Created
October 7, 2019 18:10
-
-
Save monogenea/6513a60127517048a4a80d420a35ee3c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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