[R] Odp: Dataframe manipulation
petr.pikal at precheza.cz
Fri Mar 19 09:15:50 CET 2010
maybe you shall be a little bit more clear what you really want. It is
hard to copy your data o R without some extensive fiddling, so we need to
rely on complicated text description.
It seems that
could help you but it is hard to check.
Basically I would recode ARRIVE and DEPART as POSIX class as I suggested
before. Then you can do some arithmetic with it.
At least you shall tell us what you want to be in second value for ARRIVE.
If your task is not repeating and size of your data is not too big
probably some looping could be also suitable. Or also zoo and function
na.locf can help but without data, shrug.
Sorry that I can not provide canned help but I am really not sure what the
output shall be.
r-help-bounces at r-project.org napsal dne 18.03.2010 14:48:06:
> Hello R users,
> I spent most of my workday yesterday trying unsuccessfully to
> write code that will perform a series of calculations on my
> dataframe (partial copy is attached). What I need to do is
> multiply the 24 hr time in the 'DEPART' column by the time
> (in the 'TRAVEL' column (travel time in minutes), and store this
> result in the 'ARRIVE' column for the following 'SITE1' number.
> Then I need to add the 'WAIT' time (minutes) for that site's row
> to its 'ARRIVE' time to calculate the next 'DEPART' time and
> then proceed down the dataframe independently for each unique 'MM'
> by 'DD' combination. What I want to do I hope will be obvious after you
> view the dataframe. Basically, for each unique 'MM' (month) by 'DD'(day)
> I have four sites that are surveyed sequentially, and the starting
> site for a survey day was chosen randomly. The route is circular,
> proceeding from site 101 to 104. I really hope someone can help
> me with this, because I am so close to finishing it.
> BTW, the code that adds minutes to 24 hr time to create 24 hr time is as
> new.Date<-strsplit(as.character(new.Date)," ")
> (code courtesy of Gustaf)
> Thank you,
> [příloha Dataframe.pdf odstraněna uživatelem Petr PIKAL/CTCAP]
> R-help at r-project.org mailing list
> PLEASE do read the posting guide
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help