r - Why can't I rename a data frame column inside a list? -


i rename columns cpu_usage process name before merge dataframes in order make more legible.

names(byprocess[[1]]) # [1] "time"      "cpu_usage" names(byprocess[1]) # [1] "ccmexec_3344" names(byprocess[[1]][2]) <- names(byprocess[1]) names(byprocess[[1]][2]) # [1] "cpu_usage" names(byprocess[[1]][2]) <- 'test' names(byprocess[[1]][2]) # [1] "cpu_usage" lapply(byprocess, names) # $ccmexec_3344 # [1] "time"      "cpu_usage" # # ... (removed several entries make more readable) # # $wrapper_1604 # [1] "time"      "cpu_usage" 

names(l[[1]][2]) returns names of object l[[1]][2]. in case data.frame 1 column (cpu_usage) using names<- replace names on new object (and not replace l[[1]])

if want use names<- on l[[1]], need have argument names<-

so

names(byprocess[[1])[2] <- names(byprocess[1]) 

performs action want


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -