Note that there are some explanatory texts on larger screens.

plurals
  1. POsubsetting in a specific sequence of time points in R, can I use seq?
    primarykey
    data
    text
    <p>I have a data frame that looks like this:</p> <pre><code>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") </code></pre> <p>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:</p> <pre><code>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) </code></pre> <p>I tried subsetting using <code>sapply</code>and the <code>seq</code> 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 <code>count</code> function in <code>plyr</code>package.</p> <pre><code>a1=count(unique(subset(binA, T==0.1))) </code></pre> <p>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.</p> <p>I know this problem is trivial but help would be appreciated.</p> <p>Thanks</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload