[R] working on a data frame

Matthew mccormack at molbio.mgh.harvard.edu
Thu Jul 24 23:19:38 CEST 2014


I am coming from the perspective of Excel and VBA scripts, but I would 
like to do the following in R.

  I have a data frame with 14 columns and 32,795 rows.

I want to check the value in column 8 (row 1) to see if it is a 0.
If it is not a zero, proceed to the next row and check the value for 
column 8.
If it is a zero, then
a) change the zero to a 1,
b) divide the value in column 9 (row 1) by 1,
c) place the result in column 10 (row 1) and
d) repeat this for each of the other 32,794 rows.

Is this possible with an R script, and is this the way to go about it. 
If it is, could anyone get me started ?

Matthew



More information about the R-help mailing list