lubridate

Could not find function “year” after installation from zip file R

萝らか妹 提交于 2019-12-12 03:21:35
问题 I'm using R and working on a server without internet connection. So I had to search how to install packages from a zip file. I wanted to use the lubridate package. install.packages("V:/R/lubridate_1.3.3.zip", repos=NULL) Then I tried to use library(lubridate) year(data$date) but I received an error that package or namespace load failed for "lubridate" . And the function year could not be found . Did I forgot any step? 回答1: If you install a package with install.packages from a CRAN mirror, the

How to split epochs into year, month, etc

一个人想着一个人 提交于 2019-12-12 03:09:46
问题 I have a data frame containing many time columns. I want to add columns for each time for year, month, date, etc. Here is what I have so far: library(dplyr) library(lubridate) times <- c(133456789, 143456789, 144456789 ) train2 <- data.frame(sent_time = times, open_time = times) time_col_names <- c("sent_time", "open_time") dt_part_names <- c("year", "month", "hour", "wday", "day") train3 <- as.data.frame(train2) dummy <- lapply(time_col_names, function(col_name) { pct_times <- as.POSIXct

Count number of days since a specific date [duplicate]

允我心安 提交于 2019-12-12 02:36:32
问题 This question already has answers here : Get the difference between dates in terms of weeks, months, quarters, and years (8 answers) Closed 3 years ago . I have got a dataframe with a column Date in which the observations range from 1974-10-01 to 2014-30-09. I would like to create a new column ("Day") in the dataframe which specify the number of day since the first time period day (i.e. 1974-10-01). I already have the code and it worked perfectly for a really similar dataframe but I do not

Matching values conditioned on overlapping Intervals and ID

◇◆丶佛笑我妖孽 提交于 2019-12-11 17:18:55
问题 I am having difficulties at manipulating the following data structures: Attributes Data Frame: ID Begin_A End_A Interval Value 5 2017-03-01 2017-03-10 2017-03-01 UTC--2017-03-10 UTC Cat1 10 2017-12-01 2017-12-02 2017-12-01 UTC--2017-12-02 UTC Cat2 5 2017-03-01 2017-03-03 2017-03-01 UTC--2017-03-03 UTC Cat3 10 2017-12-05 2017-12-10 2017-12-05 UTC--2017-12-10 UTC Cat4 Bookings Data Frame: ID Begin_A End_A Interval 5 2017-03-03 2017-03-05 2017-03-03 UTC--2017-03-05 UTC 6 2017-05-03 2017-05-05

Error when executing `floor_date()`

浪子不回头ぞ 提交于 2019-12-11 09:44:14
问题 I get the following error message: Error in if (sum(c(new$hour, new$min, new$sec))) { : argument is not interpretable as logical when I execute the following code: keep$EstimateDate <- as.Date(keep$date + keep$days,"%Y-%m-%d") keep$EstimateDateWeekStart <- floor_date(keep$EstimateDate,"week") #+1 The keep$EstimateDate is a column in a data.table with properly formatted dates. The floor_date() is a function in the lubridate package. 回答1: The only scenario I can think of where you get an error

Date conversion without specifying the format

匆匆过客 提交于 2019-12-11 08:08:36
问题 I do not understand how the "ymd" function from the library "lubridate" works in R. I am trying to build a feature which converts the date correctly without having to specify the format. I am checking for the minimum number of NA's occurring as a result of dmy(), mdy() and ymd() functions. So ymd() is giving NA sometimes and sometimes not for the same Date value. Are there any other functions or packages in R, which will help me get over this problem. > data$DTTM[1:5] [1] "4-Sep-06" "27-Oct

Adjusting UTC date/time to different time zones by reference in `lubridate`

与世无争的帅哥 提交于 2019-12-11 07:58:25
问题 I have a data.table with UTC date-time-stamp records spanning multiple time zones, and I want to create a new column that will show the date-time-stamp but in the specific time zone of each observation, which is specified by a variable in the same table: require("lubridate") require("data.table") dt <- data.table(A = 1:5, B = rep(ymd_hms("2016-03-24 17:15:12", tz = "UTC"), 5), timezone = c("America/Indiana/Vincennes", "Australia/North", "Pacific/Palau", "Antarctica/Macquarie", "Asia/Nicosia")

lubridate - counting overlapping intervals for every interval

大城市里の小女人 提交于 2019-12-11 06:18:40
问题 i am not very experienced in programmming today, but did some work in the past far away. We support shared cars and for every car there are bookings with a start-datetime and an end-datetime. Start-dt an end-dt for every booking is at full 00 or 30 minutes and has a duration >= 30 Minutes. Now we have many cars at the same place an i want to see, how many cars had a booking at overlapping times. For this i build a sequence of timeslots with a duration of 30 minutes between two times. library

aggregation minutes time in different time interval in R

爷,独闯天下 提交于 2019-12-11 05:23:52
问题 Here dataset with minutes datetime. times<-structure(list(date = structure(1:61, .Label = c("13.09.2018 14:00", "13.09.2018 14:01", "13.09.2018 14:02", "13.09.2018 14:03", "13.09.2018 14:04", "13.09.2018 14:05", "13.09.2018 14:06", "13.09.2018 14:07", "13.09.2018 14:08", "13.09.2018 14:09", "13.09.2018 14:10", "13.09.2018 14:11", "13.09.2018 14:12", "13.09.2018 14:13", "13.09.2018 14:14", "13.09.2018 14:15", "13.09.2018 14:16", "13.09.2018 14:17", "13.09.2018 14:18", "13.09.2018 14:19", "13

Grouping a data frame by dates: resolve missing time periods' bug

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-11 05:18:52
问题 I've identified, if not myself created, a difficult bug to resolve in some nice code received from a generous respondent here on StackOverflow a few weeks ago, and I could use some new assistance today. Sample data (called object eh below): ID 2013-03-20 2013-04-09 2013-04-11 2013-04-17 2013-04-25 2013-05-15 2013-05-24 2013-05-25 2013-05-26 5167f 0 0 0 0 0 0 0 0 0 1214m 0 0 0 0 0 0 0 0 0 1844f 0 0 0 0 0 0 0 0 0 2113m 0 0 0 0 0 0 0 0 0 2254m 0 0 0 0 0 0 0 0 0 2721f 0 0 0 0 0 0 0 0 0 3121f 0 0