[R] 2 data frames - list in one out put , matrix in another ??

John Kane jrkrideau at yahoo.ca
Mon Feb 26 20:56:07 CET 2007


I have two more or less parallel dataframes that are
giving me different results on one subset of
variables.  I know that I assembled the 2 dataframes
slightly differently but I don't see why I am getting
this result because one set of variables are labelled
and the other is not. Variable names are the same,
etc.  as far as I can acertain.  The only diffference
seems to be that bdata variables are labelled.  

About now I really don't care which I get but I would
like them to be the same.  Can anyone suggest what I
am doing wrong or should be looking at?

Windows XP , R 2.4.1 Using Hmisc and gtools as well as
the basic R installation.  

Problem

load(adata)
fn1 <- function(x) {table(x)}
jj <-apply(adata[,110:127], 2, fn1)

OUTPUT jj is aa list of 18 tables
Examine a variable:
  >  typeof(adata$act.toy)
[1] "integer"
>     class(adata$act.toy)
[1] "integer"


load(bdata
fn1 <- function(x) {table(x)}
kk <-apply(bdata[,94:111], 2, fn1)

OUTPUT jj is a matrix 2 X 18
>   class(bdata$act.toy)
[1] "labelled"
>    typeof(bdata$act.toy)
[1] "integer"



More information about the R-help mailing list