R - Error in charToDate(x) - r

I'm sure this is super simple to understand, but I'm new to R, and try as I might, I can't get the other suggestions on these forums to work for me. I'm just trying to download the PAYEMS time series through the Quantmod package.
The code:
library(quantmod)
library(lubridate)
getSymbols("PAYEMS", src=("FRED"), return.class = "xts")
The output:
getSymbols("PAYEMS", src=("FRED"), return.class = "xts")
Error in charToDate(x) :
character string is not in a standard unambiguous format
I'm guessing it's the date format, but it's not clear to me how I fix that. I only know how to change it once I get the vector I want to make into dates.
Thanks!

I get this error occasionally too. I don't recall getting this the year before. Restarting R doesn't help, but restarting the computer does solve the problem. I don't know what it is that fixed this.

Related

How to solve the following error message related to dates :Incompatible methods ("-.Date", "-.POSIXt") R?

I am new using R, I need to calculate the time between two dates: date_inclusion and date_point, for which I am doing the following.
cancer$date_point <- as_date("1980 - 02 - 15")
cancer$delai_recul_j <-(cancer$date_point-cancer$Date_inclusion)
but I get the following message.
'Warning message: Incompatible methods ("-.Date", "-.POSIXt") for "-"'
At first I thought it was the Mac date format, but it didn't work, I don't know what to do, since obviously with the column that is created I can't work.
Thank you very much!

Quantmod/getOptionChain Error in .Date(Exp/86400) : could not find function ".Date"

I'm getting an error when running getOptionChain from quantmod package.
The code should get Option chain data and subset into a new list that contains only the puts.
The error I get is: Error in .Date(Exp/86400) : could not find function ".Date"
Same code, sometimes runs without error. If I shorten the list of Symbols, there's no error, but the error as far as I know is not related to a specific symbol, because I made to run successfully. Seems random but frequent error.
All symbols are weekly expirations and the desired output is the next weekly expiration, so from my understanding, there's no need to specify a exp date.
library(quantmod)
library(xts)
Symbols<-c ("AA","AAL","AAOI","AAPL","ABBV","ABC","ABNB","ABT","ACAD","ACB","ACN","ADBE","ADI","ADM","ADP",
"ADSK","AEO","AFL","AFRM","AG","AGNC","AHT","AIG","AKAM","ALGN","AMAT","AMBA","AMC","AMD","AMGN",
"AMPX","AMRN","AMRS","AMZN","ANET","ANF","ANY","APA","APO","APPH","APPS","APRN","APT","AR","ARVL")
Options.20221118 <- lapply(Symbols, getOptionChain)
names(Options.20221118) <- Symbols
only_puts_list <- lapply(Options.20221118, function(x) x$puts)
After upgrading to R 4.2.2 the issue is fixed.

CharToDate(x) Error in R

I have a function named currency. It takes a parameter A which is a currency like "EUR/USD" . Then I do this: n<-getSymbols(A,src = "oanda",from = "2016-01-01",to = Sys.Date(),auto.assign = FALSE)
The paradox is that the program was running fine 2 days ago.
The error message is: Error in charToDate(x) : character string is not in a standard unambiguous format.
This is the traceback()
Thanks in advance!
I think that this a duplicate
quantmod::getFX function returns "character in a standard unambiguous format"
In any case, I followed the code of the getSymbols.oanda and it seems that oanda changed their API so instead of downloading a .csv you get a .xml file.
Speaking for me, I will go for a different source for the data until this is resolved by the quantmod guys.

Troubles in R with Dates

I'm just starting with R. I have the following problem:
I am using the "sesonal" package (http://cran.at.r-project.org/web/packages/season/season.pdf). I wanted to usethe cosinor function but I have a problem I can't solve.
If I use this call:
test = cosinor(data=train_data2, date=as.Date("2013-01-01"))
I get:
Fehler in charToDate(x) :
character string is not in a standard unambiguous format
but the date seams to be in the right format since
as.Date("2013-01-01")
works fine.
can anyone help me ?
Thanks in advance!

Changing String to Date and Time in R

I have a vector of character class strings.
I want to covert this to Sys.time() format. How can I do that?
When I use the as.POSIXct(z,format= "%d/%m/%Y %H:%M:%S")
I get the following warning:
Warning message:
In as.POSIXlt.POSIXct(x, tz) : NAs introduced by coercion
I don't want this to convert to NAs. What should I do?
Kindly use
strptime("2014-06-05 15:33:55 IST","%Y-%m-%d %H:%M:%S",tz="Asia/Kolkata")
For your problem
data$time <- strptime(data$time, "%Y-%m-%d %H:%M:%S",tz="Asia/Kolkata")
class(data$time)
It should be of type POSIXlt
I know this is an old question but for the benefit of those Googling this problem, I had a similar problem recently when using rbind.fill. I discovered that one of my dates was in European format, 31/1/2017 instead of 1/31/2017 like all the others. It was causing R to blank out the entire column after performing rbind.fill. Fixing the date fixed the issue.
Hope this helps someone, I spent hours trying to figure out why this was happening. R is really picky sometimes.

Resources