[R] Squaring one column of data

Kenny Larsen k.larsen at sheffield.ac.uk
Fri Jun 12 14:00:54 CEST 2009


Have sorted it, it was simple, for anyone else who needs it:

z[2] <- z[2]*z[2]

squares the second column of a data table and writes it back to the second
column

Kenny



Kenny Larsen wrote:
> 
> Hi,
> 
> A fairly basic problem I think, here although searching the inetrnet
> doesn't seem to reveal a solution. I have a dataset with two columns of
> real numbers. It is read in via read.table. I simply need to square the
> data in the second column and then plot it. I have tried extracting the
> second column (b <- z[2]) and then squaring it and merging it to a
> variable which is the first column extracted. Firstly thsi seems very
> convoluted, secondly it gives a seg fault (I'm guessing because memory
> hasn't been allocated for the second column on the creation of teh first
> variable).
> 
> So any ideas about the easy way of doing the matsh so I can then just use
> plot(z, .....) as before?
> 
> Cheers in advance,
> 
> Kenny
> 

-- 
View this message in context: http://www.nabble.com/Squaring-one-column-of-data-tp23997104p23997558.html
Sent from the R help mailing list archive at Nabble.com.




More information about the R-help mailing list