Hello,
Thank you for response
I have try reshape function, but i do not like the way how it generate
columns and row names. Currently
> tapply(s$value, list(s$day, s$symbol), mean)
seems to generate exactly what i need
Cheers,
Dima
2011/3/5 Uwe Ligges
>
>
>
> On 04.03.2011 11:38, Dmitrij Ku
On 04.03.2011 11:38, Dmitrij Kudriavcev wrote:
Hello
Let's say, my data.frame is
symbol,day,value
A, 2010-01-01, 0.
A, 2010-01-02, 0.
B, 2010-01-01, 0.
i need to get matrix as
See ?reshape, in this case if you data.frame is in dat:
reshape(dat, v.names="value", direction="wi
I have never used it, but I think the reshape and/or reshape2 packages
are designed for it.
Check the melt() and cast() functions in these packages... I guess...
Ivan
Le 3/4/2011 11:33, Dmitrij Kudriavcev a écrit :
Hello, no. I need to change data format, so i can build covariance matrix on
it
Hello, no. I need to change data format, so i can build covariance matrix on
it
Cheers,
Dima
2011/3/4 Alberto Negron
> 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 Kudr
Hello
Let's say, my data.frame is
symbol,day,value
A, 2010-01-01, 0.
A, 2010-01-02, 0.
B, 2010-01-01, 0.
i need to get matrix as
, A, B
2010-01-01, 0., 0.
2010-01-02, 0., NA
where A and B is columns name and date used as row name
I found a way how to do it with tapply
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 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
Hi,
Let's say your data.frame is called df:
df <- data.frame(a=rnorm(10), b=rnorm(10))
data.matrix <- as.matrix(df)
This should work, but be careful with coercion if you have different
modes in your data.frame
HTH,
Ivan
PS: next time, provide a reproducible example, using dput() for example
7 matches
Mail list logo