[R] Adding variables

tzygmund mcfarlane tzygmund at googlemail.com
Sat Sep 26 17:39:09 CEST 2009


Hi Jim,

I might be missing something but your command gives the error:
Error in rowSums(mag) : 'x' must be an array of at least two dimensions

#############################
data(attenu)
attach(attenu)
rowSums(mag) + rowSums(station)
attenu$new<-rowSums(cbind(mag, station))
#############################

Thanks


On Sat, Sep 26, 2009 at 4:30 PM, jim holtman <jholtman at gmail.com> wrote:
> Probably more efficient if you remove the 'cbind' which would create a
> combined matrix.  Use the following:
>
> rowSums(mag) + rowSums(station)
>
> On Sat, Sep 26, 2009 at 11:16 AM, tzygmund mcfarlane
> <tzygmund at googlemail.com> wrote:
>> Hi,
>>
>> For very large matrices, is this the most efficient way to add two
>> variables together?
>>
>> #############################
>> attach(attenu)
>> new<-rowSums(cbind(mag, station))
>> #############################
>>
>> Also, could I be directed to some resources for working with very
>> large datasets?
>>
>> 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.
>>
>
>
>
> --
> Jim Holtman
> Cincinnati, OH
> +1 513 646 9390
>
> What is the problem that you are trying to solve?
>




More information about the R-help mailing list