r - create a new empty variable in a dataset
# Create a new empty variable in a dataset
dataset$new_variable <- NA
Explanation:
1. dataset$new_variable
: This line of code creates a new column named "new_variable" in the dataset called dataset
.
2. <-
: This symbol is used to assign values.
3. NA
: Stands for "Not Available" or missing value in R. It is used here to initialize the new_variable column with empty (missing) values for all rows in the dataset.