rOpenGov / fmi

Finnish Meteorological Institute open data API R client
Other
10 stars 7 forks source link

getLayer response to data.frame with only one feature? #4

Closed tts closed 8 years ago

tts commented 8 years ago

I'm trying to process the response from fmi::observations::mareograph::timevaluepair query with only one parameter (watlev).

response <- client$getLayer(layer=layers[1], parameters=list(splitListFields=TRUE))

produces a 1-feature spatialPointsDataframe, so

dat <- as.data.frame(response)

gives me a dataframe in super-wide format: one observation with all time+value pairs are variables. I find this rather difficult to clean with e.g. tidyr.

Note that this might not be an issue, rather some kind of misunderstanding from my side.

P.S. Great package BTW!

tts commented 8 years ago

Well, now that I had the time & patience, the response do was tidy-able with gather, extract and spread. Sorry about the false alarm.

jlehtoma commented 8 years ago

I had completely missed this, sorry! I remember to have been struggling with this as well, would probably make sense to do at least some tidying within the package already.