Error in as.data.frame.default(x[[i]], optional = TRUE) : cannot coerce class ‘"function"’ to a data.frame

Hello everyone
Please I am facing an error "Error in as.data.frame.default(x[[i]], optional = TRUE) :
cannot coerce class ‘"function"’ to a data.frame" in R studio while I am running below mentioned code:
library(WaveletComp)
data<-read.table("C:/Users/faryal malaika/Desktop/Data Finalized/data.csv",header = TRUE, sep =";", stringsAsFactors = FALSE)
data<-as.Date(data$DATA)
my.data = data.frame(date = date, x = data$x, y = data$y)

Please help me how to sort out this error. I have daily returns data naming columns, date, x and y.

Thanking you

This line

data<-as.Date(data$DATA)

does not make sense to me. You replace the entire data data frame with one of its columns. Do you mean

data$DATA <- as.Date(data$DATA)

or maybe

data$DATE <- as.Date(data$DATE)

The next line would then be

my.data = data.frame(date = data$DATE, x = data$x, y = data$y)

though there are clearer ways to select three columns from a data framd.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.