principal components decomposition

I´m running the following code in a quarto document

Compute features

tourism_features <- tourism %>%
features(Trips, feature_set(pkgs="feasts"))

pcs <- tourism_features %>%
select(-State, -Region, -Purpose) %>%
prcomp(scale=TRUE) %>%

pcs %>%
ggplot(aes(x=.fittedPC1, y=.fittedPC2, col=Purpose)) +
geom_point() + theme(aspect.ratio=1)

i get this error
**Error in UseMethod("augment") : **
no applicable method for 'augment' applied to an object of class "prcomp"

Referred here by Forecasting: Principles and Practice, by Rob J Hyndman and George Athanasopoulos

This happens when you haven't loaded the appropriate packages. In this case, augment.prcomp is part of the broom package. So you could load that using


But if you copied my post accurately, it would have worked. At the very top of that post, I include the following R chunk.


Although that doesn't load broom explicitly, the tidyverse package will use the relevant broom function when called.

1 Like

Many thanks Dr Rob

I wrongly assumed that fpp3 library would load those packages fully.

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.