Re: [R] [FORGED] Re: How create columns for squared values from previous columns?

2017-04-29 Thread C W
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

Re: [R] [FORGED] Re: How create columns for squared values from previous columns?

2017-04-29 Thread C W
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

Re: [R] [FORGED] Re: How create columns for squared values from previous columns?

2017-04-29 Thread Bert Gunter
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

Re: [R] [FORGED] Re: How create columns for squared values from previous columns?

2017-04-29 Thread Göran Broström
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

Re: [R] [FORGED] Re: How create columns for squared values from previous columns?

2017-04-28 Thread Mike C
.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

Re: [R] [FORGED] Re: How create columns for squared values from previous columns?

2017-04-28 Thread Rolf Turner
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