I am trying to perform a simple filtering using dplyr but it doesnt seem to work with what I want to do.
I want to filter a dataframe based on Time as an example when only if Time matches the category
, then look at column Value
.
df <- read.table(header = TRUE, text = "SubjectID Treatment Time Value
A1 Amutant T0 5.3
B0 Control T0 4.8
A3 Amutant T3 4
B1 Control T1 3
B3 Control T3 6.5
C2 Bmutant T2 2
C1 Bmutant T1 3")
df %>%
group_by (Time) %>%
filter (Time == "T0") %>%
filter (Value <5)
This seems not what I exactly want to get because I want to subset the whole row of those that match T0
values <5
.
The results should be filtering out only those subjects with T0 higher than 5 but should not affect T1, T2, T3.
Thanks in advance!