There are 2 data frame. df1 is the original data and df2 is the output data (changed data) - but the original columns are displayed as they are.
I'd like to change column name and value (df2 → df1).
Please help me.
- Change "ch_id, ch_age, ch_score" name to id, age, score
- Change value df2 -> df1 (age, score)
Example:
id <- c("1", "2", "3", "4", "5", "6", "7")
age <- c(24, 28, 31, 25, 27, 22, 29)
sex <- c("male", "female", "female", "male", "female", "male", "female")
score <- c(90, 80, 85, 75, 95, 80, 70)
df1 <- data.frame(id, age, sex, score, stringsAsFactors = FALSE)
df1
ch_id <- c("1", "2")
ch_age <- c(50, 40)
ch_score <- c(80, 80)
df2 <- data.frame(ch_id, ch_age, ch_score, stringsAsFactors = FALSE)
df2