-
Notifications
You must be signed in to change notification settings - Fork 82
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 read.socrata() return numeric fields as numeric (not character)? #192
Comments
@Lulliter - haven't been able to reproduce this issue. Looking at the first data set, I ran this code:
Which resulted in the following output:
Comparing that with the metadata, it looks like the correct data types are being used. Can you provide an example of what you're seeing, the version of RSocrata being used, version of R, and operating system? |
Hello, here are my session info:
I see what happens: If I run your same command I get the correct data types.
But I had used the link indicated as the API Endpoint (I did so, following the indication in the Code Snippets examples, so I figured that was the link to use)
Thanks! |
Makes sense. When you don't specify the data type (e.g., just copy/paste the URL from address bar), RSocrata defaults to download from CSV. But, you can provide a valid API endpoint to declare a specific file type. Socrata is optimized for speed with JSON and is considerably faster so this is sometimes necessary. However, Socrata places quotes around all values regardless of original data type so R will interpret numbers as characters. Likewise, Socrata doesn't provide an API to read field-level metadata so we can't correct this on the back-end. Will close this issue for now. We have some open issues on better handling JSON files that we can tackle if Socrata releases some improvements on metadata. Do reach out if you have any other issues. |
OK! Many thanks for the explanation. |
I am working in R with EU cohesion data (specifically datasets 99js-gm52, xns4-t7ym, 3kkx-ekfq )
The
read.socrata()
functions returns numeric fields aschr
in the dataframe. Is it possible to convert them into the correct field type?The text was updated successfully, but these errors were encountered: