Questions tagged [as.date]

as.Date is an R function used to convert between character or numeric representations and objects of class "Date", representing calendar dates.

as.Date is an R function used to convert between character or numeric representations and objects of class "Date", representing calendar dates.

https://www.rdocumentation.org/packages/base/versions/3.3.2/topics/as.Date

349 questions
0
votes
2 answers

Trouble converting and separating dates in R

I have a dataset containing some dates listed in the CSV as dd/mm/yy and my final aim is to separate out the year column into a separate column, however it seems to be giving me some very odd results. When the CSV is input into R, the dataset…
CDav
  • 187
  • 1
  • 5
  • 12
0
votes
1 answer

Paste Date to Time in an Irregular Way

I am trying to combine times with it's corresponding date, but am having trouble. The dates and times are in one list where the date is followed by times for that date. This papptern continues in an irregular fashion. Here's what I tried so far: z =…
jdesilvio
  • 1,794
  • 4
  • 22
  • 38
0
votes
1 answer

Transforming as.Date: multiple data frames at once

I have 66 data frames that I need to transform the "Date" column "as.Date". I dont know how to do it at once. I'm going like…
Jorge Dias
  • 49
  • 7
0
votes
2 answers

How to calculate Mean by Date Grouped as Fiscal Quarters

I have the following table: Date Country Class Value 6/1/2010 USA A 45 6/1/2010 Canada A 23 6/1/2010 Brazil B 65 9/1/2010 USA B 47 9/1/2010 Canada A 98 9/1/2010 Brazil B 25 12/1/2010 …
user45415631
  • 175
  • 2
  • 11
0
votes
2 answers

R: Extract data based on date, "if date lesser than"

I have a dataset with two values for each date like this: date x y 1 2013-05-01 1 2 2 2013-05-02 2 2 3 2013-05-03 3 2 date is in the format as.Date, using the package lubridate. Now I want to have the mean of the two…
Anne
  • 377
  • 2
  • 4
  • 16
0
votes
1 answer

How do I combine two columns into one?

I am stuck combining two columns of a data frame into one. Below is the code to reproduce the problem df <- data.frame(date = c("2/13/1962 0:00:00", "4/13/1972 0:00:00", "3/13/1982 0:00:00", "12/13/1992 0:00:00"), time = c("0900",…
chribonn
  • 445
  • 5
  • 20
0
votes
1 answer

Function in a dataframe comparing two column

I have a data frame with three column. I want to apply a function to compare the second and third column, my function will create a new column. With an example : vin <- c("vin1", "vin2", "vin3", "vin4") date.fin.obs <- rep(as.Date("2014-07-04"),…
Mostafa90
  • 1,674
  • 1
  • 21
  • 39
0
votes
3 answers

How to get date format in a dataframe column?

I have a dataframe with a date column, and I want to convert it. With this example, DF <- data.frame(name = paste("A", 1:5, sep = ""), birth = c("16131", "2014-07-04", "16257", "15982", "2014-07-04")) as.Date(DF$birth, origin =…
Mostafa90
  • 1,674
  • 1
  • 21
  • 39
-1
votes
1 answer

Why is `as.Date()` giving different results on different days for the same code?

Screenshot of console I ran the first two lines of code in the screenshot and got one result. When I ran the same code today (the last two lines of code), I got a different result. I expected to get the same result, but got a different one. Am I…
-1
votes
1 answer

Separate date from a column and store in a new column

I am trying to separate date from one column and trying to put the date in another column but the new column is horribly wrong when I compare the dates in both columns. I am attaching pic below. I am separating date from the started_at column and…
-1
votes
2 answers

R function, Is there an error with my as.date? I got an error do not know how to convert df to class

Hi can someone help me solve this, got this error. Error in as.Date.default(x = df, format = "%m %d, %y") : do not know how to convert 'df' to class “Date” Appreciate it. df.data= data.frame(months = c(1,2,3,10,12), days =…
-1
votes
1 answer

Changing the Date format in the read dataframe

Actual data in the spreadsheet is as below. I have removed other columns to save space. EndTime 7/15/2020 9:34:03 AM 8/5/2020 3:19:10 PM 8/10/2020 9:52:58 AM 8/17/2020 8:07:14 PM 9/8/2020 6:11:52 AM #Reading the spreadsheet "File_Name" from…
misran
  • 37
  • 2
-1
votes
1 answer

R: as.Date not parsing dates 30 and 31 of each month

in the following example, as.Date is unable to parse dates of 30th and 31st of each month. dates <- c("28/03/2020", "29/03/2020","30/03/2020", "31/03/2020", "28/04/2020", "29/04/2020", "30/04/2020", "28/05/2020", "29/05/2020",…
-1
votes
1 answer

cross-join ids to extract data from other columns within the same R data frame

I have an R data frame like this one (but data wouldn't be sorted by any column): ppl <- structure(list(id = c("I0000", "I0001", "I0002", "I0003", "I0004","I0005", "I0006", "I0007", "I0008", "I0009"), Birth_Date = structure(c(NA, 517, -10246, -8723,…
abu
  • 422
  • 7
  • 14
-1
votes
1 answer

Can't convert date to date class in R

I am trying to make a subset based on date conditions. I uploaded a dataset and tried to convert the date from POSIXct to a date class using this code: as.Date(weatherDump$date, "%Y-%m-%d") It seemed to convert the date to y/m/d but when I try and…