request icon indicating copy to clipboard operation
request copied to clipboard

standard evaluation errors?

Open yina opened this issue 5 years ago • 1 comments

This problem is so simple but I can't seem to figure it out. I have some very simple code to interact with the bing web search api.

query <- "depression icd 10"
mkt <- "en-US"

hits <- api("https://api.cognitive.microsoft.com") %>%
  api_path(bing, v7.0, search) %>%
  api_headers('Ocp-Apim-Subscription-Key' = 'fake') %>%
  api_query_(q = bquote(.(query)), count = 20) %>%
  peep

It produces an error:

> hits <- api("https://api.cognitive.microsoft.com") %>%
+   api_path(bing, v7.0, search) %>%
+   api_headers('Ocp-Apim-Subscription-Key' = 'fake') %>%
+   api_query_(q = bquote(.(query)), count = 20) %>%
+   peep
Error in parse(text = x) : <text>:1:12: unexpected symbol
1: depression icd

yina avatar Sep 28 '20 06:09 yina

Sorry about that. The query should be quoted like "'depression icd 10'", with single quotes inside the double quotes. I probably should fix the lazy eval internals, but for now you can make it work by doing that quoting

sckott avatar Sep 28 '20 22:09 sckott