Ah, that works! Thank you!
From: PIKAL Petr <petr.pi...@precheza.cz>
Sent: Tuesday, May 2, 2017 7:56:33 AM
To: C W; r-help
Subject: RE: [R] How create columns for squared values from previous columns?
Hi
you can use data.frame
data.frame(dat, dat[,
p@r-project.org>
> Subject: Re: [R] How create columns for squared values from previous
> columns?
>
> I came up with this solution,
>
> > cbind(dat, dat[, 1:3]^2)
>X1 X2 X3 X4 X5 X1
> X2X3
>
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 0.9075806 1.27582713 -0.49438507
Dear R list,
I am am a little unsure what is the best way to approach this. I suppose I
have
> dat <- matrix(rnorm(30), ncol = 5)
> dat <- data.frame(dat)
> dat
X1 X2 X3 X4 X5
1 -1.1317 -0.87868106 -0.33000492 1.5241765 -0.92483388
2 -0.56168006
4 matches
Mail list logo