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
1 answer

Convert to date from unconventional format in R

I have dates formatted as character strings following the format of this example: "Wednesday 18 May 2016" Is there a way to convert it into date directly, maybe with as.Date(mystring,someformat) ?
moodymudskipper
  • 46,417
  • 11
  • 121
  • 167
0
votes
0 answers

as.Date converts wrong date from POSIXct data

I have 3848 rows of POSIXct data - stop times of bike trips in the month of April. As you can see, all of the data is in POSIXct format and is within the range of the month of April. length(output2_stoptime) [1] 3848 head(output2_stoptime) [1]…
iskandarblue
  • 7,208
  • 15
  • 60
  • 130
0
votes
0 answers

How to convert year variable using as.Date(), but maintain format

I'm trying to convert my year variable into a Date class year type sum 1 99 NON-ROAD 522.9400 2 99 NONPOINT 2107.6250 3 99 ON-ROAD 346.8200 4 99 POINT 296.7950 5 02 NON-ROAD 240.8469 6 02 NONPOINT 1509.5000 The…
user3200293
  • 181
  • 5
  • 18
0
votes
1 answer

R subset data frame where date is less than a variable date

I am trying to select a subset of a data frame where the date needs to be less than a (calculated/variable) date. The following code throws an error: loanFrame_excluding_young <- loanFrame[loanFrame$LoanEffective <…
gmarais
  • 1,801
  • 4
  • 16
  • 32
0
votes
1 answer

Convert date string that contains time zone to POSIXct in R

I have a vector with dates in this format (example of the first 6 rows): Dates<-c( "Sun Oct 04 20:33:05 EEST 2015", "Sun Oct 04 20:49:23 EEST 2015", "Sun Oct 04 21:05:25 EEST 2015", "Mon Sep 28 10:02:38 IDT 2015", "Mon Sep 28…
GegznaV
  • 4,938
  • 4
  • 23
  • 43
0
votes
2 answers

Using R, How to Convert a Factor into a Date without losing the year?

When I read in a data file using R, a Date variable is a Factor. For example, let epc hold the data set. Then if we look at the structure of the first date, we get str(epc$Date[1]) Factor w/ 1 level "16/12/2006": 1 If you were to convert this…
Christopher Skyi
  • 229
  • 1
  • 3
  • 12
0
votes
1 answer

R - formating list of variables as date in the same data frame

I have 50 variables named Date1 - Date50 stored in data1 (among other variables). The initial format of Date1 - Date50 is "factor". The values are like "24.01.2014". How can I format all 50 variables as a Date at once? For a single variable the…
Georg
  • 61
  • 1
  • 8
0
votes
1 answer

R: reorder data after split() command using unconventional date column

For easier data manipulation purposes, I have a data frame in R that contains a column with date and hour values written as such: june 5 23. "june 5" is the month (no year included), and "23" is the hour (including minutes and seconds would cause…
0
votes
0 answers

How to format dates without spaces r

I can do this strptime("20150615",format="%Y%m%d") But this won't work. strptime("194207","%Y%m") [1] NA Whats is going on here? Edit For now doing this but so silly. strptime(paste("194207","01"),"%Y%m%d")
CCurtis
  • 1,770
  • 3
  • 15
  • 25
0
votes
0 answers

How can I subset a data frame by a specific year and two specific months?

I have been subsetting my data set based on year and month using: sub2007 <- subset(Data, format(Date, "%Y") == "2007" & format(Data, "%m") == "04") Which has been working fine. However, how can I select multiple months? I have tried several…
0
votes
2 answers

as.Date convert Date in a data frame

I'd like to convert a whole column with as.Date to a date format. str(fluesse) 'data.frame': 1049 obs. of 28 variables: $ Datum : Date, format: NA NA NA ... the dates are formatted like this: 07.08.14 This is what I…
Brkhn
  • 1
  • 1
  • 2
0
votes
4 answers

new variable with as.date in R

this is head(both$stterm) stterm 1 2011-01-19 2 2012-01-19 3 2007-09-01 4 2011-09-01 5 2008-09-01 6 2013-09-01 this is, as I said just part of a dataset I have 4021 observations. I want to create a new column, were each date instead represents a…
malin
  • 37
  • 1
  • 4
0
votes
1 answer

Dygraphs error in as.POSIXlt.character

Trying to create a graph with the dygraphs package. I've converted the dates using as.Date() but I'm getting this message: Error in as.POSIXlt.character(x, tz, ...) : character string is not in a standard unambiguous format The first few rows…
0
votes
2 answers

Convert dates with different formats in data frame over multiple columns

I have data frame (test) that looks like this: abx start stop abx2 start2 stop2 abx3 start3 stop3 cipro 07/10/12 07/10/12 flagyl 07/10/12 07/17/12 n/a n/a n/a vanco 07/12/2012 07/15/2012 levo …
Tom O
  • 1,497
  • 3
  • 13
  • 16
0
votes
1 answer

as.Date is throwing a row number mismatch, but all vectors are same length

The following (CSV) dataset has 3133 rows of expenses by day between 7/1/2000 and 12/31/2014: head(d_exp_0014) 2000 7 6 792078.595 9 2000 7 7 140065.5 9 2000 7 11 190553.2 9 2000 7 12 119208.65 9 2000 7 16 …
d8aninja
  • 3,233
  • 4
  • 36
  • 60