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
1
vote
3 answers

How to convert character column to date?

My data frame: yearmonth basinflow 1 1966-01 0.000105 2 1966-02 0.0000946 3 1966-03 0.816 4 1966-04 5.17 5 1966-05 0.102 6 1966-06 0.0729 I want to add a column with just the month values, but…
Kayla
  • 59
  • 5
1
vote
0 answers

Trouble converting dates read in from excel

I have a data set that the date/time is formatted like this in excel 3/11/2020 8:12:00 PM 3/12/2020 7:13:00 PM When I read the file in, the date/time is converted to this. I would like to convert this to Month/day/year. 43901.84 43902.80 I have…
T.McMillen
  • 115
  • 7
1
vote
1 answer

How to convert week numbers into date format using R

I am trying to convert a column in my dataset that contains week numbers into weekly Dates. I was trying to use the lubridate package but could not find a solution. The dataset looks like the one below: df <- tibble(week = c("202009", "202010",…
1
vote
1 answer

as.Date error when converting using tryFormats

I'm running this command in RStudio: as.Date("31.01.07", tryFormats = c("%d.%m.%y")) and I get this error: Error in charToDate(x) : character string is not in a standard unambiguous format When I try this: as.Date("31.01.07", format =…
user2908112
  • 457
  • 6
  • 18
1
vote
1 answer

ggplot w/ x-axis Month-Year (no day) and "filter" start date

so suppose i have data set: date order_sum 2015-01-01 800 2016-08-19 900 2019-04-16 1200 2020-10-28 850 here's my to-month conversion: sales$month <- month(sales$date) here's my minimum to be used in x-axis: min <-…
danisabbia
  • 25
  • 5
1
vote
1 answer

How do I remove an automatically set year when using As.date in R?

I have am struggling using dates in R. I got to set it using as.Date, but then I automatically get the current year even if I did not specify it. How can I remove the year from Date? xy <- matrix(c("09/08", "10/14", "10/06", "05/11",…
HM_ft
  • 98
  • 5
1
vote
1 answer

Customize the year in as.Date (in R)

I have some dates (character string) with only month and date, for example "20-May". I'm using as.Date to convert it to a date object: as.Date("20-May", format = "%d-%b") What I got is: "2021-05-20". So R automatically sets the year to the current…
Xiaokang
  • 331
  • 1
  • 11
1
vote
2 answers

as.date in R does not convert years properly

I import the csv file: {casesRaw<-read.csv('CasesRaw.csv') tail(casesRaw$Date) my result: "12/28/2020" "12/29/2020" "12/30/2020" "12/31/2020" "1/1/2021" "1/2/2021" after…
Ali Nemati
  • 184
  • 5
1
vote
1 answer

Number of characters in an object of class Date in R

I am trying to figure out the rationale for the number of characters in an R object of class Date, which seems to be different than I would expect based on manually counting the length of a date string. For example: str1 <- "2020-12-11" dat1 <-…
cgjeff
  • 41
  • 1
  • 5
1
vote
2 answers

as.Date returns NA date format

My date format is "Sat 12 Sep" as character. I want to transform it into Date format in a new column called DATE. mutate(DATE = (as.Date(FECHA, "%a %d %b"))) but it returns NA X FECHA LOCAL RESULT VISITANTE DATE …
1
vote
2 answers

Web-scraping has weird format of date, need to convert. "Error in charToDate(x) : character string is not in a standard unambiguous format"

I'm trying to scrape this website by day. https://www.basketball-reference.com/boxscores/?month=9&day=30&year=2020 As you can see, the date is not in the right format and I can't figure out how to get R to recognize it as a date. Here is my code so…
1
vote
2 answers

Want to combine the following into datetime column in R

I have columns in the following way date, hour minute column The first column has year month day together. I want to combine columns 1, 4, 5 into DateTime format in R. Please help me. I have used as.date but getting error.
nani
  • 13
  • 3
1
vote
2 answers

Transform numeric field (YYYY.WW) to ISOweek() date field

The data frame entails a date column in the format YYYY.WW. It is imported from a csv. and classified as numeric which does not allow me to properly use it for time series analysis or ggplot visualisations. I tried to transform it as such but I get…
Max
  • 185
  • 1
  • 11
1
vote
0 answers

as.Date returns NAs

I have a very simple question, but somehow I can not figure out the problem. I want to convert a character column to a date column, to be able to create a line graph afterwards (date on x-axis, x on y-axis). However, when I try to convert the data…
Kat
  • 13
  • 2
1
vote
1 answer

Object converted to xts but an error appears when I apply dailyReturn

I have already converted my data to an xts object and this error persists. I think it is related to my date format but, I have used the function as.Date to make sure my date format is right. Here is my code so far: library(quantmod) …