Shiny app scrolling list in fviz_contrib


#1

trying to draw fviz-contrib depending on choice on a scrolling list,
finding this error:
Error in dim == 1 :
comparison (1) is possible only for atomic and list types
Error in dim == 2 :
comparison (1) is possible only for atomic and list types
Error in dim == 3 :
comparison (1) is possible only for atomic and list types
this is the code:
pca=PCA(data,ncp=3, graph=F)
selectInput(“dim”, label = “Point moyen de l’echelle des couleurs”,
choices = c(1,2,3), selected = 1)

if (dim == 1) {a <- fviz_contrib(pca, choice = “var”, axes = 1 )}

if (dim == 2) {(a <- fviz_contrib(pca, choice = “var”, axes = 2 ))}

if (dim == 3 ) {a <- fviz_contrib(pca, choice = “var”, axes = 3 )}

a