Add Prefix to Column Names in R (Example) | Affix Before Variable of Data Frame | paste0() Function

preview_player
Показать описание
R code of this video:

x2 = 4:7,
x3 = 4)
data # Print example data

data_new <- data # Duplicate data
colnames(data_new) <- paste0("foo_", colnames(data_new)) # Add prefix
data_new # Print updated data

Follow me on Social Media:
Рекомендации по теме
Комментарии
Автор

I need help. I have:
library("PNADcIBGE")
variaveis_selecionadas <- c("UF", "Capital", "V2007", "VD4002", "VD4001")

for (i in 2012:2012){
for (j in 1:2){
paste0("PNAD_", j, i) <- get_pnadc(year=i, quarter=j, deflator = TRUE,
vars=variaveis_selecionadas)
}
}
I have this mistake:
"Error in paste0("PNAD_", j, i) <- get_pnadc(year = i, quarter = j, deflator = TRUE, :
target of assignment expands to non-language object"
I would like to save the PNAD files with the i, j indices. j = quarters and i = years
from Brazil

rubicleisgomes
Автор

How would this work if I wanted to add a suffix instead?

noratarraf
visit shbcf.ru