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

R string vector seq

This is the output I am aiming for where z will provide a plot of mine with an x-axis. z<-c("2014-01", "", "", "2014-04", "", "", "2014-07", "", "","2014-10", "", "", "2015-01") The plot will be produced once a month and I aim on automating the…
alx.chrs
  • 127
  • 3
  • 15
0
votes
3 answers

Complex dates manipulation in r

I have a data.frame with two columns. Both, dates as characters: a <- c("01-01-2007 00:00:00", "01-02-2007 00:00:00", "03-05-2007 00:00:00", "31-08-2007 00:00:00") b <- c("01-01-1960 01:25:30", "01-01-1960 1:05:36", "01-01-1960 02:25:59",…
Xbel
  • 735
  • 1
  • 10
  • 30
0
votes
1 answer

R - Date in a bad format - LMT format

From R I read data into a MySQL database. There is a date column. The problem is the result is very very bad. head(inputd$Semaine_lundi, n=20) [1] "-1-12-09 00:13:36 LMT" "-1-12-16 00:13:36 LMT" "-1-12-16 00:13:36 LMT" "-1-12-23 00:13:36 LMT" …
Mael Fosso
  • 360
  • 6
  • 14
0
votes
2 answers

as.Date function gives different result in a for loop

Slight problem where my as.Date function gives a different result when I put it in a for loop. I'm looking in a folder with subfolders (per date) that contain images. I build date_list to organize all the dates (for plotting options in a later…
Jobbo90
  • 175
  • 1
  • 11
0
votes
1 answer

How to Replace NA's in a Date Column

I have a column in my data frame that contains dates so it is a date class. However, when I try to remove NA's from this column I cannot because it is not a character class. So I convert it to character class using this solution: Setting to…
d84_n1nj4
  • 1,712
  • 6
  • 23
  • 40
0
votes
1 answer

formatting dates with R and as.date

I'm trying to format dates with R. Can someone explain why R gives an error when these two strings are the exact same format? I cannot figure out how to manage these date strings, and any help is greatly appreciated as I'm new working with R. >…
MostlyRquestions
  • 526
  • 2
  • 7
  • 22
0
votes
1 answer

How to make iterations over dates in R

This is a more general problem I get in R. Say I want to create a subset for a dataset data that contains the first 10 days the days 1,...,10. For a single day I can easy make the subset like this data_new <- subset(data, data$time ==…
0
votes
0 answers

How to eliminate warning message when summarizing date based on max(Date)

I am trying to summarize dates by ID based on the max() of ExitDate. When I run the following code, however, I receive this message: In max.default(structure(NA_real_, class = "Date"), na.rm = TRUE) : no non-missing arguments to max; returning…
0
votes
1 answer

Formatting days of the week in R

I have a variable in my data frame for day of the week. > str(g.2015.1990$DAY.OF.WEEK) Factor w/ 7 levels "Friday","Monday",..: 1 3 4 2 6 7 5 1 3 4 ... R recognizes this as a factor, but is there already a specific format for day of the week I can…
0
votes
0 answers

Format time in R

I'm new to R, but need help formatting just one variable in my data frame: > str(g.2015.1990$START.TIME) int [1:60464] 712 606 1238 708 709 707 407 707 612 1237 ... Although R interprets this as an integer, it is a time variable formatted in 3-4…
0
votes
3 answers

converting data.frames into time series

Here we go againi, I am still banging my head against the wall on the above problem. I have a data.frame that I upload via csv which looks like: X SPY VTI 01.02.2002 0.0000 0.0000 04.02.2002 -2.4578 -2.4167 ..... 31.12.2015 -1.003 …
paolino
  • 11
  • 2
0
votes
1 answer

Changing the date format in r with strptime and as.Date

Following is part of my data: Date Elev Temp.C 1 02 January 2010 200 14.7 2 02 January 2010 300 5 3 02 January 2010 500 -2 4 02 January 2010 1000 -9.8 5 02 January 2010 2000 -7.1 I wanted to change the format of the…
G1124E
  • 407
  • 1
  • 10
  • 20
0
votes
0 answers

In R, I am getting multiple duplicated rows in merge.xts. How do I not?

I have a list, with each member being a stock, and various fields of historical bloomberg data. For example: > head(isData[[2]]) date CUR_MKT_CAP OPERATING_INCOME_SEQ_GROWTH OPER_ROE PX_LAST SHORT_AND_LONG_TERM_DEBT 1 1999-12-31 NA …
lukehawk
  • 1,423
  • 3
  • 22
  • 48
0
votes
1 answer

R import csv lose date (day) value

I am importing a csv, and it stores dates as month-year (Apr-02 for April 2002). In the csv file, there is a day in the value. So Apr-02 would actually have a value in the file as something like 4/10/2002. When I import the file into R, it keeps…
bnmsba14
  • 3
  • 3
0
votes
1 answer

Turning date strings into usable date objects in R

My strings look like: [1] "Sunday, April 10, 2016" "Saturday, April 16, 2016" I would like to apply an algorithm in R so they each read something like this and have a Class POSIXlt or POSIXct: [1] "04/10/2016" "04/16/2016" I tried to use…
IRNotSmart
  • 351
  • 6
  • 18