[R] Manipulation

michael.hopgood michael.hopgood at mrm.se
Mon Jan 17 21:49:30 CET 2011


Dear R family,
I am a relative newbie and have been dabbling with R for a little while. 
Simple things really, but my employers are beginning to see the benefits of
using R instead of excel. We have a remote monitoring station measuring
groundwater levels.  We download the  date as a .csv file and up until now,
we have been using excel to analyse the data.  It’s been a hassle trying to
wrestle with that damn program as my boss wants to do things that excel was
never meant to do,  so I’ve convinced my boss to give R a chance.  It’s been
a steep learning curve, but I’m fairly confident I can reduce the amount of
labour involved in producing and improving the graphs we show our clients.

The groundwater levels are measured by pressure sensors lowered into the
monitoring wells.   After a certain time, the sensors were lowered further
into the well, thus creating a disparity in the measurements.  

The data frame I import into R looks something like this:
Date            Waterhead (mm)  Parameter 1 Paramater 2, etc.
10-01-01     100
10-01-02     105
10-01-03     101
10-01-04      99
10-01-05      85
10-01-06    200  # <- Sensor lowered#
10-01-07    199
10-01-08    195
10-01-09    185
10-01-10    170

For example, on the 10-10-06, the sensor was lowered by 115 mm. 
When I download the csv file, I download the data from the beginning of the
measurement period. I then need to adjust the height by 115 mm to account
for the lowering of the parameter.  My question to you is how do I do that
in R?
I am after a formula or a manipulation that selects the first five
measurements of a column in the data frame and adds a fixed amount.  This is
something that is added everytime I download the csv file and import it into
R so that when I display my data, it is based on the following data frame:

Date            Waterhead (mm)
10-01-01     215
10-01-02     220
10-01-03     216
10-01-04      214
10-01-05      200
10-01-06    200
10-01-07    199
10-01-08    195
10-01-09    185
10-01-10    170

In short, I want to select a fixed number of rows from my data frame, add a
constant to the rows of one of the columns, and insert the new values into
their respective rows without affecting the subsequent rows.  I hope I have
produced a reproducible example, I have been searching high and low for a
solution, but have come up against a brick wall. I feel I have read
something that tackles this some time in the past, but can’t find it again.
Thanks in advance!

Sincerely,
Michael Hopgood
MRM Konsult AB


-- 
View this message in context: http://r.789695.n4.nabble.com/Manipulation-tp3221260p3221260.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list