R语言为数据框添加列名或行名

1.添加列名

wts=c(1,1,1)

技术分享

names(wts)=c("setosa","versicolor","virginica")

技术分享

2.为矩阵添加列名和行名

wts=matrix(0,3,4)

技术分享

row=c("row1","row2","row3")

column=c("setosa","versicolor","virginica")

dimnames(wts)=list(row,column)

技术分享

 

文章来自:http://www.cnblogs.com/longzhongren/p/4305206.html
© 2021 jiaocheng.bubufx.com  联系我们
ICP备案:鲁ICP备09046678号-3