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

Error: Discrete value supplied to continuous scale, as.Date

Data are supplied below with dput, but look like this: head(dat) IndIDYear DayStarting Year DailyNSD springstart 1 MTG_001_A.2012 2012-01-01 2012 0 2012-07-06 2 MTG_001_A.2012 2012-01-02 2012 0 2012-07-06 3 MTG_001_A.2012 …
B. Davis
  • 3,391
  • 5
  • 42
  • 78
1
vote
1 answer

Proper date formatting in R

I am currently working with this dataset. 'data.frame': 2938 obs. of 4 variables: $ X : int 21562 21603 21618 21620 21659 21990 21996 22024 22592 22665 ... $ uuid : Factor w/ 2938 levels…
1
vote
2 answers

R extract Date and Time Info

I have a data.frame that looks like this: > df1 Date Name Surname Amount 2015-07-24 John Smith 200 I want to extrapolate all the infos out of the Date into new columns, so I can get to this: > df2 Date Year …
Billaus
  • 81
  • 1
  • 12
1
vote
0 answers

as.Date works in different way

I found here a simple way to convert String to date format. The problem is I get different result in comparision with those on the website. sdate1 <- "6aug2005" sdate2 <- "jan151999" sdate3 <- "12-15-2001" ndate1 <- as.Date(sdate1, "%d%B%Y");…
jjankowiak
  • 3,010
  • 6
  • 28
  • 45
1
vote
0 answers

shiny reactive dateformat

I'm triyng to build a simple shiny app and I'm stuck with a date transformation. The main purpose I want is to choose the file and choose the date format. For now I'm working with one date format in an csv,datafile example that looks like a…
Oscar Benitez
  • 255
  • 3
  • 13
1
vote
2 answers

convert string data.frame to Date

I am wondering why this error occurs. I would like to convert this using brackets as I am making sequential conversions in a loop. And because I just want to be able to do it and understand what is happening. head(clean.deposit.rates) …
user3385769
  • 161
  • 6
  • 16
1
vote
3 answers

Split Dates by intervals in R

I have a column with Dates: Date 6/1/2010 6/1/2010 6/1/2010 9/1/2010 9/1/2010 9/1/2010 12/1/2010 12/1/2010 12/1/2010 3/1/2011 3/1/2011 3/1/2011 6/1/2011 6/1/2011 6/1/2011 9/1/2011 9/1/2011 9/1/2011 …
user45415631
  • 175
  • 2
  • 11
1
vote
0 answers

NA's when converting serial number into date in R

After importing an excel sheet into R, I found that all dates format has been changed to serial number. I tried to use the very simple code as below, however I get NA's instead of date. Reproducible example is (df): structure(list(X1 = c("31020",…
mallet
  • 2,454
  • 3
  • 37
  • 64
0
votes
1 answer

how to convert YMD_HMS "character" into date in R

I am in R studio trying to separate my dates "6/30/22 17:27" into year, month, day, and hms columns. The problem is it's not a numeric type variable, it's a character type. So I need to convert it before I can separate it into my needed columns. So…
0
votes
1 answer

Extract year, month and day from matrix column in one line of code

I'd like to shorten my code. My current approach is: year = as.numeric(format(as.Date(matrix[,dt_ind]), format = "%Y")) month = as.numeric(format(as.Date(matrix[,dt_ind]), format="%m")) day = as.numeric(format(as.Date(matrix[,dt_ind]),…
s28
  • 173
  • 5
0
votes
0 answers

Changing character field to a date format not working - dropping some dates

I have a large df with many columns, here's a sample: df <- data.frame(Quarter = c["Q4 2022", "Q4 2022", "Q1 2023", "Q1 2023"], Date = c["2022-11-08", "2022-11-25", "02/09/2023", "03/15/2023"]) I want to…
Donut
  • 11
  • 4
0
votes
0 answers

I keep getting NA conversion errors when converting character string columns to Date and Numeric, how can I bypass this error?

I have a large data set around 6 million rows of data. The data set was created by using bindrows from several different spreadsheets all consisting of the same columns. I want to create new columns for date, month, year, and day of the week so I…
antik731
  • 1
  • 1
0
votes
1 answer

Handling and converting multiple date formats in a file

i am relatively new to R and have the problem outlined below. Any feedback and help is much appreciated. Many thanks! I have a 400k lines CSV dataset with contributions from multiple countries, which appear to use different date formats. In…
Awamax
  • 1
  • 1
0
votes
0 answers

Error in R: non-numeric argument to binary operator

I would like some help with understanding and fixing an error message that I encountered when I executed the command View(combined_data). The error message that appeared was: r error 4 (Error in vec_data(x) * TICS_PER_SECOND : non-numeric argument…
0
votes
0 answers

Change date format in R from: "Year-Month" to "Year-Month-Day"

I have an existing column that has "dates" in character format. How can I alter my existing data frame coloumn so from: 2022-12 to 2022-12-01 2022-12 (Year-Month in class character) to 2022-12-01 (Year-Month-Day in class Date) I have tired using…
user2256
  • 1
  • 1