Expanding biplot scale in factoextra package

274 views Asked by At

I am trying to plot a PCA model in r using "fviz_pca_biplot" from the factoextra package. But I'm having problems making the plot big enough to show all the vectors. Any help is welcomed.

I am using this code:

#install.packages("FactoMineR")
library("FactoMineR")
res.pca.can <- PCA(Cannabis, scale= TRUE)

#install("factoextra")
library("factoextra")
factoextra::fviz_pca_biplot(res.pca.can, axes = c(1, 2), col.ind = "black", col.var = "steelblue",repel = TRUE, select.var = list(contrib = 5),  title = "Cannabis PCA - Biplot")

And this is the biplot that's coming up: Biplot

I am using this data set:Substance_Use

From which I subsetted the variables I needed:

Alcohol <- subset(Substance_Use[10:26])
Cannabis <- subset(Substance_Use[27:42])
Pandemic_Attitudes <- subset(Substance_Use[2:9])
Demographics <- subset(Substance_Use[43:50])

And the output is:

> dput(head(Cannabis))
structure(list(CAN_05 = c(1, 8, 3, 2, 8, 1), CAN_15 = c(6, 4, 
1, 4, 4, 6), CAN_10 = c(6, 1, 1, 1, 4, 6), CAN_20A = c(6, 6, 
2, 6, 6, 6), CAN_20B = c(6, 6, 2, 6, 6, 6), CAN_20C = c(6, 6, 
2, 6, 6, 6), CAN_20D = c(6, 6, 2, 6, 6, 6), CAN_20E = c(6, 6, 
2, 6, 6, 6), CAN_20F = c(6, 6, 2, 6, 6, 6), CAN_20G = c(6, 6, 
2, 6, 6, 6), CAN_20H = c(6, 6, 1, 6, 6, 6), CAN_20I = c(6, 6, 
2, 6, 6, 6), CAN25AGH = c(6, 6, 6, 6, 6, 6), CAN_25BF = c(6, 
6, 6, 6, 6, 6), CAN_25CD = c(6, 6, 6, 6, 6, 6), CAN_25E = c(6, 
6, 6, 6, 6, 6)), row.names = c(NA, -6L), class = c("tbl_df", 
"tbl", "data.frame"))
0

There are 0 answers