# might fail if API is not available
# query common name
y1 <- ci_query('Formaldehyde', type = 'name')
str(y1) # lots of information inside
y1$inchikey
# Query by CAS
y2 <- ci_query('50-00-0', type = 'rn')
y2$inchikey
# query by inchikey
y3 <- ci_query('WSFSSNUMVMOOMR-UHFFFAOYSA-N', type = 'inchikey')
y3$name
### handle multiple inputs
cas <- c('1071-83-6', '50-00-0')
# extract inchikeys
sapply(cas, function(x){
ci_query(x, type = 'rn')$inchikey
})
Run the code above in your browser using DataLab