0

I called index data from an excel csv. (Dates are in yyyy/mm/dd format.)

 library(tseries)
 library(minpack.lm)
 library(ggplot2)
 index <- read.csv("C:\\Users\\Toshiba\\Desktop\\deks\\DATA.csv")
 ts <- index
 df <- data.frame(ts)
 df <- data.frame(ts)
 df <- data.frame(Date=as.Date(rownames(df)),Y=df$Close)

I received the error:

Error in charToDate(x) : character string is not in a standard unambiguous format

and for

  df$days<-as.numeric(df$Date-df[1,]$Date)

I received

Warning message: In Ops.factor(df$Date, df[1, ]$Date) : - not meaningful for factors

I set the data as X=DATE(YYYY/MM/DD) and Y=INDEX VALUE.

I changed the date to [(DD/MM/YYYY),(DD-MM-YYYY),(YYYY-MM-DD)] and still the error appears. How can I proceed?

joran
  • 169,992
  • 32
  • 429
  • 468
user3664028
  • 1
  • 1
  • 2

1 Answers1

0

Step 1:

options(stringsAsFactors=FALSE)

Step 2:

index <- read.csv("C:\\Users\\Toshiba\\Desktop\\deks\\DATA.csv")
ts <- index
df <- data.frame(ts)
df <- data.frame(ts)
df <- data.frame(Date=as.Date(rownames(df), "%Y/%m/%d"),Y=df$Close)
stanekam
  • 3,906
  • 2
  • 22
  • 34