Assigning colnames() to specific column of a data frame

前端 未结 3 464
梦谈多话
梦谈多话 2021-01-14 11:22

I have a question about the colnames function in the base package

Let\'s say you have a data.frame, as follows:

df <- data.frame(var         


        
3条回答
  •  醉话见心
    2021-01-14 11:28

    Because you should be doing this:

    > colnames(df)[1] <- "test"
    > colnames(df)[1]
    [1] "test"
    

    The colnames function returns a character vector that can be altered.

提交回复
热议问题