What is the method for adding a column of data in the R language?

In R language, to add a column of data to a data frame, you can use one of the following methods:

  1. “Use the $ symbol”
dataframe$new_column <- new_data
  1. Using square brackets:
dataframe['new_column'] <- new_data
  1. Utilize the cbind() function:
dataframe <- cbind(dataframe, new_column = new_data)
Leave a Reply 0

Your email address will not be published. Required fields are marked *


广告
Closing in 10 seconds
bannerAds