Get and Set Column/Row Names for Data Frames
row.names(x)
row.names(x) <- value
rownames(x, do.NULL = TRUE, prefix = "row")
rownames(x) <- value
colnames(x, do.NULL = TRUE, prefix = "col")
colnames(x) <- value
####################################
results <- data.frame(matrix(c(1,2,3,4),nrow=2,ncol=2))
rownames(results) <- c("a","b")
colnames(results) <- c("c","d")
attr(results,"title") <- "aaa"
results
#####################################
> colnames(data)
[1] "col1" "col2" "col3"
>
> # set the name of column 2
> colnames(data)[2] <- 'column 2'
> colnames(data)
[1] "col1" "column 2" "col3"
>
> # you can assign all of the columns at once, if you wish
> colnames(data) <- c( 'col 1', 'col 2', 'col 3')
> colnames(data)
[1] "col 1" "col 2" "col 3"
> str(data)
'data.frame': 2 obs. of 3 variables:
$ col 1: Factor w/ 2 levels "1,233","470": 1 2
$ col 2: Factor w/ 2 levels " $1,113.22"," $12.79": 2 1
$ col 3: Factor w/ 2 levels " $0.12"," $1,333,233.17": 2 1
REF:
https://stackoverflow.com/questions/2281353/row-names-column-names-in-r
http://www.astrostatistics.psu.edu/su07/R/html/base/html/colnames.html
http://earlh.com/blog/2009/06/29/column-names-of-r-data-frames/
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· AI与.NET技术实操系列:基于图像分类模型对图像进行分类
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 25岁的心里话
· 闲置电脑爆改个人服务器(超详细) #公网映射 #Vmware虚拟网络编辑器
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· 零经验选手,Compose 一天开发一款小游戏!
· 一起来玩mcp_server_sqlite,让AI帮你做增删改查!!
2011-10-07 启动子 Promoter
2010-10-07 在SQL Server中,SQL语句的Insert支持一次插入多条记录
2010-10-07 SQL Server2005 不支持一条insert语句插入多条记录,2008是支持的
2010-10-07 The 'SelectedIndex' and 'SelectedValue' attributes are mutually exclusive.
2009-10-07 NOD32提示"无需更新,病毒库已是当前最新"解决方法
2008-10-07 SQL Server 事务处理 回滚事务
2007-10-07 11 Visual Studio 2005 IDE Tips and Tricks to Make You a More Productive Developer