Skip to content
Prev 350218 / 398506 Next

Problem with col

--- clip--
No you probably do not, as Sarah explained.

As a quick example of the issue look at the two data sets below. Just copy and paste into your R editor.  Both data sets are in dput() format which is how you should supply sample data to R-help.

ddat1  <-   structure(list(aa = structure(1:4, .Label = c("a", "b", "c",
"d"), class = "factor"), bb = 1:4), .Names = c("aa", "bb"), row.names = c(NA,
-4L), class = "data.frame")

ddat2 <- structure(list(aa = c("a", "b", "c", "d"), bb = c("1", "2", "3", "4")), .Names = c("aa", "bb"), row.names = c(NA, -4L), class = "data.frame")

If yo do
dat1
dat2
they look the same on the screen but if you do str()  they are not the same.
str(dat1) 
str(dat2)

Also try 
ddat1$bb * 5  #works
ddat2$bb * 5 # error!


They look the same on the computer screen but they are quite different.

John Kane
Kingston ON Canada
____________________________________________________________
Can't remember your password? Do you need a strong and secure password?
Use Password manager! It stores your passwords & protects your account.