I'm stuck on a problem, let's say we have a 1 column dataframe dfCHEM
CHEM_NAME
Aspirin
Captopril
(...)
I want to create a second column based on the string of the first using webchem::get_cid()
CHEM_NAME CID
Aspirin 2244
Captopril 44093
(...)
I try this code which doesn't work:
dfCHEM %>%
mutate(CID=get_cid(CHEM_NAME)[[1]])
I'm convinced that it's related to the use of a get_cid()
function inside the mutate which doesn't retrieve CHEM_NAME
string value at the corresponding row, but i don't know how to correct this in an efficient manner.