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
0 answers

Date Converting in Loop in R

Hello again stackoverflow. I'm encountering problems in my R code again in converting columns of dates imported from Excel in a double loop in R. The following code is what I wrote in order to convert the data (starting from column 11 to column 19…
zhshzh44
  • 3
  • 2
0
votes
1 answer

Trouble reformatting date with as.Date

I'm having a simple problem and I can't tell what's wrong. I'm trying to convert dates formatted "YYYY-MM-DD" to "m/d/YYYY". On my machine, this code: x <- as.Date("2000-01-01") x <- as.Date(x, format =…
ILA
  • 3
  • 1
0
votes
1 answer

ggplot: Issue when converting axis values from number of days to months in a boxplot

When converting a numeric variable "number of days from 1st of January of 2015" to date, the boxplot only shows part of the range of y-values but not all. In this example, I plotted "gender" vs "months". Months were obtained by transforming the…
0
votes
1 answer

R: Rollapply, preserve Date column

I have a dataset that includes a date column and the other columns are daily index returns. I would like to receive the rolling standard deviation for all indices but preserve the date in order to plot the results. Data looks as…
JJP
  • 3
  • 2
0
votes
1 answer

R Creating a data.frame and treating an object as.Date - R Version 3.5.0 - Rstudio Version 1.1.447 -

I was playing around with a data frame and I can't wrap my head around a problem. Here is the code I used: Died.At <- c(22,40,72,41) Writer.At <- c(16, 18, 36, 36) First.Name <- c("John", "Edgar", "Walt", "Jane") Second.Name <- c("Doe", "Poe",…
0
votes
1 answer

R: as.Date delivers numbers in a matrix but with a single number a date - difference?

I have dates in the format "X12.11.1985" and if I use the as.date() function to convert it on a matrix, it delivers a single number. If I use as.date() with just one single date, then it delivers a real date. Why is the result of the as.Date()…
user2894356
  • 141
  • 1
  • 10
0
votes
2 answers

date value to date format in R

i am trying to change the format of date that i import it from a CSV file. class for the date column is factor but when i want to use "as.Date" function it make me an error that the string format is not proper. > New_His_data$BirthDate[1] [1]…
Ehsan
  • 11
  • 1
  • 7
0
votes
3 answers

Using as.Date returns mostly NAs, but some correct dates

I am trying to convert date information from a .csv file to date format in R, so that I create two week intervals with which to categorize data. However, when using as.Date, it is only working correctly on some of the dates, and leaving the rest as…
0
votes
3 answers

How to convert two concatenate string vars to %m%Y format

I created a character variable called long.oto.yeni$Date. Now I need to transform this variable to %m/%Y format to plot time series graph in ggplot2. So I am unable to use yearmon() function from zoo package. But when I used as.Date() function,…
omzeybek
  • 305
  • 2
  • 14
0
votes
0 answers

R as.date error creating date

I am trying to create a time series of future dates (every day for a 30-year time period, starting in 2020). I was able to create a time series: library(zoo) df$Date <- zooreg(1:10958, start = as.Date("2020-01-01")) #assign date But, I was not…
James
  • 123
  • 1
  • 8
0
votes
2 answers

Convert chr to date using as.date

"2008/3" "2008/4" "2008/5" "2008/6" "2008/7" "2008/8" "2008/9" "2008/10" [9] "2008/11" "2008/12" "2009/1" "2009/2" "2009/3" "2009/4" "2009/5" "2009/6" [17] "2009/7" "2009/8" "2009/9" "2009/10" "2009/11" "2009/12" I use…
huaweiman
  • 19
  • 4
0
votes
2 answers

Trying to convert the date which is in character format

My dataset has 90,000 odd records. date format is as below: timestamp 2018-01-27T09:01:49Z 2018-01-27T00:04:08Z 2018-01-27T09:04:22Z 2018-01-27T09:04:28Z 2018-01-27T00:07:38Z I tried as.Date(recfive$timestamp, "%Y/%m/%d %H:%M:%S") I am getting all…
0
votes
2 answers

Generate first and last Julian day of each month

I want to creat a vector of start and end day of each month for a non-leap year (365 days) in julian days. Something like start.month <- c(1, 32, 60, .....) end.month <- c(31, 59, 90, .....) How do I do this in R? I can only generate the…
89_Simple
  • 3,393
  • 3
  • 39
  • 94
0
votes
0 answers

as.Date return NA for single digit days

I am converting my string date to date formatted as dd-mm-yy using the as.Date function but this only work for double digit days, while returning NA for single digit day. Would somebody have any ideas why is this?…
Phuong Ho
  • 67
  • 1
  • 6
0
votes
0 answers

Why does `as.Date` keep giving me `NA`s?

For some reason, as.Date keeps giving me NAs. Here's my code: test <- "1996-04" as.Date(test, format="%Y-%m") This question/answer here didn't help me.
Taylor
  • 1,797
  • 4
  • 26
  • 51