【发布时间】:2018-06-26 13:37:50
【问题描述】:
我想对这个链接Identify points within a rectangle in a scatterplot已经解决的问题使用主成分分析。图表显示正确,但我在显示表格时错过了一些东西。如果有人知道问题出在哪里,请帮忙。
代码(编辑):
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)
结果:
【问题讨论】:
-
很遗憾,如果没有
decathlon2数据,将无法重现。
标签: r datatable shiny pca brush