Reputation: 233
I am trying to subset a data frame based on a range of time. Someone has asked this question in the past and the answer was to use R CMD INSTALL lubridate_1.3.1.tar.gz
(see link: subset rows according to a range of time.
The issue with this answer is that I get the following warning:
> install.packages("lubridate_1.3.2.tar.gz")
Warning in install.packages :
package ‘lubridate_1.3.2.tar.gz’ is not available (for R version 3.1.2)
I am looking for something very similar to this answer but I cannot figure out how to do this. I have a MasterTable
with all of my data organized into columns. One of my columns is called maxNormalizedRFU
.
My question is simple:
How can I subset my maxNormalizedRFU
column by time?
I would simply like to add another column which only displays the maxNormalizedRFU
the data between 10 hours and 14 hours. Here is what I have up to now:
MasterTable <- inner_join(LongRFU, LongOD, by= c("Time.h", "Well", "Conc.nM", "Assay"))
#normalizes my data by fluorescence (RFU) and optical density (OD) based on 6 different subsets called "Assay"
MasterTable$NormalizedRFU <- MasterTable$AvgRFU/MasterTable$AvgOD
#creates a column that only picks the maximum value of each "Assay"
MasterTable <- ddply(MasterTable, .(Conc.nM, Assay), transform, maxNormalizedRFU=max(NormalizedRFU))
#The issue
MasterTable$CutmaxNormalizedRFU <- ddply(maxNormalizedRFU, "Time.h", transform, [MasterTable$Time.h < 23.00 & MasterTable$Time.h > 10.00,])
Attached is a sample of my dataset. Since the original file has over 90 000 lines, I have only attached a small fraction of it (only one assay and one concentration).
My line is currently using ddply to do the subset but this simply does not work. Does anyone have a suggestion as to how to fix this issue?
Thank you in advance!
Marty
Upvotes: 0
Views: 413
Reputation: 23574
I downloaded your data and had a look. If I am not mistaken, all you need is to subset data using Time.h
. Here you have a range of time (10-23) you want. I used dplyr
and did the following. You are asking R to pick up rows which have values between 10 and 23 in Time.h
. Your data frame is called mydf
here.
library(dplyr)
filter(mydf, between(Time.h, 10, 23))
Upvotes: 1