pathos
July 30, 2021, 6:18am
1
There are various threads about uploaded data but with given columns like this thread:
Hello I want to find the correlation coefficient of two columns of my dataset. If I use cor(subset(iris, select=c("Sepal.Length")),subset(iris, select=c("Sepal.Width")))
the correlation is being found but I cannot subset with my actual dataset which comes as a CSV file input and is in a reactive expression.
cor(subset(rt(), select=c("Sepal.Length")),subset(rt(), select=c("Sepal.Width")))
So how could I subset a data frame of this reactive form?
rt<-reactive({
req(input$file1)
csvdata <- read.csv(input$file1$datapath,
header = input$header
)
csvdata
})
I put my whole code if that helps understand the question
#ui.r
library(shiny)
library(ggplot2)
l…
How can I call the column name of user-selected column that doesn't have a given column name? Let's say the column name is saved as input$user_selected
. I can't call the column by using df()$input$user_selected
or df$input$user_selected
so I was wondering how this can be done.
An example for you
library(shiny)
ui <- fluidPage(
uiOutput("u_selector"),
p("first 10 values are : "),
verbatimTextOutput("result")
)
server <- function(input, output, session) {
df <- reactive(iris)
output$u_selector <- renderUI({
df_local <- req(df())
selectInput("user_selected","make a selection",
choices=names(df_local),
selected = names(df_local)[[1]])
})
output$result <- renderText({
df_local <- req(df())
u_sel <- req(input$user_selected)
dfh <- head(df_local,n=10)
dfh[[u_sel]]
})
}
shinyApp(ui, server)
system
Closed
August 6, 2021, 11:07am
3
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed. If you have a query related to it or one of the replies, start a new topic and refer back with a link.