[R] Strange names when creating a data.frame: Difference between <- and =

John Kane jrkrideau at yahoo.ca
Tue Oct 2 20:54:29 CEST 2007


This is just a curiosity question.  Why do the two
different syntaxes for df1 and df2 give such different
results in the names(dfx)?

Thanks


df1 <- data.frame(nas = c("A",  "B" , "B" ,"C" ,"B",
"A", "D"),nums = c(3,    2,    1,   1,   2,    3,  7))

df2 <- data.frame(nas  <- c("A",  "B" , "B" ,"C" ,"B",
"A", "D"),nums  <- c(3,    2,    1,   1,   2,    3, 
7))

df1; df2

>df1
  nas nums
1   A    3
2   B    2
    .   .

>  df2

   nas....c..A....B....B....C....B....A....D..
nums....c.3..2..1..1..2..3..7.
1                                           A         
                    3
2                                           B         
                    
3
.                                           .



More information about the R-help mailing list