I have a data frame that looks like this:
structure(list(A = c(70, 70, 70, 70, 70, 70), T = c(0.1, 0.2,
0.3, 0.4, 0.5, 0.6), X = c(434.01, 434.01, 434.75, 434.75, 434.75,
434.01), Y = c(454.92, 454.92, 454.92, 454.92, 454.18, 454.92
), V = c(0, 0, 21.128, 0, 14.94, 14.94), thetarad = c(0.151841552716899,
0.151841552716899, 0.150990672182432, 0.150990672182432, 0.150177486839524,
0.151841552716899), thetadeg = c(8.69988012340509, 8.69988012340509,
8.6511282599214, 8.6511282599214, 8.6045361718215, 8.69988012340509
)), .Names = c("A", "T", "X", "Y", "V", "thetarad", "thetadeg"
), row.names = 1423:1428, class = "data.frame")
I want to subset specific time points in R with intervals of 30 sec. I can do this by manually subsetting each time point that I want:
a1=subset(binA, T==0.1)
a2=subset(binA, T==30)
a3=subset(binA, T==60)
a4=subset(binA, T==90)
a5=subset(binA, T==120)
a6=subset(binA, T==150)
a7=subset(binA, T==180)
a8=subset(binA, T==210)
a9=subset(binA, T==240)
a10=subset(binA, T==270)
a11=subset(binA, T==300)
a12=subset(binA, T==330)
a13=subset(binA, T==360)
a14=subset(binA, T==390)
a15=subset(binA, T==420)
a16=subset(binA, T==450)
a17=subset(binA, T==480)
a18=subset(binA, T==510)
a19=subset(binA, T==540)
a20=subset(binA, T==570)
a21=subset(binA, T==599.5)
I tried subsetting using sapplyand the seq function but got confusing results. I also want to count the unique A in each subset of data. I also know I can do this using the count function in plyrpackage.
a1=count(unique(subset(binA, T==0.1)))
but count will work with one data frame and not multiple ones (correct me if I am wrong). I also want to take the means of thetadeg for each subset (this should be easy for sapply in one data frame only). So I need help on how to write a function with specific seq points.
I know this problem is trivial but help would be appreciated.
Thanks
cutorfindIntervalwould be of use here....