# might fail if API is not available
# return all hits
pan_query('2,4-dichlorophenol')[c(1, 2, 5, 74)]
# return only first hit
pan_query('2,4-dichlorophenol', match = 'first')[c(1, 2, 5, 74)]
# return only best hit
pan_query('2,4-dichlorophenol', match = 'best')[c(1, 2, 5, 74)]
# returns NA
pan_query('xxxxx')
### multiple inputs
comp <- c('Triclosan', 'Aspirin')
# retrive CAS
sapply(comp, function(x) pan_query(x, match = 'best')[['CAS Number']])
# multiple columns
ll <- lapply(comp, function(x) pan_query(x, match = 'best')[c(1, 2, 5, 74)])
do.call(rbind, ll)
Run the code above in your browser using DataLab