Error in na.fail.default(as.ts(x)) : missing values in object in time series forecasting

I am trying to perform fit diagnostic on a salesData forecast using however I am getting an error: salesDataFC$residuals 2012 NA NA NA NA NA 2013 1.00454060 0.74436890 0.59266194 0.53535119 0.18350112 2014 1.99667197 -3.32464848 0.28314025 2.30886777 7.90332419 2015 1.71499831 -0.52401427 0.34252510 -1.64516043 2.77034325 2012 NA NA NA NA NA 2013 0.05094251 -0.22804463 -1.91518053 2.58830624 0.26477677 … Read more

Categories R

Correct syntax for mutate_if

I learned this trick from the purrr tutorial, and it also works in dplyr. There are two ways to solve this problem:First, define custom functions outside the pipe, and use it in mutate_if(): Second, use the combination of ~,. or .x.( .x can be replaced with ., but not any other character or symbol): In your case, you can also use mutate_all(): Using ~, we … Read more

Categories R

How to split data into training/testing sets using sample function

I’ve just started using R and I’m not sure how to incorporate my dataset with the following sample code: I have a dataset that I need to put into a training (75%) and testing (25%) set. I’m not sure what information I’m supposed to put into the x and size? Is x the dataset file, … Read more

Categories R

Creating box plot on exercise

The error message is telling you the issue: you can’t use only factors to create a box plot. boxplot is looking for a numeric vector. Run code below as an example: see ?boxplot for examples on using formulas in the boxplot function, as that may be what you are looking for? For example:

How Do You Compare Two Strings in R?

It’s pretty simple actually. The output in the first case is FALSE and in the second case it is TRUE. You can use toupper() as well.

Categories R

What is integer overflow in R and how can it happen?

You can answer many of your questions by reading the help page ?integer. It says: R uses 32-bit integers for integer vectors, so the range of representable integers is restricted to about +/-2*10^9. Expanding to larger integers is under consideration by R Core but it’s not going to happen in the near future. If you … Read more

Categories R