[R] Multiplication of data frame with vector
Stein, Luba (AIM SE)
LUBA.STEIN at allianz.com
Tue Jul 7 16:16:48 CEST 2009
Thank you for your help!
But is it possible to produe two vectors x and y with a given length such that there correlation is zero.
For me ist not enough just to simulate two vectors with there correlation.
Thank you,
Luba
-----Urspr?ngliche Nachricht-----
Von: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] Im Auftrag von David Freedman
Gesendet: Dienstag, 7. Juli 2009 14:53
An: r-help at r-project.org
Betreff: Re: [R] Multiplication of data frame with vector
Would the scale function work for this? Something like
new=scale(df, center=T)
HTH,
david freedman
cir p wrote:
>
>
> Dear group:
> sorry for my beginners question, but I'm rather new to R and was searching
> high and low without success:
>
> I have a data frame (df) with variables in the rows and observations in
> the columns like (the actual data frame has 15 columns and 1789 rows):
>
> early1 early2 early3 early4 early5
> M386T1000 57056 55372 58012 55546 57309
> M336T90 11063 10312 10674 10840 11208
> M427T91 12064 11956 12692 12340 11924
> M429T91 4594 3890 4096 4019 4204
> M447T90 26553 27647 26889 26751 26929
>
> Now I'm trying to transform each value column-wise to make columns to all
> have the same mean with:
>
> df * mean(mean(df)) / mean(df).
>
> I just can't get my head around this: mean(df) gives me the correct column
> means vector, and mean(mean(df)) gives me the correct total mean. The
> above operation works correctly for individual rows, i.e. if I do
> df[1,]*mean(mean(df))/mean(df)
>
> Can someone tell me what I am doing wrong??
> Thanks!
>
> ______________________________________________
> 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.
>
>
--
View this message in context: http://www.nabble.com/Multiplication-of-data-frame-with-vector-tp24368878p24372764.html
Sent from the R help mailing list archive at Nabble.com.
______________________________________________
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.
More information about the R-help
mailing list