weatheR icon indicating copy to clipboard operation
weatheR copied to clipboard

Issue when your data are too good

Open kemarshall opened this issue 10 years ago • 3 comments

Hi,

I found this a really useful set of functions and I'm really excited to give them a whirl. But there is a bit of an issue if your data are too good--if you're not removing any data then you actually end up with an empty dataframe. Try getInterpolatedDataByCity("Vancouver, Canada",station.list,10,2015,2016,100,6,0.3) for an example.

So I managed to figure out where the bugs that cause this are. The first is in the combineWeatherDFs function where trackNull <- which(names(dfList$station_data)=="" | names(dfList$station_data) %in% NA) returns a logical(0) if you have data without any issues, which ends up removing all your data in the next line. I kludged through it by adding trackNull <- c(trackNull,1000) as a next line here, but I'm sure there's a more elegant solution for that.

The next bug is in the filterStationData function where rm.df <- data.frame(table(substr(rm.all, 1, nchar(rm.all)-7))) returns a null frame if there is nothing to substring out. I fixed it by adding this next if(dim(rm.df)[1] == 0) { rm.df <- kept.df }. Again, not the tidiest but it seemed to work.

Anyway, I hope this helps and I'm super excited to see this package in more use!

Cheers, Katie

kemarshall avatar Jan 18 '16 03:01 kemarshall

You can make a pull request with the fixes if you'd like

mpiccirilli avatar Jan 18 '16 20:01 mpiccirilli

I'm not super confident with git, and my fixes are kind of ugly. But happy to try it out this weekend if it would be helpful!

kemarshall avatar Jan 20 '16 19:01 kemarshall

No problem. I'm always open to helpful contributions!

mpiccirilli avatar Jan 22 '16 08:01 mpiccirilli