Sfyyhr
January 14, 2023, 2:50pm
1
Hello, I have problems with my R.
I use package fpp3, but whenever I try to plot seasonal data using gg_season or gg_subseries, I always get this error message:
Error in exists(scale_fn, parent.frame(), mode = "function") :
first argument has length > 1
I tried using my own data and data from the textbook (Forecasting: Principles and Practice (3rd ed) ), but I still got the error message.
Could you please help me find the cause of this problem?
Weclone to the frum.
I think we need a see your code and some sample data.
A minimal reproducible example consists of the following items:
A minimal dataset, necessary to reproduce the issue
The minimal runnable code necessary to reproduce the issue, which can be run
on the given dataset, and including the necessary information on the used packages.
Let's quickly go over each one of these with examples:
Minimal Dataset (Sample Data)
You need to provide a data frame that is small enough to be (reasonably) pasted on a post, but big enough to reproduce your issue.
Let's say, as an example, that you are working with the iris data frame
head(iris)
#> Sepal.Length Sepal.Width Petal.Length Petal.Width Species
#> 1 5.1 3.5 1.4 0.…
A handy way to supply some sample data is the dput() function. In the case of a large dataset something like dput(head(mydata, 100)) should supply the data we need. Just do dput(mydata) where mydata is your data. Copy the output and paste it here.
Sfyyhr
January 14, 2023, 4:37pm
3
This is the code where I can't get the output. It is from the textbook.
library(fpp3)
a10 <- PBS %>%
filter(ATC2 == "A10") %>%
select(Month, Concession, Type, Cost) %>%
summarise(TotalC = sum(Cost)) %>%
mutate(Cost = TotalC / 1e6)
a10 %>%
gg_season(Cost, labels = "both") +
labs(y = " (millions)",
title = "Seasonal plot: Antidiabetic drug sales")
a10 %>%
gg_subseries(Cost) +
labs(
y = " (millions)",
title = "Australian antidiabetic drug sales"
)
Please make a reprex and supply sample data. Please include any error messages.
Your code at the moment is essentially unreadable and there is no sample data.
PBS is a data set in the tsibbledata package, which is loaded by library(fpp3)
Everything works fine for me up to labs(y = "
. There are problems in the next line.
library(fpp3)
a10 <- PBS %>%
filter(ATC2 == "A10") %>%
select(Month, Concession, Type, Cost) %>%
summarise(TotalC = sum(Cost)) %>%
mutate(Cost = TotalC / 1e6)
a10 %>% gg_season(Cost, labels = "both") +
labs(y = "(millions)", title = "Seasonal plot: Antidiabetic drug sales")
a10 %>% gg_subseries(Cost) +
labs(y = "(millions)", title = "Australian antidiabetic drug sales")
Created on 2023-01-14 with reprex v2.0.2
Sfyyhr
January 15, 2023, 9:07am
6
Yes, this is what I should get but my R always give this error message:
Error in exists(scale_fn, parent.frame(), mode = "function") :
first argument has length > 1
I tried to run the code using other laptop and it works fine. My friends also can run it in their laptop. Is this problem happened because of my laptop? Is there any ways to fix it?
I do not know enough to figure out the cause of the problem based on the error message.
Do you have the same version of R that is on the other computers? If yours is older you should probably update.
Have you tried reinstalling the {feasts} package?
Those two functions probably use {ggplot2}, so try reinstalling that package as well.
Sorry that I cannot be of more help. Good luck!
system
Closed
February 5, 2023, 6:56pm
8
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.