Improving performance of date-time comparison in R - r

Background:
For my thesis i have several hundred large CSV files. These files contain time series with 23800 forecast half-hourly periods between the 01.11.2016 and 01.03.2018 of weather parameters.
Further, each period has 20 or 21 runtimes (number is not fixed, which is basically the problem in my case). The runtimes mark the time for a certain forecast period when the forecast is calculated. Thus, a forecast is mostly calculated before the forecast time (which naturally makes sense) but, for whatever reason this is not always the case. For some periods (mostly but not always) between 09:00 am and 12:00am there is one runtime for each period which is calculated in the future. I don't want to have this "future" runtime (I can't make a sense of it why it is included)
Exemplary excerpt of the data:
+-----------------------+-----------------------+-------------+
| ForecastPeriod | Runtime | Value |
+-----------------------+-----------------------+-------------+
| … | … | … |
| 02.11.2016 11:30+0000 | 31.10.2016 00:00+0000 | 5.544368776 |
| 02.11.2016 11:30+0000 | 31.10.2016 12:00+0000 | 4.71684533 |
| 02.11.2016 11:30+0000 | 01.11.2016 00:00+0000 | 5.374274986 |
| 02.11.2016 11:30+0000 | 01.11.2016 12:00+0000 | 5.892114875 |
| 02.11.2016 11:30+0000 | 02.11.2016 00:00+0000 | 6.18387462 | <-i want this row
| 02.11.2016 11:30+0000 | 02.11.2016 12:00+0000 | 5.852306909 | <- don't make sense
| 02.11.2016 12:00+0000 | 23.10.2016 12:00+0000 | 14.81608444 |
| 02.11.2016 12:00+0000 | 24.10.2016 00:00+0000 | 3.637574565 |
| … | … | ... |
| 02.11.2016 12:00+0000 | 01.11.2016 12:00+0000 | 5.541325144 |
| 02.11.2016 12:00+0000 | 02.11.2016 00:00+0000 | 5.745831136 | <- i want this row
| 02.11.2016 12:00+0000 | 02.11.2016 12:00+0000 | 5.347949883 | <- don't make sense
| 02.11.2016 12:30+0000 | 24.10.2016 00:00+0000 | 3.80366064 |
| 02.11.2016 12:30+0000 | 24.10.2016 12:00+0000 | 5.533042696 |
| … | … | … |
| 02.11.2016 12:30+0000 | 01.11.2016 12:00+0000 | 5.429153394 |
| 02.11.2016 12:30+0000 | 02.11.2016 00:00+0000 | 5.580232543 |
| 02.11.2016 12:30+0000 | 02.11.2016 12:00+0000 | 5.266140403 | <- i want this row
| 02.11.2016 13:00+0000 | 24.10.2016 00:00+0000 | 3.969746715 | <- here is no "future" runtime
| 02.11.2016 13:00+0000 | 24.10.2016 12:00+0000 | 5.704328337 |
| … | … | … |
+-----------------------+-----------------------+-------------+
Now my working solution:
What i am doing now is, to loop through the large data frame and filter the data which meets my expectations. It works, but it is very slow on my laptop. (takes almost an hour to go through 500.000 rows), i have a plethora of csv files to go through...
I ask myself, if there are any possibilities to do it faster? I am also ok with additional R packages if they work faster. Besides i am thinking of uploading the data to a faster SQL Server; is processing such a date comparison task faster on SQL?
#Some preliminary transformations for the comparable posixct format:
LA_Date_EC$Forecast.Time<-as.POSIXlt(LA_Date_EC$Forecast.Time,format="%d.%m.%Y %H:%M+%S",tz="UTC")
LA_Date_EC$Runtime.Forecast<-as.POSIXlt(LA_Date_EC$Runtime.Forecast,format="%d.%m.%Y %H:%M+%S",tz="UTC")
test.df2<-data.frame()
names(test.df2)<-names(LA_Date_EC) ##info: Datetimes
for (l in 2:469501){
if(LA_Date_EC[l,1]!=LA_Date_EC[l+1,1]){
#print(l)
if(LA_Date_EC[l,2]>=LA_Date_EC[l,1]){
test.df2<-rbind.data.frame(test.df2,LA_Date_EC[l-1,])
}else{
test.df2<-rbind.data.frame(test.df2,LA_Date_EC[l,])
}
}
}
EDIT: sample excerpt as an dput output in R:
structure(list(Forecast.Time = structure(list(sec = c(0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), min = c(30L, 30L, 30L,
30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L,
30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L,
30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 30L, 30L, 30L, 30L), hour = c(10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 11L, 11L, 11L, 11L, 11L,
11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L,
11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L,
11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 12L, 12L,
12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L,
12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L,
12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L,
13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L,
13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L), mday = c(2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L), mon = c(10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L
), year = c(116L, 116L, 116L, 116L, 116L, 116L, 116L, 116L, 116L,
116L, 116L, 116L, 116L, 116L, 116L, 116L, 116L, 116L, 116L, 116L,
116L, 116L, 116L, 116L, 116L, 116L, 116L, 116L, 116L, 116L, 116L,
116L, 116L, 116L, 116L, 116L, 116L, 116L, 116L, 116L, 116L, 116L,
116L, 116L, 116L, 116L, 116L, 116L, 116L, 116L, 116L, 116L, 116L,
116L, 116L, 116L, 116L, 116L, 116L, 116L, 116L, 116L, 116L, 116L,
116L, 116L, 116L, 116L, 116L, 116L, 116L, 116L, 116L, 116L, 116L,
116L, 116L, 116L, 116L, 116L, 116L, 116L, 116L, 116L, 116L, 116L,
116L, 116L, 116L, 116L, 116L, 116L, 116L, 116L, 116L, 116L, 116L,
116L, 116L, 116L, 116L, 116L, 116L, 116L, 116L, 116L, 116L, 116L,
116L, 116L, 116L, 116L, 116L, 116L, 116L, 116L, 116L, 116L, 116L,
116L, 116L), wday = c(3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L),
yday = c(306L, 306L, 306L, 306L, 306L, 306L, 306L, 306L,
306L, 306L, 306L, 306L, 306L, 306L, 306L, 306L, 306L, 306L,
306L, 306L, 306L, 306L, 306L, 306L, 306L, 306L, 306L, 306L,
306L, 306L, 306L, 306L, 306L, 306L, 306L, 306L, 306L, 306L,
306L, 306L, 306L, 306L, 306L, 306L, 306L, 306L, 306L, 306L,
306L, 306L, 306L, 306L, 306L, 306L, 306L, 306L, 306L, 306L,
306L, 306L, 306L, 306L, 306L, 306L, 306L, 306L, 306L, 306L,
306L, 306L, 306L, 306L, 306L, 306L, 306L, 306L, 306L, 306L,
306L, 306L, 306L, 306L, 306L, 306L, 306L, 306L, 306L, 306L,
306L, 306L, 306L, 306L, 306L, 306L, 306L, 306L, 306L, 306L,
306L, 306L, 306L, 306L, 306L, 306L, 306L, 306L, 306L, 306L,
306L, 306L, 306L, 306L, 306L, 306L, 306L, 306L, 306L, 306L,
306L, 306L, 306L), isdst = c(0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L)), .Names = c("sec", "min",
"hour", "mday", "mon", "year", "wday", "yday", "isdst"), class = c("POSIXlt",
"POSIXt"), tzone = "UTC"), Runtime.Forecast = structure(list(
sec = c(0, 0, 0, 0, 0, 0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, 12L, 0L, 12L, 0L, 12L, 0L, 12L,
0L, 12L, 12L, 0L, 12L, 0L, 12L, 0L, 12L, 0L, 12L, 0L, 12L,
0L, 12L, 0L, 12L, 0L, 12L, 0L, 12L, 0L, 12L, 0L, 12L, 0L,
12L, 0L, 12L, 0L, 12L, 0L, 12L, 0L, 12L, 0L, 12L, 0L, 12L,
0L, 12L, 0L, 12L, 0L, 12L, 0L, 12L, 0L, 12L, 0L, 12L, 0L,
12L, 0L, 12L, 0L, 12L, 0L, 12L, 0L, 12L, 0L, 12L, 0L, 12L,
0L, 12L), mday = c(27L, 27L, 28L, 28L, 29L, 29L, 30L, 30L,
31L, 31L, 1L, 1L, 2L, 2L, 23L, 24L, 24L, 25L, 25L, 26L, 26L,
27L, 27L, 28L, 28L, 29L, 29L, 30L, 30L, 31L, 31L, 1L, 1L,
2L, 2L, 23L, 24L, 24L, 25L, 25L, 26L, 26L, 27L, 27L, 28L,
28L, 29L, 29L, 30L, 30L, 31L, 31L, 1L, 1L, 2L, 2L, 23L, 24L,
24L, 25L, 25L, 26L, 26L, 27L, 27L, 28L, 28L, 29L, 29L, 30L,
30L, 31L, 31L, 1L, 1L, 2L, 2L, 24L, 24L, 25L, 25L, 26L, 26L,
27L, 27L, 28L, 28L, 29L, 29L, 30L, 30L, 31L, 31L, 1L, 1L,
2L, 2L, 24L, 24L, 25L, 25L, 26L, 26L, 27L, 27L, 28L, 28L,
29L, 29L, 30L, 30L, 31L, 31L, 1L, 1L, 2L, 2L, 24L, 24L, 25L,
25L), mon = c(9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 10L,
10L, 10L, 10L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L,
9L, 9L, 9L, 9L, 9L, 9L, 10L, 10L, 10L, 10L, 9L, 9L, 9L, 9L,
9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 10L,
10L, 10L, 10L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L,
9L, 9L, 9L, 9L, 9L, 9L, 10L, 10L, 10L, 10L, 9L, 9L, 9L, 9L,
9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 10L, 10L,
10L, 10L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L,
9L, 9L, 9L, 9L, 10L, 10L, 10L, 10L, 9L, 9L, 9L, 9L), year = c(116L,
116L, 116L, 116L, 116L, 116L, 116L, 116L, 116L, 116L, 116L,
116L, 116L, 116L, 116L, 116L, 116L, 116L, 116L, 116L, 116L,
116L, 116L, 116L, 116L, 116L, 116L, 116L, 116L, 116L, 116L,
116L, 116L, 116L, 116L, 116L, 116L, 116L, 116L, 116L, 116L,
116L, 116L, 116L, 116L, 116L, 116L, 116L, 116L, 116L, 116L,
116L, 116L, 116L, 116L, 116L, 116L, 116L, 116L, 116L, 116L,
116L, 116L, 116L, 116L, 116L, 116L, 116L, 116L, 116L, 116L,
116L, 116L, 116L, 116L, 116L, 116L, 116L, 116L, 116L, 116L,
116L, 116L, 116L, 116L, 116L, 116L, 116L, 116L, 116L, 116L,
116L, 116L, 116L, 116L, 116L, 116L, 116L, 116L, 116L, 116L,
116L, 116L, 116L, 116L, 116L, 116L, 116L, 116L, 116L, 116L,
116L, 116L, 116L, 116L, 116L, 116L, 116L, 116L, 116L, 116L
), wday = c(4L, 4L, 5L, 5L, 6L, 6L, 0L, 0L, 1L, 1L, 2L, 2L,
3L, 3L, 0L, 1L, 1L, 2L, 2L, 3L, 3L, 4L, 4L, 5L, 5L, 6L, 6L,
0L, 0L, 1L, 1L, 2L, 2L, 3L, 3L, 0L, 1L, 1L, 2L, 2L, 3L, 3L,
4L, 4L, 5L, 5L, 6L, 6L, 0L, 0L, 1L, 1L, 2L, 2L, 3L, 3L, 0L,
1L, 1L, 2L, 2L, 3L, 3L, 4L, 4L, 5L, 5L, 6L, 6L, 0L, 0L, 1L,
1L, 2L, 2L, 3L, 3L, 1L, 1L, 2L, 2L, 3L, 3L, 4L, 4L, 5L, 5L,
6L, 6L, 0L, 0L, 1L, 1L, 2L, 2L, 3L, 3L, 1L, 1L, 2L, 2L, 3L,
3L, 4L, 4L, 5L, 5L, 6L, 6L, 0L, 0L, 1L, 1L, 2L, 2L, 3L, 3L,
1L, 1L, 2L, 2L), yday = c(300L, 300L, 301L, 301L, 302L, 302L,
303L, 303L, 304L, 304L, 305L, 305L, 306L, 306L, 296L, 297L,
297L, 298L, 298L, 299L, 299L, 300L, 300L, 301L, 301L, 302L,
302L, 303L, 303L, 304L, 304L, 305L, 305L, 306L, 306L, 296L,
297L, 297L, 298L, 298L, 299L, 299L, 300L, 300L, 301L, 301L,
302L, 302L, 303L, 303L, 304L, 304L, 305L, 305L, 306L, 306L,
296L, 297L, 297L, 298L, 298L, 299L, 299L, 300L, 300L, 301L,
301L, 302L, 302L, 303L, 303L, 304L, 304L, 305L, 305L, 306L,
306L, 297L, 297L, 298L, 298L, 299L, 299L, 300L, 300L, 301L,
301L, 302L, 302L, 303L, 303L, 304L, 304L, 305L, 305L, 306L,
306L, 297L, 297L, 298L, 298L, 299L, 299L, 300L, 300L, 301L,
301L, 302L, 302L, 303L, 303L, 304L, 304L, 305L, 305L, 306L,
306L, 297L, 297L, 298L, 298L), isdst = c(0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L)), .Names = c("sec",
"min", "hour", "mday", "mon", "year", "wday", "yday", "isdst"
), class = c("POSIXlt", "POSIXt"), tzone = "UTC"), Wind.Speed = c(12.0889469204481,
8.1534483762018, 11.229031832199, 9.51623004872928, 7.99700924410322,
8.06420698869646, 7.46190421726437, 7.95691440205356, 8.19089703425263,
7.50023772800533, 7.46471349405832, 7.87503218264228, 8.10704533381368,
8.25997087655172, 12.9641999142878, 5.95739166070848, 8.48709144265445,
12.3686489749888, 3.27377438788927, 3.8132283355639, 5.40513611081943,
12.3699466614361, 7.91484229489558, 11.0188269744693, 9.56301437212706,
7.91921747636113, 7.86903553214633, 7.4208161449472, 7.7049451673898,
8.02618971449148, 7.32764074016071, 7.26610021373866, 7.70408467708526,
7.90262085370489, 8.1065215773556, 13.5223226992998, 6.23422083753905,
8.45254447734072, 12.3148462884236, 3.00095427388565, 4.11192170847009,
5.35120820775642, 12.6509464024241, 7.67623621358937, 10.8086221167397,
9.60979869552483, 7.84142570861904, 7.67386407559621, 7.37972807263003,
7.45297593272604, 7.86148239473033, 7.15504375231609, 7.06748693341901,
7.53313717152826, 7.69819637359609, 7.95307227815948, 14.0804454843119,
6.51105001436962, 8.41799751202699, 12.2610436018583, 2.72813415988203,
4.41061508137628, 5.2972803046934, 12.9319461434121, 7.43763013228316,
10.59841725901, 9.65658301892261, 7.76363394087695, 7.47869261904608,
7.33864000031286, 7.20100669806228, 7.69677507496918, 6.98244676447147,
6.86887365309936, 7.36218966597125, 7.4937718934873, 7.79962297896336,
6.47610742140243, 8.44809907428991, 12.1754295175459, 2.80289574128868,
4.43071887689015, 5.25901387681356, 12.8048270636345, 7.77257529660677,
10.6689406707837, 9.67371178278272, 7.71232463800448, 7.639287068313,
7.37678432847625, 7.39386920787284, 7.65056355621861, 7.0961073828294,
6.94340806177623, 7.41655132109855, 7.53010844435008, 7.89628470472931,
6.44116482843524, 8.47820063655284, 12.0898154332335, 2.87765732269532,
4.450822672404, 5.22074744893371, 12.6777079838569, 8.10752046093037,
10.7394640825575, 9.69084054664283, 7.66101533513201, 7.79988151757991,
7.41492865663964, 7.58673171768341, 7.60435203746804, 7.20976800118733,
7.01794247045311, 7.47091297622585, 7.56644499521287, 7.99294643049527,
6.40622223546805, 8.50830219881576, 12.0042013489211, 2.95241890410197
)), .Names = c("Forecast.Time", "Runtime.Forecast", "Wind.Speed"
), row.names = 1400:1520, class = "data.frame")

You could do this with dplyr or data.table. data.table should be the quicker solution for you.
dplyr
library(dplyr)
df$Forecast.Time <- as.POSIXct(df$Forecast.Time)
df$Runtime.Forecast <- as.POSIXct(df$Runtime.Forecast)
filtered <- df %>% filter(Forecast.Time > Runtime.Forecast) %>%
group_by(Forecast.Time) %>%
summarise_all(funs(last))
data.table
library(data.table)
df_dt <- as.data.table(df)
filtered_dt <- dat_dt[Forecast.Time > Runtime.Forecast, lapply(.SD, last), by = Forecast.Time]

Here is a potential solution using the dplyr package. With the lead/lag function and group_by the loop was eliminated.
As I mentioned in my comment above I converted the date/times to POSIXct objects.
library(dplyr)
#df is a copy of the orginal data
df<-LA_Date_EC
#find all future values and remove them from the data
future<-LA_Date_EC[,2]>=lag(LA_Date_EC[,1])
future[1]<-FALSE
df<-df[!future,]
#Group by the Forecast time and then find the last row
answer<-df %>% group_by(Forecast.Time) %>%
summarize(Runtime.Forecas= last(Runtime.Forecast), Wind.Speed = last(Wind.Speed))

Related

non-numeric argument to binary operator - log()

When I try to run log(x) on a variable in my dataset I get the error:
Error in oldat$gdp16 + 1 : non-numeric argument to binary operator
At first I thought that the reason is that these particular variables have NA's so I decided to deal with this problem like so:
oldat$gdp16[oldat$gdp16 == "#N/A"] <- "NA"
oldat$gdp16LOG <- log(oldat$gdp16 + 1, na.rm=TRUE)
This did not solve the problem.
Please find the excerpt of the data as an example below. The variable that fails the log transform is gdp16:
structure(list(gdp16 = c("19469", "159049", "554861", "10546",
"1208039", "390800", "37868", "11839", "32153", "47723", "467546",
"15649", "1793989", "53241", "32218", "1535768", "250036", "11190993",
"280091", "51339", "NA", "20154", "195305", "306900", "72343",
"98614", "332928", "5010", "23338", "73001", "4671", "238678",
"2465134", "14014", "14378", "3477796", "192691", "1056", "68664",
"320881", "125817", "20304", "2274230", "932256", "418977", "304819",
"317748", "1859384", "36375", "14057", "4949273", "137278", "70875",
"6715", "110912", "6813", "27572", "42773", "296536", "12232",
"1076912", "6796", "11183", "4374", "103606", "777228", "189286",
"404653", "7607", "1414804", "371075", "57821", "304889", "27424",
"471400", "205184", "105035", "152452", "187806", "1284728",
"644936", "38300", "309764", "89769", "44709", "295763", "1411042",
"1237255", "95584", "514460", "668745", "NA", "525608", "6952",
"411755", "4389", "22320", "42063", "863722", "24079", "93270",
"357045", "2650850", "18624475", "67068", "236", "205276", "16620"
), pop16 = c(34656L, 40606L, 43847L, 2925L, 24211L, 8737L, 9758L,
391L, 1425L, 9502L, 11331L, 2250L, 207653L, 7128L, 23439L, 36265L,
17910L, 1378665L, 48653L, 4174L, 11476L, 1170L, 10566L, 5728L,
10649L, 16385L, 95689L, 4955L, 1316L, 102403L, 899L, 5495L, 66860L,
1980L, 3719L, 82349L, 10776L, 107L, 16582L, 7337L, 9814L, 335L,
1324171L, 261115L, 80277L, 4755L, 8546L, 60627L, 23696L, 2881L,
126995L, 17794L, 48462L, 1816L, 4053L, 6080L, 1960L, 2868L, 31187L,
1263L, 127540L, 3552L, 3027L, 622L, 35277L, 17030L, 4693L, 185990L,
20673L, 51246L, 5235L, 4034L, 103320L, 6725L, 37970L, 10325L,
3407L, 2570L, 19702L, 144342L, 32276L, 7058L, 5607L, 5431L, 2065L,
56015L, 25369L, 46484L, 39579L, 9923L, 8373L, 18430L, 22465L,
8735L, 68864L, 7606L, 1365L, 11403L, 79512L, 41488L, 45005L,
9270L, 65596L, 323406L, 31848L, 31568L, 94569L, 16150L), gold16 = c(0L,
0L, 3L, 1L, 8L, 0L, 1L, 1L, 1L, 1L, 2L, 0L, 7L, 0L, 0L, 4L, 0L,
26L, 3L, 5L, 5L, 0L, 1L, 2L, 0L, 0L, 0L, 0L, 0L, 1L, 1L, 0L,
10L, 0L, 2L, 17L, 3L, 0L, 0L, 0L, 8L, 0L, 0L, 1L, 3L, 0L, 0L,
8L, 1L, 6L, 12L, 3L, 6L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 8L, 4L, 0L, 0L, 2L, 0L, 0L, 0L, 0L, 2L, 0L, 1L, 0L,
1L, 19L, 0L, 2L, 1L, 2L, 1L, 2L, 9L, 7L, 0L, 2L, 3L, 0L, 1L,
1L, 2L, 0L, 0L, 0L, 1L, 0L, 2L, 0L, 27L, 46L, 4L, 0L, 1L, 0L),
tot16 = c(0L, 2L, 4L, 4L, 29L, 1L, 18L, 2L, 2L, 9L, 6L, 0L,
19L, 3L, 0L, 22L, 0L, 70L, 8L, 10L, 11L, 0L, 10L, 15L, 1L,
0L, 3L, 0L, 1L, 8L, 1L, 1L, 42L, 0L, 7L, 42L, 6L, 1L, 0L,
0L, 15L, 0L, 2L, 3L, 8L, 2L, 2L, 28L, 2L, 11L, 41L, 18L,
13L, 1L, 0L, 0L, 0L, 4L, 5L, 0L, 5L, 0L, 2L, 0L, 1L, 19L,
18L, 1L, 1L, 7L, 4L, 0L, 1L, 0L, 11L, 1L, 1L, 1L, 4L, 55L,
0L, 8L, 1L, 4L, 4L, 10L, 21L, 17L, 0L, 11L, 7L, 0L, 3L, 1L,
6L, 0L, 1L, 3L, 8L, 0L, 11L, 1L, 67L, 121L, 13L, 3L, 2L,
0L), altitude = c(1790, 1, 10.5, 989, 605, 170, -28, 2, 6,
198, 76, 983, 1079, 580, 726, 74, 521, 44, 2625, 130, 4,
170, 244, 0, 0, 2850, 22, 2325, 37, 2355, 0, 25, 34, 0, 451,
34, 153, 25, 1529, 100, 102, 15, 210, 3, 1189, 8, 754, 14,
217, 53, 17, 338, 1795, 0, 5, 771, 8, 124, 60, 134, 2240,
80, 1350, 61, 53, -2, 10, 777, 207, 6, 12, 0, 7, 54, 93,
15, 3, 13, 70, 124, 624, 116, 0, 131, 281, 1271, 33, 667,
377, 15, 542, 691, 5, 789, 1, 63, 0, 0, 938, 1190, 168, 13,
14, 2, 459, 909, 25, 1483), athletes16 = c(3L, 64L, 215L,
31L, 420L, 72L, 56L, 29L, 33L, 120L, 104L, 12L, 462L, 50L,
24L, 310L, 42L, 392L, 143L, 85L, 117L, 15L, 104L, 119L, 26L,
37L, 121L, 12L, 46L, 37L, 53L, 54L, 393L, 6L, 40L, 418L,
92L, 7L, 21L, 37L, 154L, 8L, 112L, 28L, 63L, 76L, 47L, 309L,
12L, 56L, 336L, 101L, 79L, 8L, 0L, 19L, 32L, 67L, 32L, 2L,
123L, 23L, 43L, 35L, 48L, 237L, 195L, 71L, 6L, 31L, 62L,
10L, 13L, 11L, 234L, 90L, 40L, 37L, 95L, 285L, 10L, 103L,
25L, 52L, 63L, 135L, 135L, 307L, 6L, 151L, 103L, 7L, 57L,
7L, 54L, 5L, 28L, 61L, 100L, 21L, 204L, 12L, 360L, 555L,
70L, 86L, 22L, 30L)), class = "data.frame", row.names = c(NA,
-108L))
Your gdp16 variable is of class character. You cannot add a number to character. You need to convert your variable to the numeric type (and perhaps substitute NAs):
df$gdp16 <- as.numeric(df$gdp16)
You need to replace the "NA" with an actual NA, and do as.numeric:
oldat$gdp16LOG = log(as.numeric(replace(oldat$gdp16,oldat$gdp16=="NA",NA)))
You can just do as.numeric(oldat$gdp16) . It will return some error messages because any other string that is not numeric will be converted to NA..

TraMineR::seqecmpgroup variable lengths differ (found for 'group')

Consider the following data set:
SimulatedDated <- structure(list(CustumerId = c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 5L, 5L,
5L, 5L, 5L, 5L, 5L, 5L, 5L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 7L,
7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 8L, 8L, 8L, 8L, 8L, 8L, 8L,
8L, 8L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L,
11L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 13L, 13L,
13L, 13L, 13L, 13L, 13L, 13L, 13L, 14L, 14L, 14L, 14L, 14L, 14L,
14L, 14L, 14L, 14L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L,
15L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 17L, 17L, 17L,
17L, 17L, 17L, 17L, 17L, 17L, 18L, 18L, 18L, 18L, 18L, 18L, 18L,
18L, 18L, 18L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 20L, 20L,
20L, 20L, 20L, 20L, 20L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L,
22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 23L, 23L, 23L, 23L,
23L, 23L, 23L, 23L, 24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L,
25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L, 26L, 26L, 26L,
26L, 26L, 26L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 28L,
28L, 28L, 28L, 28L, 28L, 28L, 29L, 29L, 29L, 29L, 29L, 29L, 29L,
29L, 29L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 31L, 31L,
31L, 31L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2L, 4L, 8L, 7L, 1L, 4L, 2L, 10L,
10L, 3L, 8L, 1L, 7L, 5L, 4L, 6L, 2L, 10L, 6L, 1L, 2L, 5L, 4L,
8L, 1L, 10L, 8L, 3L, 2L, 9L, 5L, 6L, 4L, 9L, 10L, 6L, 2L, 1L,
7L, 4L, 8L, 5L, 1L, 5L, 9L, 10L, 3L, 8L, 7L, 2L, 4L, 10L, 1L,
5L, 7L, 6L, 2L, 3L, 4L, 9L, 8L, 1L, 5L, 2L, 7L, 3L, 6L, 10L,
4L, 9L, 9L, 5L, 10L, 8L, 2L), DaysSinceEpoch = c(7L, 20L, 31L,
40L, 105L, 146L, 162L, 169L, 212L, 10L, 18L, 31L, 65L, 84L, 122L,
156L, 202L, 206L, 1L, 4L, 7L, 11L, 14L, 24L, 25L, 100L, 148L,
149L, 3L, 10L, 12L, 14L, 18L, 26L, 35L, 41L, 96L, 147L, 9L, 22L,
66L, 80L, 102L, 104L, 170L, 199L, 234L, 10L, 24L, 36L, 38L, 75L,
122L, 163L, 169L, 9L, 16L, 35L, 39L, 54L, 58L, 79L, 116L, 133L,
224L, 27L, 35L, 37L, 49L, 73L, 91L, 105L, 141L, 252L, 16L, 28L,
51L, 73L, 76L, 83L, 126L, 202L, 97L, 105L, 150L, 172L, 203L,
207L, 223L, 256L, 259L, 25L, 28L, 38L, 40L, 63L, 100L, 120L,
176L, 186L, 191L, 7L, 22L, 36L, 37L, 40L, 41L, 53L, 67L, 114L,
233L, 1L, 16L, 17L, 23L, 40L, 52L, 125L, 184L, 186L, 12L, 42L,
53L, 65L, 67L, 69L, 83L, 149L, 154L, 265L, 10L, 14L, 33L, 47L,
67L, 106L, 133L, 181L, 247L, 258L, 6L, 21L, 26L, 41L, 49L, 68L,
89L, 112L, 119L, 9L, 34L, 88L, 91L, 102L, 110L, 132L, 171L, 200L,
6L, 14L, 21L, 36L, 40L, 60L, 64L, 88L, 109L, 208L, 8L, 17L, 21L,
55L, 77L, 85L, 97L, 168L, 18L, 28L, 42L, 44L, 70L, 77L, 101L,
14L, 23L, 33L, 84L, 107L, 123L, 124L, 125L, 25L, 29L, 33L, 57L,
79L, 83L, 98L, 112L, 119L, 5L, 31L, 64L, 91L, 102L, 131L, 222L,
234L, 27L, 46L, 48L, 60L, 61L, 64L, 72L, 103L, 161L, 8L, 24L,
27L, 50L, 60L, 62L, 92L, 99L, 147L, 159L, 16L, 19L, 20L, 84L,
175L, 202L, 17L, 21L, 25L, 46L, 69L, 121L, 161L, 175L, 267L,
10L, 14L, 20L, 39L, 58L, 90L, 229L, 32L, 35L, 39L, 40L, 60L,
66L, 98L, 153L, 173L, 2L, 3L, 25L, 46L, 51L, 80L, 96L, 166L,
202L, 43L, 70L, 76L, 77L, 115L, 160L, 183L, 202L, 223L, 25L,
33L, 61L, 72L, 74L, 77L, 85L, 91L, 152L, 265L, 16L, 62L, 63L,
64L, 66L, 82L, 104L, 126L, 181L, 47L, 49L, 55L, 58L, 67L), BoughtPAD = c(0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 1L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 1L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L,
1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L)), .Names = c("CustumerId",
"ProductId", "DaysSinceEpoch", "BoughtPAD"), row.names = c(NA,
300L), class = "data.frame")
Then, doing
library(TraMineR)
SimSeq <- seqecreate(id = SimulatedDated$CustumerId,
timestamp = SimulatedDated$DaysSinceEpoch,
event = SimulatedDated$ProductId)
Cohort <- factor(SimulatedDated$BoughtPAD, labels = c("PAD", "NPAD"))
Fsubseq <- seqefsub(seq = SimSeq, pMinSupport = .01)
DiscrCohort <- seqecmpgroup(subseq = Fsubseq, group = Cohort)
produces:
Error in model.frame.default(formula = ww ~ group + seqmatrix[, index]) :
variable lengths differ (found for 'group')
and I was wondering, what could be causing this problem?
The group variable should have length equal to the number of sequences, i.e., the number of customers in your case. Also it is supposed to remain constant all along the sequence (which is not the case in your example).
The Cohort variable that you use as group argument has for length the total number of events (300) while you have only 34 customers. So you need to aggregate it by the CustumerID.
Here is how you can do that (here by taking the max of the group value for each customer.)
bylist <- list(id = SimulatedDated$CustumerId)
agg.PAD <- aggregate(SimulatedDated[,c("CustumerId","BoughtPAD")], by=bylist, FUN="max")
Cohort <- agg.PAD$BoughtPAD
Now you can look for the subsequences that best discriminate the groups
DiscrCohort <- seqecmpgroup(subseq = Fsubseq, group = Cohort)
print(DiscrCohort[1:10])
Hope this helps.

Merge two legends (size and color) into one [duplicate]

This question already has answers here:
How to combine scales for colour and size into one legend?
(2 answers)
Closed 7 years ago.
What is the code to make the two legends into one: A circles legend with color?
I think, a single legend with circles colored according to "size" and "# total number of crimes" is the best way to show the legend.
Desired output:
1) There should be one legend: the circles, instead of black should be colored: 0 circle = "yellow" to 800 circle = "red".
My code:
library(maps)
library(ggmap)
Get map from Google Maps
lima <- get_map(location = "lima", zoom = 11, maptype = c("terrain"))
Plot
ggmap(lima) + geom_point(data = limanov2, aes(x = LONGITUD , y = LATITUD, color = TOTALES,
size = TOTALES)) +
scale_size_continuous(name = "Cantidad\ndelitos",range = c(2,12)) +
scale_color_gradient(name = "Cantidad\ndelitos", low = "yellow", high = "red") +
theme(legend.text= element_text(size=14)) +
ggtitle("TOTAL DELITOS - LIMA NOV 2012") +
theme(plot.title = element_text(size = 12, vjust=2, family="Verdana", face="italic"),
legend.position = 'left')
My data:
structure(list(DISTRITO = c("SAN JUAN DE LURIGANCHO", "CALLAO",
"LOS OLIVOS", "ATE", "LIMA", "SAN MARTIN DE PORRES", "SANTIAGO DE SURCO",
"CHORILLOS", "COMAS", "INDEPENDENCIA", "EL AGUSTINO", "LA VICTORIA",
"SAN JUAN DE MIRAFLORES", "VILLA EL SALVADOR", "SAN MIGUEL",
"CARABAYLLO", "MIRAFLORES", "SAN BORJA", "VENTANILLA", "SURQUILLO",
"BREÑA", "ANCON", "PTE. PIEDRA", "RIMAC", "BARRANCO", "LA MOLINA",
"SAN LUIS", "SANTA ANITA", "LURIGANCHO", "P. LIBRE", "MAGDALENA DEL MAR",
"LA PERLA", "CHACLACAYO", "PUENTE PIEDRA", "SAN ISIDRO", "JESUS MARIA",
"BELLAVISTA", "LINCE", "CARMEN DE LA LEGUA REYNOSO", "CIENEGUILLA",
"SANTA ROSA", "LURIN", "PUNTA NEGRA", "PUCUSANA", "LA PUNTA",
"PUNTA HERMOSA", "PACHACAMAC", "SAN BARTOLO", "SANTA MARIA"),
TOTALES = c(861L, 696L, 696L, 642L, 516L, 479L, 442L, 378L,
371L, 368L, 361L, 333L, 325L, 291L, 282L, 251L, 239L, 196L,
193L, 188L, 185L, 174L, 165L, 161L, 138L, 134L, 128L, 119L,
115L, 105L, 67L, 65L, 63L, 58L, 58L, 56L, 45L, 38L, 23L,
23L, 11L, 8L, 6L, 5L, 3L, 3L, 2L, 0L, 0L), HOMICIDIOS = c(1L,
7L, 0L, 1L, 2L, 0L, 0L, 1L, 7L, 4L, 4L, 4L, 0L, 0L, 0L, 2L,
0L, 0L, 7L, 0L, 0L, 0L, 0L, 4L, 0L, 0L, 2L, 0L, 0L, 0L, 0L,
0L, 0L, 1L, 0L, 0L, 0L, 1L, 1L, 0L, 0L, 1L, 0L, 0L, 0L, 0L,
0L, 0L, 0L), LESIONES = c(100L, 72L, 61L, 43L, 44L, 8L, 10L,
15L, 44L, 40L, 50L, 15L, 52L, 28L, 7L, 33L, 15L, 3L, 21L,
7L, 36L, 33L, 15L, 19L, 14L, 1L, 8L, 6L, 16L, 4L, 4L, 9L,
1L, 12L, 2L, 9L, 5L, 2L, 5L, 7L, 1L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L), VIO..DE.LA.LIBERTAD.PERSONAL = c(0L, 7L, 6L,
5L, 6L, 1L, 1L, 0L, 3L, 1L, 2L, 0L, 2L, 0L, 1L, 0L, 1L, 0L,
1L, 1L, 0L, 3L, 1L, 1L, 1L, 0L, 0L, 0L, 0L, 1L, 0L, 1L, 0L,
0L, 1L, 0L, 0L, 0L, 2L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L), VIO..DE.LA.LIBERTAD.SEXUAL = c(56L, 14L, 12L, 15L, 7L,
10L, 2L, 9L, 11L, 13L, 8L, 9L, 7L, 14L, 4L, 15L, 4L, 2L,
17L, 7L, 3L, 4L, 6L, 12L, 2L, 1L, 5L, 3L, 11L, 4L, 1L, 2L,
0L, 6L, 2L, 0L, 3L, 0L, 2L, 2L, 0L, 4L, 0L, 0L, 0L, 0L, 0L,
0L, 0L), HURTO.SIMPLE.Y.AGRAVADO = c(217L, 203L, 296L, 230L,
260L, 167L, 226L, 217L, 130L, 117L, 154L, 133L, 121L, 46L,
163L, 72L, 161L, 119L, 69L, 120L, 64L, 19L, 64L, 21L, 57L,
44L, 39L, 2L, 48L, 60L, 30L, 19L, 48L, 20L, 41L, 25L, 19L,
27L, 7L, 11L, 9L, 0L, 6L, 0L, 2L, 3L, 1L, 0L, 0L), ROBO.SIMPLE.Y.AGRAVADO = c(460L,
289L, 308L, 344L, 186L, 277L, 198L, 130L, 165L, 184L, 137L,
149L, 134L, 188L, 104L, 126L, 58L, 72L, 64L, 51L, 77L, 115L,
79L, 76L, 64L, 88L, 73L, 108L, 40L, 36L, 30L, 32L, 14L, 17L,
12L, 22L, 12L, 8L, 6L, 3L, 1L, 3L, 0L, 2L, 1L, 0L, 1L, 0L,
0L), MICRO.COM.DE.DROGAS = c(26L, 100L, 13L, 3L, 10L, 15L,
5L, 5L, 11L, 8L, 3L, 23L, 9L, 15L, 3L, 3L, 0L, 0L, 8L, 2L,
5L, 0L, 0L, 28L, 0L, 0L, 1L, 0L, 0L, 0L, 2L, 2L, 0L, 2L,
0L, 0L, 6L, 0L, 0L, 0L, 0L, 0L, 0L, 3L, 0L, 0L, 0L, 0L, 0L
), TENENCIA.ILEGAL.DE.ARMAS = c(1L, 4L, 0L, 1L, 1L, 1L, 0L,
1L, 0L, 1L, 3L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 6L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L), LONGITUD = c(-77,
-77.12, -77.08, -76.89, -77.04, -77.09, -76.99, -77.01, -77.05,
-77.05, -77, -77.02, -76.97, -76.94, -77.09, -76.99, -77.03,
-77, -77.13, -77.01, -77.05, -77.11, -77.08, -76.7, -77.02,
-76.92, -77, -76.96, -76.86, -77.06, -77.07, -77.12, -76.76,
-77.08, -77.03, -77.05, -77.11, -77.04, -77.09, -76.78, -77.16,
-76.81, -76.73, -76.77, -77.16, -76.76, -76.83, -76.73, -76.77
), LATITUD = c(-11.99, -12.04, -11.95, -12.04, -12.06, -12,
-12.16, -12.2, -11.93, -11.99, -12.04, -12.08, -12.16, -12.23,
-12.08, -11.79, -12.12, -12.1, -11.89, -12.11, -12.06, -11.69,
-11.88, -11.94, -12.15, -12.09, -12.08, -12.04, -11.98, -12.08,
-12.09, -12.07, -11.99, -11.88, -12.1, -12.08, -12.06, -12.09,
-12.04, -12.07, -11.81, -12.24, -12.32, -12.47, -12.07, -12.28,
-12.18, -12.38, -12.42)), class = c("tbl_df", "tbl", "data.frame"
), row.names = c(NA, -49L), .Names = c("DISTRITO", "TOTALES",
"HOMICIDIOS", "LESIONES", "VIO..DE.LA.LIBERTAD.PERSONAL", "VIO..DE.LA.LIBERTAD.SEXUAL",
"HURTO.SIMPLE.Y.AGRAVADO", "ROBO.SIMPLE.Y.AGRAVADO", "MICRO.COM.DE.DROGAS",
"TENENCIA.ILEGAL.DE.ARMAS", "LONGITUD", "LATITUD"))
I've found a solution. Reading the documention for GGPLOT2 V. 0.9
It is the new function: guide_legend() that should be used inside guides().
This is a function that lets you have more control over legend labels.
This is the end code with the resulting output (See the last line):
ggmap(lima) + geom_point(data = limanov2, aes(x = LONGITUD , y = LATITUD, color = TOTALES,
size = TOTALES)) +
scale_size_continuous(name = "Cantidad\ndelitos",range = c(2,12)) +
scale_color_gradient(name = "Cantidad\ndelitos", low = "yellow", high = "red") +
theme(legend.text= element_text(size=14)) +
ggtitle("TOTAL DELITOS - LIMA NOV 2012") +
theme(plot.title = element_text(size = 12, vjust=2, family="Verdana", face="italic"),
legend.position = 'left') +
guides(colour = guide_legend())

R: ggmap: containing missing values (geom_point) when plottinng but no NAs values found in data.frame

I'm plotting some points over a map with ggmap package.
The problem is that i get the message: "Removed 12 rows containing missing values (geom_point)".
But i don't have any NAs. I've looked the data, and used:
sum(is.na(limanov2)) #Gives 0
to prove it.
This is my code:
library(maps)
library(ggmap)
lima <- get_map(location = "lima", zoom = 11)
ggmap(lima) + geom_point(data = limanov2, aes(x = LONGITUD , y = LATITUD, color = TOTALES,
size = TOTALES)) +
scale_color_gradient(low = "yellow", high = "red")
My data:
structure(list(DISTRITO = c("SAN JUAN DE LURIGANCHO", "CALLAO",
"LOS OLIVOS", "ATE VITARTE", "LIMA CERCADO", "SAN MARTÍN", "SANTIAGO DE SURCO",
"CHORILLOS", "COMAS", "INDEPENDENCIA", "EL AGUSTINO", "LA VICTORIA",
"SAN JUAN DE MIRAFLORES", "VILLA EL SALVADOR", "S. MIGUEL", "CARABAYLLO",
"MIRAFLORES", "PTE. PIEDRA", "SAN BORJA", "VENTANILLA", "SURQUILLO",
"BREÑA", "ANCÓN", "EL RIMAC", "BARRANCO", "LA MOLINA", "SAN LUIS",
"STA. ANITA", "LURIGANCHO", "P. LIBRE", "MAGDALENA", "LA PERLA",
"CHACLACAYO", "SAN ISIDRO", "J. MARÍA", "BELLAVISTA", "LINCE",
"C. DE LA LEGUA", "CIENEGUILLA", "STA.ROSA", "LURÍN", "PTA.NEGRA",
"PUCUSANA", "LA PUNTA", "PTA. HERMOSA", "PACHACAMAC", "SAN BARTOLO",
"SANTA MARÍA"), TOTALES = c(861L, 696L, 696L, 642L, 516L, 479L,
442L, 378L, 371L, 368L, 361L, 333L, 325L, 291L, 282L, 251L, 239L,
223L, 196L, 193L, 188L, 185L, 174L, 161L, 138L, 134L, 128L, 119L,
115L, 105L, 67L, 65L, 63L, 58L, 56L, 45L, 38L, 23L, 23L, 11L,
8L, 6L, 5L, 3L, 3L, 2L, 0L, 0L), HOMICIDIOS = c(1L, 7L, 0L, 1L,
2L, 0L, 0L, 1L, 7L, 4L, 4L, 4L, 0L, 0L, 0L, 2L, 0L, 1L, 0L, 7L,
0L, 0L, 0L, 4L, 0L, 0L, 2L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
1L, 1L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L), LESIONES = c(100L,
72L, 61L, 43L, 44L, 8L, 10L, 15L, 44L, 40L, 50L, 15L, 52L, 28L,
7L, 33L, 15L, 27L, 3L, 21L, 7L, 36L, 33L, 19L, 14L, 1L, 8L, 6L,
16L, 4L, 4L, 9L, 1L, 2L, 9L, 5L, 2L, 5L, 7L, 1L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L), VIO..DE.LA.LIBERTAD.PERSONAL = c(0L, 7L,
6L, 5L, 6L, 1L, 1L, 0L, 3L, 1L, 2L, 0L, 2L, 0L, 1L, 0L, 1L, 1L,
0L, 1L, 1L, 0L, 3L, 1L, 1L, 0L, 0L, 0L, 0L, 1L, 0L, 1L, 0L, 1L,
0L, 0L, 0L, 2L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L), VIO..DE.LA.LIBERTAD.SEXUAL = c(56L,
14L, 12L, 15L, 7L, 10L, 2L, 9L, 11L, 13L, 8L, 9L, 7L, 14L, 4L,
15L, 4L, 12L, 2L, 17L, 7L, 3L, 4L, 12L, 2L, 1L, 5L, 3L, 11L,
4L, 1L, 2L, 0L, 2L, 0L, 3L, 0L, 2L, 2L, 0L, 4L, 0L, 0L, 0L, 0L,
0L, 0L, 0L), HURTO.SIMPLE.Y.AGRAVADO = c(217L, 203L, 296L, 230L,
260L, 167L, 226L, 217L, 130L, 117L, 154L, 133L, 121L, 46L, 163L,
72L, 161L, 84L, 119L, 69L, 120L, 64L, 19L, 21L, 57L, 44L, 39L,
2L, 48L, 60L, 30L, 19L, 48L, 41L, 25L, 19L, 27L, 7L, 11L, 9L,
0L, 6L, 0L, 2L, 3L, 1L, 0L, 0L), ROBO.SIMPLE.Y.AGRAVADO = c(460L,
289L, 308L, 344L, 186L, 277L, 198L, 130L, 165L, 184L, 137L, 149L,
134L, 188L, 104L, 126L, 58L, 96L, 72L, 64L, 51L, 77L, 115L, 76L,
64L, 88L, 73L, 108L, 40L, 36L, 30L, 32L, 14L, 12L, 22L, 12L,
8L, 6L, 3L, 1L, 3L, 0L, 2L, 1L, 0L, 1L, 0L, 0L), MICRO.COM.DE.DROGAS = c(26L,
100L, 13L, 3L, 10L, 15L, 5L, 5L, 11L, 8L, 3L, 23L, 9L, 15L, 3L,
3L, 0L, 2L, 0L, 8L, 2L, 5L, 0L, 28L, 0L, 0L, 1L, 0L, 0L, 0L,
2L, 2L, 0L, 0L, 0L, 6L, 0L, 0L, 0L, 0L, 0L, 0L, 3L, 0L, 0L, 0L,
0L, 0L), TENENCIA.ILEGAL.DE.ARMAS = c(1L, 4L, 0L, 1L, 1L, 1L,
0L, 1L, 0L, 1L, 3L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 6L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L), LONGITUD = c(-77, -77.12,
-77.08, -76.89, -77.04, -77.09, -76.99, -77.01, -77.05, -77.05,
-77, -77.02, -76.97, -76.94, -77.09, -76.99, -77.03, -77.08,
-77, -77.13, -77.01, -77.05, -77.11, -76.7, -77.02, -76.92, -77,
-76.96, -76.86, -77.06, -77.07, -77.12, -76.76, -77.03, -77.05,
-77.11, -77.04, -77.09, -76.78, -77.16, -76.81, -76.73, -76.77,
-77.16, -76.76, -76.83, -76.73, -76.77), LATITUD = c(-11.99,
-12.04, -11.97, -12.04, -12.06, -12, -12.16, -12.2, -11.93, -11.99,
-12.04, -12.08, -12.16, -12.23, -12.08, -11.79, -12.12, -11.88,
-12.1, -11.89, -12.11, -12.06, -11.69, -11.94, -12.15, -12.09,
-12.08, -12.04, -11.98, -12.08, -12.09, -12.07, -11.99, -12.1,
-12.08, -12.06, -12.09, -12.04, -12.07, -11.81, -12.24, -12.32,
-12.47, -12.07, -12.28, -12.18, -12.38, -12.42)), class = c("tbl_df",
"tbl", "data.frame"), row.names = c(NA, -48L), .Names = c("DISTRITO",
"TOTALES", "HOMICIDIOS", "LESIONES", "VIO..DE.LA.LIBERTAD.PERSONAL",
"VIO..DE.LA.LIBERTAD.SEXUAL", "HURTO.SIMPLE.Y.AGRAVADO", "ROBO.SIMPLE.Y.AGRAVADO",
"MICRO.COM.DE.DROGAS", "TENENCIA.ILEGAL.DE.ARMAS", "LONGITUD",
"LATITUD"))
You have values outside of the base map zoom range... try changing your zoom parameter.
library(maps)
library(ggmap)
lima <- get_map(location = "lima", zoom = 10)
ggmap(lima) +
geom_point(data = limanov2,
aes(x = LONGITUD , y = LATITUD,
color = TOTALES, size = TOTALES)) +
scale_color_gradient(low = "yellow", high = "red")

Is `format` more secure than `$` when extracting hours from a POSIXlt vector?

Starting R with a bare-bone
l#np350v5c:~$ R --vanilla
> search()
[1] ".GlobalEnv" "package:stats" "package:graphics"
[4] "package:grDevices" "package:utils" "package:datasets"
[7] "package:methods" "Autoloads" "package:base"
.. this is a dump of data (emergency accesses hours in a northern Italy hospital) which gave a strange (to me) behaviour:
times <- structure(list(sec = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0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 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0), min = c(5L, 43L, 2L, 47L, 15L, 18L, 46L, 50L, 58L,
26L, 14L, 54L, 28L, 11L, 32L, 17L, 51L, 40L, 17L, 47L, 21L, 57L,
59L, 34L, 45L, 15L, 10L, 25L, 27L, 31L, 5L, 34L, 5L, 36L, 16L,
2L, 20L, 0L, 24L, 1L, 54L, 59L, 28L, 24L, 24L, 19L, 26L, 1L,
48L, 0L, 10L, 18L, 43L, 38L, 24L, 21L, 37L, 36L, 54L, 11L, 27L,
29L, 34L, 32L, 33L, 43L, 40L, 53L, 56L, 48L, 47L, 54L, 11L, 37L,
14L, 46L, 30L, 54L, 0L, 38L, 27L, 57L, 21L, 31L, 21L, 37L, 17L,
41L, 21L, 14L, 33L, 33L, 31L, 6L, 30L, 48L, 49L, 26L, 9L, 0L,
19L, 45L, 5L, 9L, 29L, 15L, 34L, 48L, 20L, 25L, 1L, 49L, 48L,
46L, 47L, 18L, 48L, 35L, 56L, 24L, 41L, 13L, 37L, 53L, 57L, 11L,
9L, 43L, 30L, 11L, 55L, 56L, 12L, 35L, 14L, 48L, 22L, 44L, 25L,
51L, 51L, 27L, 58L, 23L, 17L, 42L, 21L, 54L, 59L, 40L, 37L, 43L,
15L, 12L, 22L, 15L, 55L, 7L, 21L, 59L, 34L, 38L, 15L, 8L, 57L,
49L, 6L, 1L, 51L, 46L, 49L, 20L, 46L, 56L, 32L, 36L, 56L, 47L,
58L, 23L, 14L, 56L, 4L, 44L, 25L, 44L, 22L, 21L, 36L, 35L, 58L,
27L, 22L, 44L, 16L, 5L, 34L, 46L, 52L, 18L, 0L, 32L, 49L, 3L,
16L, 53L, 57L, 58L, 35L, 21L, 32L, 57L, 7L, 20L, 29L, 26L, 48L,
53L, 9L, 59L, 58L, 30L, 57L, 34L, 6L, 29L, 57L, 10L, 25L, 15L,
26L, 29L, 20L, 24L, 36L, 54L, 46L, 24L, 14L, 10L, 48L, 22L, 17L,
39L, 59L, 33L, 12L, 0L, 29L, 36L, 31L, 57L, 38L, 10L, 29L, 42L,
36L, 16L, 2L, 21L, 35L, 4L, 16L, 33L, 35L, 14L, 37L, 25L, 51L,
12L, 45L, 15L, 7L, 33L, 42L, 28L, 19L, 40L, 5L, 39L, 13L, 23L,
47L, 31L, 7L, 12L, 8L, 7L, 24L, 37L, 51L, 49L, 11L, 0L, 23L,
30L, 37L, 48L, 26L, 42L, 33L, 8L, 17L, 4L, 51L, 26L, 48L, 17L,
43L, 35L, 35L, 27L, 27L, 47L, 17L, 24L, 43L, 55L, 20L, 54L, 38L,
58L, 2L, 37L, 26L, 3L, 25L, 18L, 0L, 58L, 57L, 12L, 10L, 51L,
37L, 23L, 57L, 14L, 7L, 22L, 50L, 14L, 24L, 27L, 42L, 53L, 6L,
21L, 56L, 17L, 4L, 6L, 30L, 47L, 42L, 20L, 17L, 0L, 35L, 59L,
46L, 50L, 16L, 15L, 42L, 26L, 36L, 8L, 35L, 2L, 59L, 12L, 14L,
58L, 3L, 0L, 37L, 36L, 23L, 29L, 45L, 44L, 32L, 25L, 1L, 50L,
17L, 56L, 58L, 53L, 35L, 17L, 14L, 38L, 27L, 27L, 8L, 14L, 7L,
24L, 13L, 42L, 21L, 12L, 38L, 24L, 30L, 27L, 55L, 23L, 31L, 43L,
22L, 47L, 50L, 27L, 56L, 22L, 54L, 23L, 46L, 17L, 30L, 41L, 54L,
41L, 51L, 44L, 34L, 42L, 3L, 57L, 9L, 51L, 54L, 58L, 53L, 58L,
4L, 12L, 12L, 35L, 55L, 5L, 4L, 15L, 56L, 14L, 48L, 57L, 13L,
19L, 25L, 24L, 24L, 2L, 54L), hour = c(-3, -4, -3, -2, -4, -1,
-5, -4, -5, -5, -5, -4, -3, -2, -4, -2, -2, -4, -4, -1, -2, -5,
-5, -2, -2, -2, -5, -1, -1, -4, -3, -4, -4, -3, -4, -3, -1, -2,
-2, -1, -2, -5, -5, -3, -2, -2, -3, -3, -4, -1, -4, -3, -4, -2,
-5, -2, -4, -5, -4, -2, -5, -1, -5, -3, -2, -1, -3, -5, -1, -3,
-5, -1, -5, -1, -3, -1, -2, -5, -3, -1, -5, -1, -1, -3, -5, -1,
-2, -4, -4, -5, -3, -5, -4, -1, -5, -2, -5, -3, -5, -5, -2, -1,
-5, -3, -5, -3, -2, -4, -3, -1, -1, -2, -3, -1, -4, -3, -4, -5,
-1, -5, -3, -3, -1, -3, -3, -4, -4, -2, -5, -5, -1, -3, -5, -2,
-3, -2, -1, -5, -3, -5, -1, -1, -1, -3, -3, -5, -1, -2, -4, -2,
-4, -1, -4, -5, -1, -5, -1, -1, -4, -2, -5, -5, -3, -1, -5, -3,
-4, -5, -4, -5, -3, -5, -5, -5, -2, -5, -3, -5, -3, -4, -4, -5,
-5, -1, -4, -4, -1, -3, -1, -3, -3, -4, -2, -2, -4, -3, -1, -4,
-5, -3, -1, -3, -4, -3, -5, -1, -3, -5, -4, -5, -2, -4, -1, -3,
-5, -2, -5, -3, -4, -2, -5, -4, -1, -5, -3, -5, -1, -2, -2, -4,
-3, -4, -2, -4, -3, -4, -2, -5, -1, -1, -2, -1, -3, -5, -1, -1,
-2, -4, -4, -5, -3, -3, -3, -4, -4, -4, -4, -3, -4, -2, -5, -4,
-1, -4, -5, -4, -3, -3, -5, -2, -3, -1, -4, -1, -5, -2, -1, -1,
-4, -3, -2, -5, -4, -3, -4, -1, -3, -4, -5, -3, -2, -4, -1, -4,
-4, -2, -5, -3, -5, -1, -3, -4, -2, -1, -2, -3, -5, -3, -1, -1,
-3, -4, -4, -2, -2, -1, -2, -1, -4, -2, -5, -2, -1, -3, -5, -1,
-5, -3, -3, -5, -2, -1, -1, -4, -5, -5, -4, -1, -3, -5, -2, -4,
-1, -2, -4, -5, -5, -1, -5, -5, -4, -2, -5, -2, -3, -2, -2, -2,
-3, -2, -4, -4, -5, -1, -2, -5, -3, -1, -1, -4, -1, -5, -3, -5,
-4, -2, -4, -3, -4, -4, -3, -2, -2, -5, -2, -1, -1, -1, -3, -5,
-4, -5, -1, -1, -3, -2, -4, -2, -2, -1, -2, -4, -3, -5, -2, -1,
-4, -4, -1, -4, -2, -3, -2, -1, -5, -5, -4, -2, -1, -5, -3, -3,
-4, -5, -3, -4, -1, -3, -2, -2, -2, -4, -1, -2, -2, -2, -5, -1,
-4, -2, -4, -2, -5, -4, -2, -3, -2, -1, -1, -1, -3, -2, -5, -3,
-5, -2, -1), mday = c(24L, 30L, 13L, 17L, 11L, 17L, 1L, 26L,
21L, 1L, 9L, 6L, 7L, 17L, 17L, 4L, 24L, 23L, 31L, 2L, 22L, 19L,
12L, 17L, 26L, 13L, 12L, 26L, 14L, 20L, 22L, 14L, 26L, 29L, 7L,
16L, 19L, 10L, 19L, 17L, 15L, 22L, 4L, 22L, 6L, 22L, 6L, 24L,
18L, 11L, 13L, 26L, 5L, 2L, 1L, 12L, 15L, 21L, 22L, 24L, 25L,
18L, 4L, 18L, 28L, 4L, 21L, 25L, 18L, 4L, 8L, 10L, 21L, 11L,
11L, 20L, 23L, 14L, 16L, 2L, 31L, 3L, 21L, 3L, 1L, 13L, 26L,
20L, 17L, 4L, 3L, 13L, 10L, 23L, 16L, 1L, 28L, 27L, 16L, 29L,
6L, 15L, 6L, 14L, 4L, 17L, 15L, 4L, 19L, 26L, 20L, 22L, 24L,
1L, 16L, 18L, 12L, 21L, 26L, 11L, 30L, 19L, 26L, 4L, 3L, 2L,
26L, 30L, 14L, 16L, 21L, 20L, 29L, 26L, 17L, 23L, 8L, 19L, 23L,
14L, 14L, 5L, 28L, 6L, 15L, 13L, 8L, 6L, 1L, 2L, 3L, 5L, 16L,
17L, 3L, 23L, 20L, 27L, 28L, 1L, 31L, 26L, 14L, 30L, 22L, 9L,
31L, 5L, 19L, 9L, 27L, 26L, 24L, 12L, 27L, 20L, 9L, 4L, 9L, 4L,
18L, 9L, 13L, 10L, 23L, 27L, 11L, 21L, 6L, 6L, 6L, 9L, 23L, 14L,
27L, 23L, 17L, 19L, 29L, 16L, 18L, 4L, 5L, 29L, 14L, 16L, 19L,
25L, 14L, 16L, 27L, 12L, 11L, 26L, 2L, 17L, 1L, 20L, 2L, 3L,
5L, 7L, 27L, 27L, 17L, 6L, 4L, 11L, 5L, 15L, 13L, 19L, 1L, 29L,
18L, 29L, 17L, 23L, 31L, 26L, 19L, 17L, 14L, 21L, 17L, 13L, 5L,
13L, 4L, 27L, 13L, 18L, 4L, 24L, 23L, 21L, 25L, 25L, 2L, 24L,
25L, 28L, 6L, 10L, 15L, 9L, 7L, 8L, 9L, 22L, 17L, 11L, 15L, 24L,
14L, 23L, 18L, 28L, 3L, 20L, 25L, 5L, 17L, 21L, 24L, 21L, 24L,
3L, 31L, 21L, 18L, 27L, 30L, 25L, 13L, 8L, 21L, 16L, 22L, 24L,
3L, 16L, 4L, 22L, 15L, 30L, 2L, 16L, 28L, 24L, 26L, 20L, 9L,
3L, 3L, 4L, 11L, 5L, 30L, 19L, 24L, 3L, 24L, 5L, 14L, 4L, 23L,
18L, 7L, 16L, 24L, 3L, 27L, 4L, 30L, 22L, 28L, 17L, 25L, 3L,
19L, 18L, 26L, 8L, 24L, 18L, 17L, 6L, 17L, 25L, 6L, 23L, 14L,
4L, 5L, 15L, 5L, 4L, 19L, 4L, 7L, 24L, 28L, 23L, 28L, 9L, 7L,
27L, 26L, 25L, 4L, 19L, 24L, 18L, 18L, 7L, 16L, 11L, 10L, 21L,
6L, 30L, 15L, 1L, 16L, 16L, 21L, 17L, 8L, 19L, 1L, 23L, 10L,
18L, 2L, 8L, 20L, 28L, 25L, 28L, 25L, 23L, 5L, 4L, 31L, 2L, 21L,
30L, 1L, 4L, 18L, 8L, 25L, 1L, 25L, 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L, 112L, 112L, 112L, 112L, 112L,
112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L,
112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L,
112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L,
112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L,
112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L,
112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L,
112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L,
112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L,
112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L,
112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L,
112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L,
112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L,
112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L,
112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L,
112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L,
112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L,
112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L,
112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L,
112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L,
112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L,
112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L,
112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L,
112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L,
112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L,
112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L,
112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L,
112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L,
112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L,
112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L,
112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L,
112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L,
112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L,
112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L,
112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L,
112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L,
112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L,
112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L,
112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L,
112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L,
112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L
), wday = c(6L, 3L, 1L, 5L, 5L, 6L, 6L, 2L, 4L, 5L, 4L, 3L, 3L,
3L, 5L, 3L, 5L, 4L, 2L, 6L, 3L, 1L, 4L, 4L, 6L, 5L, 3L, 1L, 5L,
5L, 0L, 2L, 2L, 0L, 5L, 0L, 6L, 0L, 1L, 1L, 0L, 2L, 6L, 3L, 4L,
0L, 2L, 1L, 3L, 6L, 0L, 4L, 5L, 1L, 2L, 1L, 0L, 0L, 5L, 5L, 2L,
6L, 3L, 3L, 1L, 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0L, 2L, 4L, 5L, 2L, 5L, 5L, 5L, 1L, 5L, 5L, 5L,
5L, 5L, 4L, 6L, 2L, 6L, 4L, 6L, 0L, 3L, 0L, 1L, 2L, 1L, 5L, 2L,
3L, 5L, 4L, 6L, 3L, 6L, 4L, 5L, 6L, 4L, 5L, 6L, 5L, 6L, 1L, 5L,
4L, 1L, 5L, 0L, 0L, 0L, 0L, 2L, 3L, 1L, 1L, 0L, 0L, 5L, 3L, 4L,
0L, 3L, 6L, 0L, 0L, 3L, 5L, 6L, 6L, 6L, 4L, 6L, 3L, 5L, 5L, 2L,
2L, 4L, 0L, 0L, 5L, 4L, 4L, 4L, 4L, 2L, 0L, 3L, 2L, 6L, 3L, 5L,
4L, 3L, 1L, 2L, 2L, 1L, 5L, 5L, 0L, 5L, 5L, 4L, 1L, 3L, 6L, 5L,
1L, 3L, 2L, 1L, 2L, 0L, 0L, 3L, 5L, 0L, 3L, 1L, 6L, 3L, 1L, 3L,
5L, 3L, 5L, 5L, 5L, 6L, 4L, 0L, 3L, 2L, 0L, 3L), yday = c(328L,
150L, 225L, 229L, 131L, 321L, 335L, 177L, 172L, 152L, 39L, 157L,
311L, 290L, 47L, 185L, 236L, 235L, 30L, 153L, 234L, 323L, 193L,
137L, 146L, 194L, 346L, 330L, 257L, 110L, 203L, 44L, 177L, 210L,
341L, 259L, 139L, 161L, 78L, 260L, 14L, 142L, 34L, 52L, 340L,
21L, 65L, 358L, 199L, 41L, 133L, 207L, 278L, 183L, 121L, 316L,
14L, 294L, 173L, 54L, 268L, 48L, 185L, 199L, 148L, 94L, 264L,
359L, 230L, 124L, 342L, 283L, 172L, 131L, 192L, 19L, 235L, 13L,
46L, 306L, 365L, 123L, 233L, 215L, 274L, 286L, 299L, 324L, 107L,
34L, 276L, 103L, 161L, 357L, 197L, 305L, 332L, 26L, 350L, 119L,
279L, 319L, 187L, 257L, 155L, 229L, 227L, 247L, 49L, 299L, 79L,
356L, 54L, 182L, 228L, 322L, 71L, 264L, 269L, 254L, 273L, 139L,
56L, 3L, 2L, 153L, 207L, 211L, 104L, 167L, 233L, 232L, 363L,
207L, 47L, 266L, 312L, 292L, 82L, 318L, 318L, 4L, 118L, 279L,
288L, 225L, 220L, 36L, 274L, 61L, 62L, 4L, 228L, 16L, 215L, 327L,
232L, 178L, 240L, 152L, 243L, 360L, 134L, 334L, 234L, 343L, 212L,
339L, 323L, 190L, 86L, 207L, 23L, 224L, 331L, 79L, 282L, 124L,
39L, 63L, 230L, 252L, 103L, 314L, 327L, 270L, 10L, 294L, 96L,
340L, 187L, 343L, 174L, 73L, 270L, 82L, 351L, 353L, 59L, 259L,
48L, 185L, 248L, 149L, 134L, 106L, 49L, 55L, 257L, 320L, 239L,
102L, 254L, 177L, 122L, 47L, 213L, 232L, 183L, 62L, 186L, 280L,
208L, 361L, 260L, 187L, 308L, 70L, 35L, 227L, 194L, 323L, 152L,
149L, 48L, 28L, 47L, 22L, 365L, 85L, 200L, 290L, 348L, 355L,
321L, 347L, 217L, 256L, 124L, 208L, 286L, 138L, 247L, 297L, 296L,
325L, 329L, 115L, 214L, 297L, 145L, 271L, 65L, 314L, 319L, 129L,
97L, 38L, 282L, 234L, 290L, 101L, 166L, 23L, 257L, 296L, 230L,
271L, 154L, 232L, 268L, 248L, 321L, 51L, 236L, 80L, 297L, 246L,
90L, 172L, 17L, 331L, 181L, 206L, 72L, 312L, 51L, 259L, 234L,
23L, 33L, 106L, 277L, 112L, 196L, 150L, 306L, 15L, 118L, 175L,
146L, 324L, 282L, 215L, 123L, 94L, 10L, 95L, 120L, 49L, 297L,
154L, 114L, 95L, 257L, 338L, 327L, 138L, 341L, 15L, 236L, 33L,
26L, 124L, 89L, 81L, 27L, 16L, 237L, 123L, 139L, 322L, 269L,
98L, 267L, 352L, 260L, 5L, 16L, 206L, 187L, 53L, 13L, 94L, 125L,
74L, 278L, 34L, 200L, 124L, 97L, 54L, 27L, 22L, 362L, 39L, 127L,
117L, 238L, 329L, 63L, 49L, 23L, 17L, 169L, 127L, 259L, 315L,
222L, 325L, 249L, 273L, 45L, 244L, 350L, 259L, 325L, 229L, 342L,
139L, 244L, 53L, 314L, 108L, 306L, 159L, 324L, 240L, 298L, 301L,
84L, 327L, 4L, 277L, 151L, 214L, 233L, 364L, 31L, 338L, 48L,
38L, 145L, 60L, 115L, 92L, 156L, 324L, 1L, 229L, 278L, 217L,
334L, 334L, 137L, 64L, 17L, 20L, 54L, 232L, 269L, 212L, 288L,
303L, 350L, 126L, 199L, 271L, 280L, 24L, 267L, 188L, 143L, 190L,
220L, 145L, 10L, 19L, 292L, 54L, 125L, 4L, 56L, 269L, 37L, 119L,
234L), isdst = c(0L, 1L, 1L, 1L, 1L, 0L, 0L, 1L, 1L, 1L, 0L,
1L, 0L, 1L, 0L, 1L, 1L, 1L, 0L, 1L, 1L, 0L, 1L, 1L, 1L, 1L, 0L,
0L, 1L, 1L, 1L, 0L, 1L, 1L, 0L, 1L, 1L, 1L, 0L, 1L, 0L, 1L, 0L,
0L, 0L, 0L, 0L, 0L, 1L, 0L, 1L, 1L, 1L, 1L, 1L, 0L, 0L, 1L, 1L,
0L, 1L, 0L, 1L, 1L, 1L, 1L, 1L, 0L, 1L, 1L, 0L, 1L, 1L, 1L, 1L,
0L, 1L, 0L, 0L, 0L, 0L, 1L, 1L, 1L, 1L, 1L, 1L, 0L, 1L, 0L, 1L,
1L, 1L, 0L, 1L, 0L, 0L, 0L, 0L, 1L, 1L, 0L, 1L, 1L, 1L, 1L, 1L,
1L, 0L, 1L, 0L, 0L, 0L, 1L, 1L, 0L, 0L, 1L, 1L, 1L, 1L, 1L, 0L,
0L, 0L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 0L, 1L, 0L, 1L, 0L, 1L, 0L,
0L, 0L, 0L, 1L, 1L, 1L, 1L, 1L, 0L, 1L, 0L, 0L, 0L, 1L, 0L, 1L,
0L, 1L, 1L, 1L, 1L, 1L, 0L, 1L, 0L, 1L, 0L, 1L, 0L, 0L, 1L, 1L,
1L, 0L,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 1L, 1L, 1L, 1L, 0L, 0L, 1L, 1L, 1L, 1L, 0L, 1L, 1L, 1L,
1L, 1L, 1L, 0L, 0L, 1L, 0L, 1L, 0L, 0L, 1L, 0L, 1L, 1L)), .Names = c("sec",
"min", "hour", "mday", "mon", "year", "wday", "yday", "isdst"
), class = c("POSIXlt", "POSIXt"))
Then, trying to extract hours in different ways
df <- data.frame(times,
with.dollar = times$hour,
with.format = as.numeric(format(times, "%H"))
)
head(df)
and my results are
times with.dollar with.format
1 2012-11-23 21:05:00 -3 21
2 2012-05-29 20:43:00 -4 20
3 2012-08-12 21:02:00 -3 21
4 2012-08-16 22:47:00 -2 22
5 2012-05-10 20:15:00 -4 20
6 2012-11-16 23:18:00 -1 23
Another test (not in a data.frame... simple vectors)
> any(times$hour == as.numeric(format(times, "%H")))
[1] FALSE
With times$hour it seems to be counting hours starting from the next days in some cases (all of the cases here reported).
Could you reproduce that? any idea why?
Looking at ?POSIXlt this could be a bug because not all hours are within 0:23 range.
If so, for the moment it would be safer to use format rather $ for POSIXlt vector
> R.version
_
platform x86_64-pc-linux-gnu
arch x86_64
os linux-gnu
system x86_64, linux-gnu
status
major 3
minor 0.3
year 2014
month 03
day 06
svn rev 65126
language R
version.string R version 3.0.3 (2014-03-06)
nickname Warm Puppy

Resources