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
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
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
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
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
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
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
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
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
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
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
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
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
>
--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
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
15 matches
Mail list logo