Missing column-names from table()-output
The function table() will print the column-names of the dataframe in the table, when the data.frame() is created like this:
table(data.frame( var1 = "yes", var2 = "no") )
var2
var1 no
yes 1
But when i create the data.frame() like this, the table()-function will not print any column names:
e1 <- data.frame( smoking = "no", cvd = "no" )
e1 <- e1[rep(1,3495),]
e2 <- data.frame( smoking = "no", cvd = "yes" )
e2 <- e2[rep(1,57), ]
e3 <- data.frame( smoking = "yes",cvd = "no")
e3 <- e3[rep(1,2112),]
e4 <- data.frame( smoking = "yes",cvd = "yes")
e4 <- e4[rep(1,75),]
ee <- rbind( e1,e2,e3,e4)
No names are printed in the table:
> table( ee$smoking, ee$cvd)
no yes
no 3495 57
yes 2112 75
Despite the ee is actually a data.frame and has names:
> class(ee)
[1] "data.frame"
> names(ee)
[1] "smoking" "cvd"
So my question is why does the table()-function not print names when called on the ee-data.frame?