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

Petr Pikal petr.pikal at precheza.cz
Tue Feb 27 08:00:07 CET 2007


Hi

as I do not know what class is labelled and not knowing about your 
data I just try to give you some hints.

What says str(adata) and str(bdata) about structure of your data?

It can be possible that in second case the structure of resulting 
table can be formed into matrix and apply probably does this coercion 
in accordance with Details section of help page.

But this is only a guess.

HTH
Petr



On 26 Feb 2007 at 14:56, John Kane wrote:

Date sent:      	Mon, 26 Feb 2007 14:56:07 -0500 (EST)
From:           	John Kane <jrkrideau at yahoo.ca>
To:             	R R-help <r-help at stat.math.ethz.ch>
Subject:        	[R] 2 data frames - list in one out put  , matrix in another ??

> 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"
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html and provide commented,
> minimal, self-contained, reproducible code.

Petr Pikal
petr.pikal at precheza.cz



More information about the R-help mailing list