DS4PS / cpp-525-fall-2020

http://ds4ps.org/cpp-525-fall-2020/
1 stars 0 forks source link

Lab 1 Data Type Issue #20

Open nerea88 opened 3 years ago

nerea88 commented 3 years ago

I am having issues working with the data when brought into markdown. It is brought in as a list and seems like it needs to be another format to run the time series model. I have tried a few different ways:

p2 <- as.data.frame(passengers)
p3 <- as.numeric(as.character(unlist(passengers[1:365])))

But I still get this error when I try to run the time series model:

Error in model.frame.default(formula = p3 ~ time + treatment + timesince, : invalid type (list) for variable 'time'

I feel as if I am missing something potentially simple but haven’t been able to formulate and search the right questions to figure this out. Any help would be appreciated.

Thanks, Nick

Dselby86 commented 3 years ago

Passengers is a vector. So you need to build a dataframe with all the variables, or make each variable its separate numeric vector.

For time just do

Time <- 1:365

Then use the time variable to create treatment and time since.

Hope that helps