Linux 拨号vps windows公众号手机端

r语言添加一列数据的方法有哪些

lewis 9年前 (2016-08-17) 阅读数 10 #程序编程
文章标签 r语言

在R语言中,添加一列数据的方法有以下几种:

  1. 使用$操作符向数据框中添加新列,例如:
dataframe$new_column <- new_data
  1. 使用transform()函数向数据框中添加新列,例如:
dataframe <- transform(dataframe, new_column = new_data)
  1. 使用mutate()函数来添加新列,例如:
library(dplyr)
dataframe <- dataframe %>% mutate(new_column = new_data)
  1. 使用cbind()函数将新列添加到数据框中,例如:
dataframe <- cbind(dataframe, new_column = new_data)
版权声明

本文仅代表作者观点,不代表米安网络立场。

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

热门