I would like to use the principal component analysis for the problem that has been solved at this link Identify points within a rectangle in a scatterplot. The chart displays correctly, but I miss something in displaying the table. If anyone knew where the problem is, please help.
Code (EDIT):
head(decathlon2.active[, 1:6], 4)
## X100m Long.jump Shot.put High.jump X400m X110m.hurdle
## SEBRLE 11.0 7.58 14.8 2.07 49.8 14.7
## CLAY 10.8 7.40 14.3 1.86 49.4 14.1
## BERNARD 11.0 7.23 14.2 1.92 48.9 15.0
## YURKOV 11.3 7.09 15.2 2.10 50.4 15.3
#################################################################
library(shiny)
library(DT)
server <- function(input, output) {
output$plot1 <- renderPlot({
data(decathlon2)
decathlon2.active <- decathlon2[1:23, 1:10]
head(decathlon2.active[, 1:6], 4)
res.pca <- PCA(decathlon2.active, graph = FALSE)
fviz_pca_ind(res.pca)
})
df <- reactive({
res.pca$ind$coord
})
output$plotui <- renderUI({
plotOutput("plot1", height=300,
brush = brushOpts(id = "plot_brush")
)
})
output$plot_brushed_points <- renderDataTable({
res <- brushedPoints(df(), input$plot_brush)
datatable(res)
})
}
ui <- fluidPage(
uiOutput("plotui"),
dataTableOutput("plot_brushed_points")
)
shinyApp(ui = ui, server = server)
Result: