gpt4 book ai didi

r - 分析 Shiny 的服务器日志以创建使用情况统计信息

转载 作者:行者123 更新时间:2023-12-04 04:24:34 26 4
gpt4 key购买 nike

我想弄清楚,我的 Shiny 应用程序的哪个功能最常使用...
这样做的首选方式是什么?
目前,我解析 Shiny 的服务器access.log并可以找到一些链接,例如.../session/69d4f32b3abc77e71097ae4beefbd135/dataobj/lifecycle_table,指示何时加载称为DTlifecycle_table对象。但是我只能在这些DT对象中看到这一点。
有更好的方法吗?
很乐意为每个唯一IP创建此统计信息。基本上是单击哪个选项卡。我对搜索字符串等不感兴趣

最佳答案

编辑:要获取有关单击的选项卡的信息,请查看:?tabsetPanel您会看到可以为面板指定一个ID。
因此,tabsetPanel(id =“tabs”,...)将使您能够通过输入$ tabs在服务器端跟踪所选的tabpanel。

请参见下面的示例:(基于https://shiny.rstudio.com/articles/tabsets.html)

library(shiny)

ui <- shinyUI(pageWithSidebar(

# Application title
headerPanel("Tabsets"),

# Sidebar with controls to select the random distribution type
# and number of observations to generate. Note the use of the br()
# element to introduce extra vertical spacing
sidebarPanel(
radioButtons("dist", "Distribution type:",
list("Normal" = "norm",
"Uniform" = "unif",
"Log-normal" = "lnorm",
"Exponential" = "exp")),
br(),

sliderInput("n",
"Number of observations:",
value = 500,
min = 1,
max = 1000)
),

# Show a tabset that includes a plot, summary, and table view
# of the generated distribution
mainPanel(
tabsetPanel(id = "tabs",
tabPanel("Plot", plotOutput("plot")),
tabPanel("Summary", verbatimTextOutput("summary")),
tabPanel("Visited Tabs", tableOutput("table"))
)
)
))


# Define server logic for random distribution application
server <- shinyServer(function(input, output, session) {
global <- reactiveValues(visitedTabs = c())

# Reactive expression to generate the requested distribution. This is
# called whenever the inputs change. The renderers defined
# below then all use the value computed from this expression
data <- reactive({
dist <- switch(input$dist,
norm = rnorm,
unif = runif,
lnorm = rlnorm,
exp = rexp,
rnorm)

dist(input$n)
})

observe({
input$tabs
isolate({
userTabInfo <- paste0(" selected: ",input$tabs)
print(userTabInfo)
global$visitedTabs = c(global$visitedTabs, userTabInfo)
})
})

# Generate a plot of the data. Also uses the inputs to build the
# plot label. Note that the dependencies on both the inputs and
# the 'data' reactive expression are both tracked, and all expressions
# are called in the sequence implied by the dependency graph
output$plot <- renderPlot({
dist <- input$dist
n <- input$n

hist(data(),
main=paste('r', dist, '(', n, ')', sep=''))
})

# Generate a summary of the data
output$summary <- renderPrint({
str(session$userData)
# session$user
})

# Generate an HTML table view of the data
output$table <- renderTable({
data.frame(global$visitedTabs)
})
})

shinyApp(ui, server)

关于IP:我知道大约有4-5个代码片段可以获取IP,它们都使用JSS或XSS风格,你怎么称呼它:)我同意应该可以,但是由于人们已经在3-4年前问过了,我不确定这确实是 Shiny 团队的知名度问题。希望标签跟踪无论如何都能有所帮助。如果您愿意,我可以添加JS代码段以再次获取IP。

关于r - 分析 Shiny 的服务器日志以创建使用情况统计信息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41718948/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com