Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
# Determine intersection of compounds in features and responses
commonMols <- intersect(responses$CID,
molFeats$CID)
# Subset features and responses accordingly
responses %<>% filter(CID %in% commonMols)
molFeats %<>% filter(CID %in% commonMols)
# Compute median pleasantness across the population
medianPlsnt <- responses %>%
group_by(CID) %>%
dplyr::summarise(pleasantness = median(`VALENCE/PLEASANTNESS`, na.rm = T))
all(medianPlsnt$CID == molFeats$CID) # TRUE - rownames match
# Concatenate predictors (molFeats) and population pleasantness
X <- mutate(molFeats, Y = medianPlsnt$pleasantness) %>%
select(-CID)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.