[R] from "table" to "dataframe"

Liaw, Andy andy_liaw at merck.com
Tue Dec 5 17:03:36 CET 2006


Like this?

R> data.frame(unclass(df2))
   a b c d
s1 8 4 4 4
s2 8 4 4 4
s3 8 4 4 4

Andy
 

From: Milton Cezar Ribeiro
> 
> Hi there, 
>    
>   I have a two-entrance dataframe, and I would like generate 
> a new dataframe with its frequency. I tryed this
>    
>   site<-rep(c("s1","s2","s3"),20)
> species<-rep(c("a","b","a","c","d"),12)
>   df<-data.frame(cbind(site,species))
>   df2<-table(df)
> 
>   But when I convert df2 to data.frame I miss the square 
> format. I would like have my data.frame like this:
>    
>   site a b c d
>   s1 8 4 4 4
>   s2 8 4 4 4
>   s3 8 4 4 4
>    
>   Any help?
>    
>   Miltinho
> 
>  		
> ---------------------------------
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> 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.
> 
> 
> 


------------------------------------------------------------------------------
Notice:  This e-mail message, together with any attachments,...{{dropped}}




More information about the R-help mailing list