>> You will get the warning that last last column is not "going right" but
>> otherwise this returns what you asked for:
>>
>> sapply(1:length(mydf), function(i) mydf[[i]]* as.numeric(names(mydf)[i]) )
>
> This suits my purposes well with a couple slight modifications:
>
> ## I made this into a da
Thanks for the response David.
On Tue, Aug 16, 2011 at 1:13 PM, David Winsemius wrote:
>
> On Aug 16, 2011, at 3:37 PM, Sam Albers wrote:
>
>> ## Hello there,
>> ## I have an issue where I need to use the value of column names to
>> multiply with the individual values in a column and I have many
Sorry, my second should be:
scale(mydf[,1:3],center = FALSE,
scale=1/as.numeric(names(mydf)[1:3])) ## ?scale
-- Bert
On Tue, Aug 16, 2011 at 1:30 PM, Bert Gunter wrote:
> How about:
>
> as.matrix(mydf[,1:3]) %*% diag(as.numeric(names(mydf)[1:3]))
>
> or
>
> scale(mydf[,1:3],1/as.numeric(nam
How about:
as.matrix(mydf[,1:3]) %*% diag(as.numeric(names(mydf)[1:3]))
or
scale(mydf[,1:3],1/as.numeric(names(mydf)[1:3])) ## ?scale
to create your new columns?
-- Bert
On Tue, Aug 16, 2011 at 1:13 PM, David Winsemius wrote:
>
> On Aug 16, 2011, at 3:37 PM, Sam Albers wrote:
>
>> ## Hello
On Aug 16, 2011, at 3:37 PM, Sam Albers wrote:
## Hello there,
## I have an issue where I need to use the value of column names to
multiply with the individual values in a column and I have many
columns to do this over. I have data like this where the column names
are numbers:
mydf <- data.fra
## Hello there,
## I have an issue where I need to use the value of column names to
multiply with the individual values in a column and I have many
columns to do this over. I have data like this where the column names
are numbers:
mydf <- data.frame(`2.72`=runif(20, 0, 125),
`3.2
6 matches
Mail list logo