Re: [R] How to copy data from data.frame to matrix

From: Alberto Negron <albertonegron_at_gmail.com>
Date: Fri, 04 Mar 2011 09:33:23 +0000

Can't you just convert you df as follow matrix <- as.matrix(s) ?

Double check it as I am a newbie too. :-)

Regards,

Alberto

On 4 March 2011 06:08, Dmitrij Kudriavcev <dimitrij.kudriavcev_at_ntsg.lt>wrote:

> Hello
>
> I'm a new in R
> I have a large data.frame "s" (this is actualy just a table in mysql) :
>
> > names(s)
> [1] "symbols", "day", "value"
>
> I need to convert it to simple matrix. I have define this matrix like this:
>
> > data.matrix <- matrix(nrow=nDays, ncol=nSymbols, dimnames=list(days,
> symbols))
>
> then i just copy values to the matrix using for() loop, but it seems to
> take
> very long time. Is is a more fast way to do it in R? I know, what i can
> just
> gyve s$value as source data to the matrix, but problem is, what for some
> symbols couple days could be just missed.
>
> Cheers,
> Dima
>
> [[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.
>

        [[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. Received on Fri 04 Mar 2011 - 14:01:33 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 04 Mar 2011 - 14:15:21 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive