Struggling to use ggplot2 functions (ggseasonplot, ggAcf, autoplot)

I am trying to use the functions ggseasonplot, ggAcf, and autoplot to visualize the R dataset USAccDeaths, but nothing is working the way I expect. I installed and loaded the ggplot2 library, but it doesn't allow me to use any of the functions I need. Autoplot runs, but I get the error "Objects of type ts not supported by autoplot.". GGseasonplot and ggAcf aren't even options, and when I try to run them I get the error "could not find function "ggseasonplot"". Same error for ggAcf.
I tried loading ggfortify, which another post suggested might work to solve the autoplot error, but I get the error "package or namespace load failed for ‘ggfortify’ in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]):
there is no package called ‘stringr’
In addition: Warning message:
package ‘ggfortify’ was built under R version 4.0.5"

Any help at all would be highly appreciated.

I have never used the function ggseasonplot or ggAcf but they are part of the forecast package. You will have to install that, if you haven't already, and then run library(forecast). The functions will then be available.

I did try to use the forecast package as well. I installed it, but got the error, "installation of package forecast had non-zero exit status". Then when I try to load it using library(forecast), I get the error "there is no package called forecast"

Can you share the complete console output you get when you run the install command?

install.packages("forecast")

Please post all of the output the results from running install.packages("forecast"). Place a line with three back ticks just before and after the pasted output, like this
```
output of install.packages()
```

also installing the dependencies ‘tseries’, ‘urca’, ‘RcppArmadillo’


  There are binary versions available but the source
  versions are later:
                  binary     source needs_compilation
tseries          0.10-50    0.10-52              TRUE
urca               1.3-0      1.3-3              TRUE
RcppArmadillo 0.11.0.0.0 0.11.4.0.1              TRUE
forecast            8.16       8.18              TRUE

Do you want to install from sources the packages which need compilation? (Yes/no/cancel) 
installing the source packages ‘tseries’, ‘urca’, ‘RcppArmadillo’, ‘forecast’

trying URL 'https://cran.rstudio.com/src/contrib/tseries_0.10-52.tar.gz'
Content type 'application/x-gzip' length 165058 bytes (161 KB)
==================================================
downloaded 161 KB

trying URL 'https://cran.rstudio.com/src/contrib/urca_1.3-3.tar.gz'
Content type 'application/x-gzip' length 682649 bytes (666 KB)
==================================================
downloaded 666 KB

trying URL 'https://cran.rstudio.com/src/contrib/RcppArmadillo_0.11.4.0.1.tar.gz'
Content type 'application/x-gzip' length 1369973 bytes (1.3 MB)
==================================================
downloaded 1.3 MB

trying URL 'https://cran.rstudio.com/src/contrib/forecast_8.18.tar.gz'
Content type 'application/x-gzip' length 588703 bytes (574 KB)
==================================================
downloaded 574 KB

* installing *source* package ‘tseries’ ...
** package ‘tseries’ successfully unpacked and MD5 sums checked
** using staged installation
** libs
clang -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG   -I/usr/local/include   -fPIC  -Wall -g -O2  -c arma.c -o arma.o
clang -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG   -I/usr/local/include   -fPIC  -Wall -g -O2  -c bdstest.c -o bdstest.o
clang -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG   -I/usr/local/include   -fPIC  -Wall -g -O2  -c boot.c -o boot.o
gfortran -mmacosx-version-min=10.13 -fno-optimize-sibling-calls  -fPIC  -Wall -g -O2  -c  cfuncs.f90 -o cfuncs.o
make: gfortran: No such file or directory
make: *** [cfuncs.o] Error 1
ERROR: compilation failed for package ‘tseries’
* removing ‘/Library/Frameworks/R.framework/Versions/4.0/Resources/library/tseries’
Warning in install.packages :
  installation of package ‘tseries’ had non-zero exit status
* installing *source* package ‘urca’ ...
** package ‘urca’ successfully unpacked and MD5 sums checked
** using staged installation
** libs
gfortran -mmacosx-version-min=10.13 -fno-optimize-sibling-calls  -fPIC  -Wall -g -O2  -c UnitRootMacKinnon.f -o UnitRootMacKinnon.o
make: gfortran: No such file or directory
make: *** [UnitRootMacKinnon.o] Error 1
ERROR: compilation failed for package ‘urca’
* removing ‘/Library/Frameworks/R.framework/Versions/4.0/Resources/library/urca’
Warning in install.packages :
  installation of package ‘urca’ had non-zero exit status
* installing *source* package ‘RcppArmadillo’ ...
** package ‘RcppArmadillo’ successfully unpacked and MD5 sums checked
** using staged installation
checking whether the C++ compiler works... yes
checking for C++ compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether the compiler supports GNU C++... yes
checking whether clang++ accepts -g... yes
checking for clang++ option to enable C++11 features... none needed
checking how to run the C++ preprocessor... clang++ -E
checking whether the compiler supports GNU C++... (cached) yes
checking whether clang++ accepts -g... (cached) yes
checking for clang++ option to enable C++11 features... (cached) none needed
checking whether we have a suitable tempdir... /var/folders/rq/w95dvftd5bxc10228wjrp2d00000gn/T
checking whether R CMD SHLIB can already compile programs using OpenMP... no
checking whether g++ version is sufficient... almost
configure: WARNING: Compiler self-identifies as being compliant with GNUC extensions but is not g++.
checking for macOS... found
checking for macOS Apple compiler... not found
checking for clang compiler... found
checking for OpenMP compatible version of clang... not found
configure: WARNING: OpenMP unavailable and turned off.
checking LAPACK_LIBS... R-supplied partial LAPACK found
configure: WARNING: Some complex-valued LAPACK functions may not be available
configure: creating ./config.status
config.status: creating inst/include/RcppArmadilloConfigGenerated.h
config.status: creating src/Makevars
** libs
clang++ -mmacosx-version-min=10.13 -std=gnu++11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG  -I'/Library/Frameworks/R.framework/Versions/4.0/Resources/library/Rcpp/include' -I/usr/local/include  -I../inst/include  -fPIC  -Wall -g -O2  -c RcppArmadillo.cpp -o RcppArmadillo.o
clang++ -mmacosx-version-min=10.13 -std=gnu++11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG  -I'/Library/Frameworks/R.framework/Versions/4.0/Resources/library/Rcpp/include' -I/usr/local/include  -I../inst/include  -fPIC  -Wall -g -O2  -c RcppExports.cpp -o RcppExports.o
clang++ -mmacosx-version-min=10.13 -std=gnu++11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG  -I'/Library/Frameworks/R.framework/Versions/4.0/Resources/library/Rcpp/include' -I/usr/local/include  -I../inst/include  -fPIC  -Wall -g -O2  -c fastLm.cpp -o fastLm.o
clang++ -mmacosx-version-min=10.13 -std=gnu++11 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/Library/Frameworks/R.framework/Resources/lib -L/usr/local/lib -o RcppArmadillo.so RcppArmadillo.o RcppExports.o fastLm.o -L/Library/Frameworks/R.framework/Resources/lib -lRlapack -L/Library/Frameworks/R.framework/Resources/lib -lRblas -L/usr/local/gfortran/lib/gcc/x86_64-apple-darwin18/8.2.0 -L/usr/local/gfortran/lib -lgfortran -lquadmath -lm -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
ld: warning: directory not found for option '-L/usr/local/gfortran/lib/gcc/x86_64-apple-darwin18/8.2.0'
ld: warning: directory not found for option '-L/usr/local/gfortran/lib'
ld: library not found for -lgfortran
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [RcppArmadillo.so] Error 1
ERROR: compilation failed for package ‘RcppArmadillo’
* removing ‘/Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppArmadillo’
Warning in install.packages :
  installation of package ‘RcppArmadillo’ had non-zero exit status
ERROR: dependencies ‘tseries’, ‘urca’, ‘RcppArmadillo’ are not available for package ‘forecast’
* removing ‘/Library/Frameworks/R.framework/Versions/4.0/Resources/library/forecast’
Warning in install.packages :
  installation of package ‘forecast’ had non-zero exit status

The downloaded source packages are in
	‘/private/var/folders/rq/w95dvftd5bxc10228wjrp2d00000gn/T/RtmpvJDgmd/downloaded_packages’

The easiest solution would be to answer "no" to this question, you would get a precompiled binary version that is a little older but much easier to install.
If you need to install the latest version from source, then you need to install Xcode in your system (not in R) and the recommended development tools for macOS systems.
https://mac.r-project.org/tools/

This topic was automatically closed 7 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.