avoid using F, spell it out Use an appropriate TZ... e.g. use Sys.setenv( TZ="Etc/GMT+5" ) before converting if your time is local standard time year round
Use difftime to add to time values for consistent results endt <- startt + as.difftime( data2$V6, units="secs" ) Use the str function to explore your data --------------------------------------------------------------------------- Jeff Newmiller The ..... ..... Go Live... DCN:<jdnew...@dcn.davis.ca.us> Basics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/Batteries O.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --------------------------------------------------------------------------- Sent from my phone. Please excuse my brevity. Cat Cowie <cat.e.co...@gmail.com> wrote: >Hi Gerrit, > >Thanks for your quick reply - this, in combination with reversing the >date as it is shown in my data, worked perfectly. > >startt<- strptime((paste(data2$V4, data2$V5)), "%Y-%m-%d %H:%M:%S") > >Apologies for the silly question it seems, but you've saved me a lot >of time. Always learning.... >Thanks, Cat > > > >On 12 April 2013 15:00, Gerrit Eichner ><gerrit.eich...@math.uni-giessen.de> wrote: >> Hello, Cat, >> >> see inline below. >> >> Hth -- Gerrit >> >> >> On Fri, 12 Apr 2013, Cat Cowie wrote: >> >>> Hi R forum, >>> >>> Each row of my data (below) show a new contact event between >animals. >>> In order to ultimately look at the patterns of intervals between >>> contacts, I need to calculate a contact end time. The contact starts >>> at the date and time shown in V4 and V5, and lasts for the duration >>> shown IN SECONDS in V6: >>> >>> >>>> data2<- read.csv(file=file.choose(), header=F, sep=" ") >>>> head(data2) >>> >>> V1 V2 V3 V4 V5 V6 >>> 1 3 PO4 CO1 2011-04-29 07:27:21 28 >>> 2 3 PO4 CO1 2011-04-24 05:57:39 20 >>> 3 3 PO4 CO1 2011-04-14 10:29:49 4 >>> 4 3 PO4 CO1 2011-04-16 07:27:31 63 >>> 5 3 PO4 CO1 2011-04-18 15:46:20 1 >>> 6 3 PO4 CO1 2011-04-18 15:45:57 1 >>> >>> To start with I have tried to make the start data and time into one >new >>> column: >>> >>> startt<- strptime((paste(data2$V4, data2$V5)), "%d/%m/%Y %H:%M:%S") >> >> >> Shouldn't you use "-" instead of "/" as it is used in data$V4? >> >> >> >>> This executes without any warnings, but returns a full column of NA >>> values. It would be great to fix this, and then to know how to >>> correctly add column V6 as seconds to the resulting column. >>> >>> >>> The problem is further exacerbated by an error with dput() with this >>> data. It's a large dataset of over 9000 rows, and when I call: >>> >>> dput(head(data2,50)) >>> >>> It returns dput(), but for all the data (i.e. not the first 50 >rows). >>> This of course does not fit on the workstation screen and therefore >I >>> cannot find out what class it has assigned to any of the data. The >>> times appear sorted, suggesting they are being classed as a factor? >>> Sorry I can't provide dput() data! >>> >>> Thanks, Cat >>> >>> ______________________________________________ >>> R-help@r-project.org mailing list >>> https://stat.ethz.ch/mailman/listinfo/r-help >>> PLEASE do read the posting guide >>> http://www.R-project.org/posting-guide.html >>> and provide commented, minimal, self-contained, reproducible code. > >______________________________________________ >R-help@r-project.org mailing list >https://stat.ethz.ch/mailman/listinfo/r-help >PLEASE do read the posting guide >http://www.R-project.org/posting-guide.html >and provide commented, minimal, self-contained, reproducible code. ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.