I have the feeling I am close but I cannot get it to work and your help would be greatly appreciated.
My goal is to subset data in a list based on the value of 1 of the factors. It is data concerning subjects that have been exposed to stimuli at varying timepoints. Now I want to subset the data of all variables for all subject per stimulus. The variable of the stimulus is called 'Stimulus'. And stimulus has name for example "Happy 8". So example path: SubjList$Subject1$Stimulus["Happy 8"] (although this also doesn't work.
My dataframe has the following structure:
Subjdf Large list (38 elements)
Each element is a data.frame with around 4000 observations(varying) and 26 variables (including "Stimulus")
Now I can subset one column over all subjects (elements) by doing the following:
ColSub <- (lapply(SubjList,'[[','Stimulus'))
But when I try to implement a condition it does not work.
Happy8 <- (lapply(SubjList,'[[','Stimulus'=='Happy 8'))
Not does simple selection methods like:
Happy8 <- SubjList$Subject1$Stimulus["Happy 8", ]
So, I there a way to subset only the rows that follow the condition op "Stimulus"=="Happy 8". and the create a list of of same subjects with same variables but only the observations of Stimulus Happy 8.
Thank you in advance!