Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Examples does not work #1

Closed
matteodefelice opened this issue Aug 29, 2016 · 6 comments
Closed

Examples does not work #1

matteodefelice opened this issue Aug 29, 2016 · 6 comments

Comments

@matteodefelice
Copy link

matteodefelice commented Aug 29, 2016

Hi,
I have created an account and I tried to execute the sample commands in the GitHub homepage of the package:

> df <- cams_get_radition(username, lat=60, lon=15, 
                        date_begin="2016-01-01", date_end="2016-01-15")
Error in cams_get_radition(username, lat = 60, lon = 15, date_begin = "2016-01-01",  : 
  unused argument (lon = 15)

it seems that the argument is now lng instead of lon. I tried the right argument:

> df <- cams_get_radition(username, lat=60, lng =15, 
                        date_begin="2016-01-01", date_end="2016-01-15")
Error in match.arg(encode) : 
  'arg' should be one of “multipart”, “form”, “json”

the problem comes from httr::POST in cams_api, in line 95 you set as argument encode the value raw but my httr doc says:

POST(url = NULL, config = list(), ..., body = NULL,
  encode = c("multipart", "form", "json"), multipart = TRUE,
  handle = NULL)

the encode raw option is instead present in httr version 1.2.1 but not in the 1.1.0 I have on my Microsoft R 3.3.0. So, you should add a dependency to this particular version of httr.

UPDATE: I have installed the latest httr from Hadley's repository on GitHub and now I get:

> filename <- paste0(tempfile(), ".nc")
> 
> r <- cams_api(username, 60, 15, "2016-06-01", "2016-06-10", 
+               format = "application/x-netcdf", filename = filename)
No encoding supplied: defaulting to UTF-8.
xmlXPathEval: evaluation failed
xmlXPathEval: evaluation failed
xmlXPathEval: evaluation failed
Warning messages:
1: In node_find_all(x$node, x$doc, xpath = xpath, nsMap = ns) :
  Undefined namespace prefix [1219]
2: In node_find_all(x$node, x$doc, xpath = xpath, nsMap = ns) :
  Undefined namespace prefix [1219]
3: In node_find_all(x$node, x$doc, xpath = xpath, nsMap = ns) :
  Undefined namespace prefix [1219]

and r$ok is FALSE.

@lukas-rokka
Copy link
Contributor

Thank you for feedback, @matteodefelice.

  1. Documentation now updated. lon -> lng
  2. cams_api is POSTing a string with xml/text content, but seems like the "multipart" options work just as well as "raw". So should now work with older httr as well.

@matteodefelice
Copy link
Author

thank you for the update, unfortunately I still get the last error...

@lukas-rokka
Copy link
Contributor

What version of xml2 do you have?

@matteodefelice
Copy link
Author

matteodefelice commented Aug 29, 2016

I had the 0.1.2, after updating to the latest dev release now your package works!

@lukas-rokka
Copy link
Contributor

Ok, thanks. That could be it. CRAN version of xml2 is at 1.0.0.

I've now updated it with conservative dependency settings in the DESCRIPTION file. So if you reinstall it should updated those as well.

It works on Travis-CI (Linux) and on my computer with windows/rstudio with latest CRAN updates (also with httr as github dev version).

If you still get errors, could you please run it with verbose=TRUE in the call to cams_api/cams_get_radiation and paste the output here or email it to me.

FYI: the package is also under review to onboard to rOpenSci.

@matteodefelice
Copy link
Author

Now it works smoothly, it is very useful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants