Specifying column names in a data.frame changes spaces to “.”

后端 未结 4 1727
耶瑟儿~
耶瑟儿~ 2020-11-28 14:25

Let\'s say I have a data.frame, like so:

x <- c(1:10,1:10,1:10,1:10,1:10,1:10,1:10,1:10,1:10,1:10)
df <- data.frame(\"Label 1\"=x,\"Label 2\"=rnorm(10         


        
4条回答
  •  猫巷女王i
    2020-11-28 14:41

    You don't.

    With the space you desire the format would not satisfy the requirements for an identifier that come to play when you use df$column.1 -- that could not cope with a space. So see the make.names() function for details or an example:

    > make.names(c("Foo Bar", "tic tac"))
    [1] "Foo.Bar" "tic.tac"  
    >                                              
    

提交回复
热议问题