It "works", but you need to shuffle the names in the same way:
> >
> > names(dat)[3:5] <- names(dat)[c(5,3,4)]
> >
> > Better(?):
> >
> > perm <- c(1,2,5,3,4)
> > dat <- dat[perm]
> >
> > dat is a list.
> >
> > Göra
ut you need to shuffle the names in the same way:
>
> names(dat)[3:5] <- names(dat)[c(5,3,4)]
>
> Better(?):
>
> perm <- c(1,2,5,3,4)
> dat <- dat[perm]
>
> dat is a list.
>
> Göran
>
>
>> ________________________ From: Rolf Tu
names(dat)[3:5] <- names(dat)[c(5,3,4)]
>
> Better(?):
>
> perm <- c(1,2,5,3,4)
> dat <- dat[perm]
>
> dat is a list.
>
> Göran
>
>
>>
>> ____________ From: Rolf Turner
>> <r.tur...@auckland.ac.nz> Sent: Friday, Apr
r-help Subject: Re: [FORGED] Re: [R] How create columns
for squared values from previous columns?
On 29/04/17 13:21, C W wrote:
I came up with this solution,
cbind(dat, dat[, 1:3]^2)
X1 X2 X3 X4 X5 X1 X2
X3 1 0.72776481 -1.1332612 -1.9857503 0.4618
.ac.nz>
Sent: Friday, April 28, 2017 10:48:42 PM
To: C W
Cc: r-help
Subject: Re: [FORGED] Re: [R] How create columns for squared values from
previous columns?
On 29/04/17 13:21, C W wrote:
> I came up with this solution,
>
>> cbind(dat, dat[, 1:3]^2)
>X1
On 29/04/17 13:21, C W wrote:
I came up with this solution,
cbind(dat, dat[, 1:3]^2)
X1 X2 X3 X4 X5 X1
X2X3
1 0.72776481 -1.1332612 -1.9857503 0.46189400 -0.09016379 0.529641625
1.28428102 3.9432044
2 0.05126592 0.2858707
6 matches
Mail list logo