[R] Convert a data frame to a 2D array?

Joshua Wiley jwiley.psych at gmail.com
Tue Jun 8 18:19:19 CEST 2010


Hi,

Does this work?

array(data=unlist(yourdataframe), dim=c(n,m))


Josh

On Tue, Jun 8, 2010 at 9:07 AM, A Huang <mytechforum at yahoo.com> wrote:
> Hi there,
>
> I've read a file into a data frame. The data is n rows by m columns, all values are numbers.
> Is there a way to convert the data frame to a 2D array? I tried as.array(), but got some
> error messages.
>
> Thanks
>
> A. Huang
>
>
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org 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.
>



-- 
Joshua Wiley
Senior in Psychology
University of California, Riverside
http://www.joshuawiley.com/



More information about the R-help mailing list