在R语言中,添加一列数据的方法有以下几种:
$
操作符向数据框中添加新列,例如:dataframe$new_column <- new_data
transform()
函数向数据框中添加新列,例如:dataframe <- transform(dataframe, new_column = new_data)
mutate()
函数来添加新列,例如:library(dplyr)
dataframe <- dataframe %>% mutate(new_column = new_data)
cbind()
函数将新列添加到数据框中,例如:dataframe <- cbind(dataframe, new_column = new_data)
亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
推荐阅读:r语言添加一列数据的方法是什么