I want to use chosen variables in UI.r in Server.r












0















I have a checkboxinput in UI.R using data set downloaded in server.R, but when I try to use set of columns in Server.R my checkboxinput disappear from layout.



Last part of code shows what I've tried to include in reactive



#Server.R
shinyServer(function(input, output) {



# 3 wczytywanie danych
dataIn <- reactive({
inFile <- input$fileInPath

if (is.null(inFile)) {
return(NULL)
}
read.table(file=inFile$datapath,sep=";",dec=",",header=T,stringsAsFactors=FALSE)
})


output$ListOfColumns <- renderUI({
req(dataIn())
columns <- colnames(dataIn())

checkboxGroupInput("Columns", "Choose columns",columns)
})

output$daneIn <- renderTable({
ret <- rbind(
head(dataIn(),5),
tail(dataIn(),5)
)

return(ret)



},include.rownames=FALSE)

#ui.r


shinyUI(fluidPage(
tags$img(src="http://administracja.sgh.waw.pl/pl/dpir/obowiazki/PublishingImages/ksiega2019/SGHherbCMYK.png", width = 150, heigh = 150),

sidebarLayout(

sidebarPanel(
# 2. Przegladarka do pobrania danych
fileInput("fileInPath",
label= h4("Import danych"), accept=("text/csv")),
radioButtons('plott','Plot',c('ggplot2'='ggplot2', 'lattice'='lattice')
),
radioButtons('format', 'Document format', c('PDF', 'HTML', 'Word'),
inline = TRUE),
downloadButton('downloadReport',label="Wygeneruj raport"),
uiOutput("ListOfColumns")

),
mainPanel(

# 5. zakladki wynikiwe
tabsetPanel(type = "tabs",

# 6. wyswietlanie pobranych danych
tabPanel("Table", tableOutput("daneIn"))
))



#What I've tried to add

dataIn <- reactive({
inFile <- input$fileInPath

if (is.null(inFile)) {
return(NULL)
}
d<- read.table(file=inFile$datapath,sep=";",dec=",",header=T,stringsAsFactors=FALSE)
d <- d[c(input$Columns)]
return(d)
})


I expect shiny to use only variables choosen in checkboxinput.
Now checkboxinput stoped to appear (after addding last part of code to reacive)










share|improve this question

























  • You cant have a reactive expression in ui.R

    – Sada93
    Jan 20 at 13:45











  • I have one reactive expression in Server.R, But how in this case I can use a reactive expression in ui.R?

    – Andrzej Lisowski
    Jan 20 at 14:46











  • In the shiny architecture, your server evaluates reactive expressions and the ui.R file is essentially a static HTML file which is served to the user.

    – Sada93
    Jan 21 at 6:53











  • What can in to change it? Really I have now idea how to you reactive expressions in ui.R

    – Andrzej Lisowski
    Jan 21 at 21:51
















0















I have a checkboxinput in UI.R using data set downloaded in server.R, but when I try to use set of columns in Server.R my checkboxinput disappear from layout.



Last part of code shows what I've tried to include in reactive



#Server.R
shinyServer(function(input, output) {



# 3 wczytywanie danych
dataIn <- reactive({
inFile <- input$fileInPath

if (is.null(inFile)) {
return(NULL)
}
read.table(file=inFile$datapath,sep=";",dec=",",header=T,stringsAsFactors=FALSE)
})


output$ListOfColumns <- renderUI({
req(dataIn())
columns <- colnames(dataIn())

checkboxGroupInput("Columns", "Choose columns",columns)
})

output$daneIn <- renderTable({
ret <- rbind(
head(dataIn(),5),
tail(dataIn(),5)
)

return(ret)



},include.rownames=FALSE)

#ui.r


shinyUI(fluidPage(
tags$img(src="http://administracja.sgh.waw.pl/pl/dpir/obowiazki/PublishingImages/ksiega2019/SGHherbCMYK.png", width = 150, heigh = 150),

sidebarLayout(

sidebarPanel(
# 2. Przegladarka do pobrania danych
fileInput("fileInPath",
label= h4("Import danych"), accept=("text/csv")),
radioButtons('plott','Plot',c('ggplot2'='ggplot2', 'lattice'='lattice')
),
radioButtons('format', 'Document format', c('PDF', 'HTML', 'Word'),
inline = TRUE),
downloadButton('downloadReport',label="Wygeneruj raport"),
uiOutput("ListOfColumns")

),
mainPanel(

# 5. zakladki wynikiwe
tabsetPanel(type = "tabs",

# 6. wyswietlanie pobranych danych
tabPanel("Table", tableOutput("daneIn"))
))



#What I've tried to add

dataIn <- reactive({
inFile <- input$fileInPath

if (is.null(inFile)) {
return(NULL)
}
d<- read.table(file=inFile$datapath,sep=";",dec=",",header=T,stringsAsFactors=FALSE)
d <- d[c(input$Columns)]
return(d)
})


I expect shiny to use only variables choosen in checkboxinput.
Now checkboxinput stoped to appear (after addding last part of code to reacive)










share|improve this question

























  • You cant have a reactive expression in ui.R

    – Sada93
    Jan 20 at 13:45











  • I have one reactive expression in Server.R, But how in this case I can use a reactive expression in ui.R?

    – Andrzej Lisowski
    Jan 20 at 14:46











  • In the shiny architecture, your server evaluates reactive expressions and the ui.R file is essentially a static HTML file which is served to the user.

    – Sada93
    Jan 21 at 6:53











  • What can in to change it? Really I have now idea how to you reactive expressions in ui.R

    – Andrzej Lisowski
    Jan 21 at 21:51














0












0








0








I have a checkboxinput in UI.R using data set downloaded in server.R, but when I try to use set of columns in Server.R my checkboxinput disappear from layout.



Last part of code shows what I've tried to include in reactive



#Server.R
shinyServer(function(input, output) {



# 3 wczytywanie danych
dataIn <- reactive({
inFile <- input$fileInPath

if (is.null(inFile)) {
return(NULL)
}
read.table(file=inFile$datapath,sep=";",dec=",",header=T,stringsAsFactors=FALSE)
})


output$ListOfColumns <- renderUI({
req(dataIn())
columns <- colnames(dataIn())

checkboxGroupInput("Columns", "Choose columns",columns)
})

output$daneIn <- renderTable({
ret <- rbind(
head(dataIn(),5),
tail(dataIn(),5)
)

return(ret)



},include.rownames=FALSE)

#ui.r


shinyUI(fluidPage(
tags$img(src="http://administracja.sgh.waw.pl/pl/dpir/obowiazki/PublishingImages/ksiega2019/SGHherbCMYK.png", width = 150, heigh = 150),

sidebarLayout(

sidebarPanel(
# 2. Przegladarka do pobrania danych
fileInput("fileInPath",
label= h4("Import danych"), accept=("text/csv")),
radioButtons('plott','Plot',c('ggplot2'='ggplot2', 'lattice'='lattice')
),
radioButtons('format', 'Document format', c('PDF', 'HTML', 'Word'),
inline = TRUE),
downloadButton('downloadReport',label="Wygeneruj raport"),
uiOutput("ListOfColumns")

),
mainPanel(

# 5. zakladki wynikiwe
tabsetPanel(type = "tabs",

# 6. wyswietlanie pobranych danych
tabPanel("Table", tableOutput("daneIn"))
))



#What I've tried to add

dataIn <- reactive({
inFile <- input$fileInPath

if (is.null(inFile)) {
return(NULL)
}
d<- read.table(file=inFile$datapath,sep=";",dec=",",header=T,stringsAsFactors=FALSE)
d <- d[c(input$Columns)]
return(d)
})


I expect shiny to use only variables choosen in checkboxinput.
Now checkboxinput stoped to appear (after addding last part of code to reacive)










share|improve this question
















I have a checkboxinput in UI.R using data set downloaded in server.R, but when I try to use set of columns in Server.R my checkboxinput disappear from layout.



Last part of code shows what I've tried to include in reactive



#Server.R
shinyServer(function(input, output) {



# 3 wczytywanie danych
dataIn <- reactive({
inFile <- input$fileInPath

if (is.null(inFile)) {
return(NULL)
}
read.table(file=inFile$datapath,sep=";",dec=",",header=T,stringsAsFactors=FALSE)
})


output$ListOfColumns <- renderUI({
req(dataIn())
columns <- colnames(dataIn())

checkboxGroupInput("Columns", "Choose columns",columns)
})

output$daneIn <- renderTable({
ret <- rbind(
head(dataIn(),5),
tail(dataIn(),5)
)

return(ret)



},include.rownames=FALSE)

#ui.r


shinyUI(fluidPage(
tags$img(src="http://administracja.sgh.waw.pl/pl/dpir/obowiazki/PublishingImages/ksiega2019/SGHherbCMYK.png", width = 150, heigh = 150),

sidebarLayout(

sidebarPanel(
# 2. Przegladarka do pobrania danych
fileInput("fileInPath",
label= h4("Import danych"), accept=("text/csv")),
radioButtons('plott','Plot',c('ggplot2'='ggplot2', 'lattice'='lattice')
),
radioButtons('format', 'Document format', c('PDF', 'HTML', 'Word'),
inline = TRUE),
downloadButton('downloadReport',label="Wygeneruj raport"),
uiOutput("ListOfColumns")

),
mainPanel(

# 5. zakladki wynikiwe
tabsetPanel(type = "tabs",

# 6. wyswietlanie pobranych danych
tabPanel("Table", tableOutput("daneIn"))
))



#What I've tried to add

dataIn <- reactive({
inFile <- input$fileInPath

if (is.null(inFile)) {
return(NULL)
}
d<- read.table(file=inFile$datapath,sep=";",dec=",",header=T,stringsAsFactors=FALSE)
d <- d[c(input$Columns)]
return(d)
})


I expect shiny to use only variables choosen in checkboxinput.
Now checkboxinput stoped to appear (after addding last part of code to reacive)







r shiny






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 20 at 12:17









G5W

22.3k92041




22.3k92041










asked Jan 20 at 9:40









Andrzej LisowskiAndrzej Lisowski

13




13













  • You cant have a reactive expression in ui.R

    – Sada93
    Jan 20 at 13:45











  • I have one reactive expression in Server.R, But how in this case I can use a reactive expression in ui.R?

    – Andrzej Lisowski
    Jan 20 at 14:46











  • In the shiny architecture, your server evaluates reactive expressions and the ui.R file is essentially a static HTML file which is served to the user.

    – Sada93
    Jan 21 at 6:53











  • What can in to change it? Really I have now idea how to you reactive expressions in ui.R

    – Andrzej Lisowski
    Jan 21 at 21:51



















  • You cant have a reactive expression in ui.R

    – Sada93
    Jan 20 at 13:45











  • I have one reactive expression in Server.R, But how in this case I can use a reactive expression in ui.R?

    – Andrzej Lisowski
    Jan 20 at 14:46











  • In the shiny architecture, your server evaluates reactive expressions and the ui.R file is essentially a static HTML file which is served to the user.

    – Sada93
    Jan 21 at 6:53











  • What can in to change it? Really I have now idea how to you reactive expressions in ui.R

    – Andrzej Lisowski
    Jan 21 at 21:51

















You cant have a reactive expression in ui.R

– Sada93
Jan 20 at 13:45





You cant have a reactive expression in ui.R

– Sada93
Jan 20 at 13:45













I have one reactive expression in Server.R, But how in this case I can use a reactive expression in ui.R?

– Andrzej Lisowski
Jan 20 at 14:46





I have one reactive expression in Server.R, But how in this case I can use a reactive expression in ui.R?

– Andrzej Lisowski
Jan 20 at 14:46













In the shiny architecture, your server evaluates reactive expressions and the ui.R file is essentially a static HTML file which is served to the user.

– Sada93
Jan 21 at 6:53





In the shiny architecture, your server evaluates reactive expressions and the ui.R file is essentially a static HTML file which is served to the user.

– Sada93
Jan 21 at 6:53













What can in to change it? Really I have now idea how to you reactive expressions in ui.R

– Andrzej Lisowski
Jan 21 at 21:51





What can in to change it? Really I have now idea how to you reactive expressions in ui.R

– Andrzej Lisowski
Jan 21 at 21:51












0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54275184%2fi-want-to-use-chosen-variables-in-ui-r-in-server-r%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54275184%2fi-want-to-use-chosen-variables-in-ui-r-in-server-r%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Callistus III

Plistias Cous

Index Sanctorum