Re: [R] Questions about doing analysis based on time

2012-07-12 Thread APOCooter
Another new question: I want to be able to subset the data based on whether or not that data point was recorded on a holiday. The is.holiday() function from the chron package would be perfect for this. However, when I try it, the following happens (I'm also using the timeDate package): > holida

Re: [R] Questions about doing analysis based on time

2012-07-11 Thread Rui Barradas
Hello, If I understanding it, what you want are the values below. half.hours <- function(x){ s <- strsplit(as.character(x), ":") H <- as.integer(sapply(s, `[`, 1)) M <- as.integer(sapply(s, `[`, 2)) h <- (H*60 + M)/60 floor(h/0.5)*0.5 } half.hours(dat$Sun

Re: [R] Questions about doing analysis based on time

2012-07-11 Thread APOCooter
Hmm, I guess that's not exactly what I needed. It's my fault; you gave me what I asked for, I was just asking for the wrong thing. What I'm hoping to do is something similar to: aggregate(dat$SunScore, by=list(h), median) except I'd like to do it by half hour instead of hour. I guess what I ne

Re: [R] Questions about doing analysis based on time

2012-07-10 Thread Rui Barradas
Hello, You can use cut.POSIXt from package base. cut(dat$SunDate, breaks="30 mins") Hope this helps, Rui Barradas Em 10-07-2012 13:43, APOCooter escreveu: Thanks to everyone for their help so far. It's been greatly appreciated. I have a new, but similar problem: I have data that I have b

Re: [R] Questions about doing analysis based on time

2012-07-10 Thread APOCooter
Thanks to everyone for their help so far. It's been greatly appreciated. I have a new, but similar problem: I have data that I have broken down by hour (median/mean for each hour). I would like to break it down further, by each half hour (0:00-0:29, 0:30-0:59, 1:00-1:29, 1:30-1:59, etc). I tho

Re: [R] Questions about doing analysis based on time

2012-06-28 Thread Rui Barradas
Hello, The only explanation I'm seeing is you are computing the SunScore averages using different datasets. With the dataset oyu've dput-ed I get your hand results. aggregate(SunScore ~ h, data=dat, mean) h SunScore 1 0 131.0167 2 1 107.7436 # Another way of doing the same sapply(split(dat

Re: [R] Questions about doing analysis based on time

2012-06-28 Thread APOCooter
That is very helpful, and exactly what I was looking for! However, I seem to have some problems. When I ran the following line: aggregate(SunScore ~ h, data=dat, mean) I got the following output: h SunScore 1 0 136.01389 2 1 135.27632 3 2 127.03704 4 3 127.17105 5 4 129.94545 6

Re: [R] Questions about doing analysis based on time

2012-06-25 Thread Rui Barradas
Hello, The following worked with the supplied dataset, named 'Sunday'. dat <- Sunday dat$SunDate <- as.POSIXct(Sunday$SunDate, format="%m/%d/%Y %H:%M") dat <- na.exclude(dat) h <- hours(dat$SunDate) # 1. Two different displays aggregate(dat$SunScore, by=list(h), mean) aggregate(SunScore ~ h, da

Re: [R] Questions about doing analysis based on time

2012-06-25 Thread APOCooter
Oh, whoops. When I responded the first time, I had done dput(head(Sunday, 100)) too, but it didn't look useful. It was only just now that I saw that it basically prints out the vectors. Sorry about that. Anyways, here's dput(head(Sunday, 100)): > dput(head(Sunday, 100)) structure(list(SunDate

Re: [R] Questions about doing analysis based on time

2012-06-25 Thread R. Michael Weylandt
On Fri, Jun 22, 2012 at 3:45 PM, APOCooter wrote: > > [snip and rearrange] > >> try to put your data in a proper time series class (zoo/xts if I >>might give a personal-ish plug) which will make all these calculations >>much easier. > > I thought that's what I was doing with as.POSIXlt? as.POSIXl

Re: [R] Questions about doing analysis based on time

2012-06-25 Thread John Kane
Arrgh yes I did mean dput(head(mydata, 100)). Thanks for catching it. John Kane Kingston ON Canada > -Original Message- > From: michael.weyla...@gmail.com > Sent: Fri, 22 Jun 2012 14:25:30 -0500 > To: jrkrid...@inbox.com > Subject: Re: [R] Questions about doing analysi

Re: [R] Questions about doing analysis based on time

2012-06-22 Thread APOCooter
Here is a part of the data for the first two questions: > head(Sunday,100) SunDate SunTime SunScore 1 5/9/2010 0:000:00 127 26/12/2011 0:000:00 125 36/15/2008 0:040:04 98 4 8/3/2008 0:070:07 118 57/24/2011 0:070:07 122 6

Re: [R] Questions about doing analysis based on time

2012-06-22 Thread R. Michael Weylandt
ocess as a reply to the > list and we will have decent data to work with. > > John Kane > Kingston ON Canada > > >> -Original Message- >> From: mikeedinge...@gmail.com >> Sent: Fri, 22 Jun 2012 09:21:40 -0700 (PDT) >> To: r-help@r-project.org >

Re: [R] Questions about doing analysis based on time

2012-06-22 Thread John Kane
--Original Message- > From: mikeedinge...@gmail.com > Sent: Fri, 22 Jun 2012 09:21:40 -0700 (PDT) > To: r-help@r-project.org > Subject: [R] Questions about doing analysis based on time > > > I have a spreadsheet that I've read into R using read.csv. I've also > att

[R] Questions about doing analysis based on time

2012-06-22 Thread APOCooter
Man, R has a steep learning curve (but I suppose you all know this). I have very little programming knowledge, so when I search for answers to my questions, I struggle with making sense of a lot of the pages. I have a spreadsheet that I've read into R using read.csv. I've also attached it. It l