Re: [R] Finding values in a dataframe at a specified hour

2015-04-13 Thread PIKAL Petr
Hi I presume your data frames are not big. What about merging them by hour and comparing appropriate columns? something like windMerged-merge(windHW, spring, by = hour, all=TRUE) sel - which(windMerged[, xx] = windMerged[,yy]) windMerged[sel, xx] - NA Untested because lack of data. Cheers

[R] Finding values in a dataframe at a specified hour

2015-04-10 Thread Alexandra Catena
Hello, I have a large dataframe (windHW) of wind speeds (ws) at each hour from many days over a set of years. Some of these values are obviously wrong (600 m/s) and I want to get rid of all the values that are larger than 5*sigma for each hour. The 5*sigma (variable name sigma5) values are

Re: [R] Finding values in a dataframe at a specified hour

2015-04-10 Thread Alexandra Catena
Update: I have this so far. * The first column of windHW is the wind speed. The 5th column of the dataframe, spring, is the 5*sigma value of every hour. hourRow gives out all the rows of wind speed at a given hour. for (i in 0:23){ hourRow = which(windHW$hour==i,arr.ind=TRUE) for (h in

Re: [R] Finding values in a dataframe at a specified hour

2015-04-10 Thread Jim Lemon
Hi Alexandra, The error probably comes from the first iteration of i in 0:23. As indexing in R begins at 1, there is no element 0. Try using: for(i in 1:24) { ... and see what happens. Jim On Sat, Apr 11, 2015 at 7:06 AM, Alexandra Catena amc5...@gmail.com wrote: Update: I have this so

Re: [R] Finding values in a dataframe at a specified hour

2015-04-10 Thread Alexandra Catena
Hi Jim, Thanks for the response, but unfortunately it results in the same error. I think it is something wrong with the if statement. I tried it out manually for the first row and hour that it's testing and indeed, the wind speed is not higher than the 5*sigma value. Since it is not higher

Re: [R] Finding values in a dataframe at a specified hour

2015-04-10 Thread Jim Lemon
Hi Alexandra, I answered too quickly. Your response made me look for a deeper error: The value of i doesn't matter, as it isn't being used as an index. However, the first value of i=0 may cause the error in the second loop, where h is used as an index. for (i in 0:23){ hourRow =