-
Notifications
You must be signed in to change notification settings - Fork 40
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
Can fromJSON coerce type of variable? #416
Comments
Can you please include example code so we can see what you mean |
Thanks Jeroen. The code is quite simple: json2dfB <- function(id, date, key) { wuDtTEST <- lapply("IJARDN7", function(x) json2dfB(x, "20230228", apikey)) %>% And a glimpse of the downloaded data; temperature should be dbl, as in other variables: |
I can't run this code (because I don't have your Perhaps you can help by further simplifying the example, and creating a small json blob that looks like your input, and then show what jsonlite is doing wrong when we parse it. |
I am scraping weather data from Wunderground, and found that jsonlite::fromJson incorrectly maps all temperature data (five variables, which are presented in the webpage with one decimal figure) as integers with (of course) zero decimals. The command recognises however other variables (e.g., rainfall, pressure, latitude) as doubles. Is there any general reason why jsonlite could incur in this wrong mapping? Is it possible define a priori the kind of data for each available "column" in a json file before importing it with fromJSON? I appreciate any help with this issue; I already invested a lot of time looking for possible solutions.
The text was updated successfully, but these errors were encountered: