How do I use the NULL Value as a variable call in R Shiny
How do I pass NULL as a Variable Value in RSHINY?
In phyloseq, there is a plot called plot_net.
The most basic plot_net plot code looks like this:
data(enterotype)
#Eliminate samples with no entereotype denomination
enterotype = subset_samples(enterotype, !is.na(Enterotype))
plot_net(enterotype, maxdist = 0.1, point_label = NULL)
I am trying to create an RShiny app which allows a user to alter this graphic.
point_label has several different options (ex: "SecTech", "SampleID", NULL).
I already have all of the other values for this label, I am just not sure how to add NULL.
Here is what I did:
This might not run since it isn't in a shiny app but I included it as an example to illustrate the issue.
library(shiny)
library(phyloseq)
# Data: This data contains info about nodes and edges on Phyloseq data.
data(enterotype)
#Eliminate samples with no entereotype denomination. Make it a lesson to
always catalogue data correctly from the start.
enterotype = subset_samples(enterotype, !is.na(Enterotype))
# a is the collection of variable names for point_label
a <- sample_variables(enterotype)
theme_set(theme_bw())
# Define UI for application that draws a network plot
shinyUI(fluidPage(
# Application title
titlePanel("Network Plots"),
sidebarLayout(
sidebarPanel(
selectInput("labelBy",
"Select the point label category",
***choices = c(a, "NA" = NULL),***
selected = "NA")
),
# Show a plot of the generated distribution
mainPanel(
plotOutput("netPlot")#,
#plotOutput("networkPlot")
)
)
))
shinyServer(function(input, output)
output$netPlot <- renderPlot(
plot_net(enterotype, maxdist = .1, point_label = input$labelBy)
)
)
shinyApp(ui = ui, server = server)
This line is my question:
choices = c(a, "NA" = NULL)
How do I add NULL to my list of choices. No matter how I tried it, NULL was always taken as a zero value and it does not appear as an option.
If I write NULL as "NULL', the phyloseq function plot_net doesn't take it.
It only takes the value point_label = NULL for no value.
I think that it is possible to create an if... else loop where if a user clicks NULL on a checkboxInput then the plot will be generated by a second line of code specifying that the value in point_label is NULL, but that can be really cumbersome if there are several variables with a possible NULL Value.
There probably is some obvious trick like placing a $ or % in front of the NULL value but I couldn't find it. If anyone could help it would be great!
r shiny null phyloseq
add a comment |
How do I pass NULL as a Variable Value in RSHINY?
In phyloseq, there is a plot called plot_net.
The most basic plot_net plot code looks like this:
data(enterotype)
#Eliminate samples with no entereotype denomination
enterotype = subset_samples(enterotype, !is.na(Enterotype))
plot_net(enterotype, maxdist = 0.1, point_label = NULL)
I am trying to create an RShiny app which allows a user to alter this graphic.
point_label has several different options (ex: "SecTech", "SampleID", NULL).
I already have all of the other values for this label, I am just not sure how to add NULL.
Here is what I did:
This might not run since it isn't in a shiny app but I included it as an example to illustrate the issue.
library(shiny)
library(phyloseq)
# Data: This data contains info about nodes and edges on Phyloseq data.
data(enterotype)
#Eliminate samples with no entereotype denomination. Make it a lesson to
always catalogue data correctly from the start.
enterotype = subset_samples(enterotype, !is.na(Enterotype))
# a is the collection of variable names for point_label
a <- sample_variables(enterotype)
theme_set(theme_bw())
# Define UI for application that draws a network plot
shinyUI(fluidPage(
# Application title
titlePanel("Network Plots"),
sidebarLayout(
sidebarPanel(
selectInput("labelBy",
"Select the point label category",
***choices = c(a, "NA" = NULL),***
selected = "NA")
),
# Show a plot of the generated distribution
mainPanel(
plotOutput("netPlot")#,
#plotOutput("networkPlot")
)
)
))
shinyServer(function(input, output)
output$netPlot <- renderPlot(
plot_net(enterotype, maxdist = .1, point_label = input$labelBy)
)
)
shinyApp(ui = ui, server = server)
This line is my question:
choices = c(a, "NA" = NULL)
How do I add NULL to my list of choices. No matter how I tried it, NULL was always taken as a zero value and it does not appear as an option.
If I write NULL as "NULL', the phyloseq function plot_net doesn't take it.
It only takes the value point_label = NULL for no value.
I think that it is possible to create an if... else loop where if a user clicks NULL on a checkboxInput then the plot will be generated by a second line of code specifying that the value in point_label is NULL, but that can be really cumbersome if there are several variables with a possible NULL Value.
There probably is some obvious trick like placing a $ or % in front of the NULL value but I couldn't find it. If anyone could help it would be great!
r shiny null phyloseq
add a comment |
How do I pass NULL as a Variable Value in RSHINY?
In phyloseq, there is a plot called plot_net.
The most basic plot_net plot code looks like this:
data(enterotype)
#Eliminate samples with no entereotype denomination
enterotype = subset_samples(enterotype, !is.na(Enterotype))
plot_net(enterotype, maxdist = 0.1, point_label = NULL)
I am trying to create an RShiny app which allows a user to alter this graphic.
point_label has several different options (ex: "SecTech", "SampleID", NULL).
I already have all of the other values for this label, I am just not sure how to add NULL.
Here is what I did:
This might not run since it isn't in a shiny app but I included it as an example to illustrate the issue.
library(shiny)
library(phyloseq)
# Data: This data contains info about nodes and edges on Phyloseq data.
data(enterotype)
#Eliminate samples with no entereotype denomination. Make it a lesson to
always catalogue data correctly from the start.
enterotype = subset_samples(enterotype, !is.na(Enterotype))
# a is the collection of variable names for point_label
a <- sample_variables(enterotype)
theme_set(theme_bw())
# Define UI for application that draws a network plot
shinyUI(fluidPage(
# Application title
titlePanel("Network Plots"),
sidebarLayout(
sidebarPanel(
selectInput("labelBy",
"Select the point label category",
***choices = c(a, "NA" = NULL),***
selected = "NA")
),
# Show a plot of the generated distribution
mainPanel(
plotOutput("netPlot")#,
#plotOutput("networkPlot")
)
)
))
shinyServer(function(input, output)
output$netPlot <- renderPlot(
plot_net(enterotype, maxdist = .1, point_label = input$labelBy)
)
)
shinyApp(ui = ui, server = server)
This line is my question:
choices = c(a, "NA" = NULL)
How do I add NULL to my list of choices. No matter how I tried it, NULL was always taken as a zero value and it does not appear as an option.
If I write NULL as "NULL', the phyloseq function plot_net doesn't take it.
It only takes the value point_label = NULL for no value.
I think that it is possible to create an if... else loop where if a user clicks NULL on a checkboxInput then the plot will be generated by a second line of code specifying that the value in point_label is NULL, but that can be really cumbersome if there are several variables with a possible NULL Value.
There probably is some obvious trick like placing a $ or % in front of the NULL value but I couldn't find it. If anyone could help it would be great!
r shiny null phyloseq
How do I pass NULL as a Variable Value in RSHINY?
In phyloseq, there is a plot called plot_net.
The most basic plot_net plot code looks like this:
data(enterotype)
#Eliminate samples with no entereotype denomination
enterotype = subset_samples(enterotype, !is.na(Enterotype))
plot_net(enterotype, maxdist = 0.1, point_label = NULL)
I am trying to create an RShiny app which allows a user to alter this graphic.
point_label has several different options (ex: "SecTech", "SampleID", NULL).
I already have all of the other values for this label, I am just not sure how to add NULL.
Here is what I did:
This might not run since it isn't in a shiny app but I included it as an example to illustrate the issue.
library(shiny)
library(phyloseq)
# Data: This data contains info about nodes and edges on Phyloseq data.
data(enterotype)
#Eliminate samples with no entereotype denomination. Make it a lesson to
always catalogue data correctly from the start.
enterotype = subset_samples(enterotype, !is.na(Enterotype))
# a is the collection of variable names for point_label
a <- sample_variables(enterotype)
theme_set(theme_bw())
# Define UI for application that draws a network plot
shinyUI(fluidPage(
# Application title
titlePanel("Network Plots"),
sidebarLayout(
sidebarPanel(
selectInput("labelBy",
"Select the point label category",
***choices = c(a, "NA" = NULL),***
selected = "NA")
),
# Show a plot of the generated distribution
mainPanel(
plotOutput("netPlot")#,
#plotOutput("networkPlot")
)
)
))
shinyServer(function(input, output)
output$netPlot <- renderPlot(
plot_net(enterotype, maxdist = .1, point_label = input$labelBy)
)
)
shinyApp(ui = ui, server = server)
This line is my question:
choices = c(a, "NA" = NULL)
How do I add NULL to my list of choices. No matter how I tried it, NULL was always taken as a zero value and it does not appear as an option.
If I write NULL as "NULL', the phyloseq function plot_net doesn't take it.
It only takes the value point_label = NULL for no value.
I think that it is possible to create an if... else loop where if a user clicks NULL on a checkboxInput then the plot will be generated by a second line of code specifying that the value in point_label is NULL, but that can be really cumbersome if there are several variables with a possible NULL Value.
There probably is some obvious trick like placing a $ or % in front of the NULL value but I couldn't find it. If anyone could help it would be great!
r shiny null phyloseq
r shiny null phyloseq
asked Nov 12 '18 at 22:40
Ariel AAriel A
356
356
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
I don't think there is a way to use NULL
in selectInput
. Here's an alternative which you almost worked out - Use "None"
(or any other replacement value) in selectInput
and switch it with NULL
while plotting. This way you don't have to write multiple if...else
.
# update on UI side
selectInput("labelBy",
"Select the point label category",
choices = c("None", a),
selected = "None")
# update on server side
output$netPlot <- renderPlot(
point_labels <- switch(input$labelBy, "None" = NULL, input$labelBy)
plot_net(enterotype, maxdist = .1, point_label = point_labels)
)
This doesn't really seem to solve my issue. Even if none is encoded in the server, there is no real way to change it on the user end (unless there is a way to make it the default choice). In that vein, how do I make "None" the standard value in the server if there is no way to change it on front end? Thank you!
– Ariel A
Nov 12 '18 at 23:42
1
Do you mean this doesn't work because the user will seeNone
instead ofNULL
when using the app?
– Qwfqwf
Nov 12 '18 at 23:50
No. When I put it into the server file, it doesn't appear as an option for the User on the UI. I also tried putting it in UI with command c(a, "None" = NULL) but that was also to no avail.
– Ariel A
Nov 12 '18 at 23:55
1
@ArielA updated the answer. Let me know if that's what you are looking for.
– Shree
Nov 13 '18 at 0:08
Beautiful! Thank you for all of your help!
– Ariel A
Nov 13 '18 at 0:44
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53271132%2fhow-do-i-use-the-null-value-as-a-variable-call-in-r-shiny%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
I don't think there is a way to use NULL
in selectInput
. Here's an alternative which you almost worked out - Use "None"
(or any other replacement value) in selectInput
and switch it with NULL
while plotting. This way you don't have to write multiple if...else
.
# update on UI side
selectInput("labelBy",
"Select the point label category",
choices = c("None", a),
selected = "None")
# update on server side
output$netPlot <- renderPlot(
point_labels <- switch(input$labelBy, "None" = NULL, input$labelBy)
plot_net(enterotype, maxdist = .1, point_label = point_labels)
)
This doesn't really seem to solve my issue. Even if none is encoded in the server, there is no real way to change it on the user end (unless there is a way to make it the default choice). In that vein, how do I make "None" the standard value in the server if there is no way to change it on front end? Thank you!
– Ariel A
Nov 12 '18 at 23:42
1
Do you mean this doesn't work because the user will seeNone
instead ofNULL
when using the app?
– Qwfqwf
Nov 12 '18 at 23:50
No. When I put it into the server file, it doesn't appear as an option for the User on the UI. I also tried putting it in UI with command c(a, "None" = NULL) but that was also to no avail.
– Ariel A
Nov 12 '18 at 23:55
1
@ArielA updated the answer. Let me know if that's what you are looking for.
– Shree
Nov 13 '18 at 0:08
Beautiful! Thank you for all of your help!
– Ariel A
Nov 13 '18 at 0:44
add a comment |
I don't think there is a way to use NULL
in selectInput
. Here's an alternative which you almost worked out - Use "None"
(or any other replacement value) in selectInput
and switch it with NULL
while plotting. This way you don't have to write multiple if...else
.
# update on UI side
selectInput("labelBy",
"Select the point label category",
choices = c("None", a),
selected = "None")
# update on server side
output$netPlot <- renderPlot(
point_labels <- switch(input$labelBy, "None" = NULL, input$labelBy)
plot_net(enterotype, maxdist = .1, point_label = point_labels)
)
This doesn't really seem to solve my issue. Even if none is encoded in the server, there is no real way to change it on the user end (unless there is a way to make it the default choice). In that vein, how do I make "None" the standard value in the server if there is no way to change it on front end? Thank you!
– Ariel A
Nov 12 '18 at 23:42
1
Do you mean this doesn't work because the user will seeNone
instead ofNULL
when using the app?
– Qwfqwf
Nov 12 '18 at 23:50
No. When I put it into the server file, it doesn't appear as an option for the User on the UI. I also tried putting it in UI with command c(a, "None" = NULL) but that was also to no avail.
– Ariel A
Nov 12 '18 at 23:55
1
@ArielA updated the answer. Let me know if that's what you are looking for.
– Shree
Nov 13 '18 at 0:08
Beautiful! Thank you for all of your help!
– Ariel A
Nov 13 '18 at 0:44
add a comment |
I don't think there is a way to use NULL
in selectInput
. Here's an alternative which you almost worked out - Use "None"
(or any other replacement value) in selectInput
and switch it with NULL
while plotting. This way you don't have to write multiple if...else
.
# update on UI side
selectInput("labelBy",
"Select the point label category",
choices = c("None", a),
selected = "None")
# update on server side
output$netPlot <- renderPlot(
point_labels <- switch(input$labelBy, "None" = NULL, input$labelBy)
plot_net(enterotype, maxdist = .1, point_label = point_labels)
)
I don't think there is a way to use NULL
in selectInput
. Here's an alternative which you almost worked out - Use "None"
(or any other replacement value) in selectInput
and switch it with NULL
while plotting. This way you don't have to write multiple if...else
.
# update on UI side
selectInput("labelBy",
"Select the point label category",
choices = c("None", a),
selected = "None")
# update on server side
output$netPlot <- renderPlot(
point_labels <- switch(input$labelBy, "None" = NULL, input$labelBy)
plot_net(enterotype, maxdist = .1, point_label = point_labels)
)
edited Nov 13 '18 at 0:07
answered Nov 12 '18 at 23:20
ShreeShree
3,3111323
3,3111323
This doesn't really seem to solve my issue. Even if none is encoded in the server, there is no real way to change it on the user end (unless there is a way to make it the default choice). In that vein, how do I make "None" the standard value in the server if there is no way to change it on front end? Thank you!
– Ariel A
Nov 12 '18 at 23:42
1
Do you mean this doesn't work because the user will seeNone
instead ofNULL
when using the app?
– Qwfqwf
Nov 12 '18 at 23:50
No. When I put it into the server file, it doesn't appear as an option for the User on the UI. I also tried putting it in UI with command c(a, "None" = NULL) but that was also to no avail.
– Ariel A
Nov 12 '18 at 23:55
1
@ArielA updated the answer. Let me know if that's what you are looking for.
– Shree
Nov 13 '18 at 0:08
Beautiful! Thank you for all of your help!
– Ariel A
Nov 13 '18 at 0:44
add a comment |
This doesn't really seem to solve my issue. Even if none is encoded in the server, there is no real way to change it on the user end (unless there is a way to make it the default choice). In that vein, how do I make "None" the standard value in the server if there is no way to change it on front end? Thank you!
– Ariel A
Nov 12 '18 at 23:42
1
Do you mean this doesn't work because the user will seeNone
instead ofNULL
when using the app?
– Qwfqwf
Nov 12 '18 at 23:50
No. When I put it into the server file, it doesn't appear as an option for the User on the UI. I also tried putting it in UI with command c(a, "None" = NULL) but that was also to no avail.
– Ariel A
Nov 12 '18 at 23:55
1
@ArielA updated the answer. Let me know if that's what you are looking for.
– Shree
Nov 13 '18 at 0:08
Beautiful! Thank you for all of your help!
– Ariel A
Nov 13 '18 at 0:44
This doesn't really seem to solve my issue. Even if none is encoded in the server, there is no real way to change it on the user end (unless there is a way to make it the default choice). In that vein, how do I make "None" the standard value in the server if there is no way to change it on front end? Thank you!
– Ariel A
Nov 12 '18 at 23:42
This doesn't really seem to solve my issue. Even if none is encoded in the server, there is no real way to change it on the user end (unless there is a way to make it the default choice). In that vein, how do I make "None" the standard value in the server if there is no way to change it on front end? Thank you!
– Ariel A
Nov 12 '18 at 23:42
1
1
Do you mean this doesn't work because the user will see
None
instead of NULL
when using the app?– Qwfqwf
Nov 12 '18 at 23:50
Do you mean this doesn't work because the user will see
None
instead of NULL
when using the app?– Qwfqwf
Nov 12 '18 at 23:50
No. When I put it into the server file, it doesn't appear as an option for the User on the UI. I also tried putting it in UI with command c(a, "None" = NULL) but that was also to no avail.
– Ariel A
Nov 12 '18 at 23:55
No. When I put it into the server file, it doesn't appear as an option for the User on the UI. I also tried putting it in UI with command c(a, "None" = NULL) but that was also to no avail.
– Ariel A
Nov 12 '18 at 23:55
1
1
@ArielA updated the answer. Let me know if that's what you are looking for.
– Shree
Nov 13 '18 at 0:08
@ArielA updated the answer. Let me know if that's what you are looking for.
– Shree
Nov 13 '18 at 0:08
Beautiful! Thank you for all of your help!
– Ariel A
Nov 13 '18 at 0:44
Beautiful! Thank you for all of your help!
– Ariel A
Nov 13 '18 at 0:44
add a comment |
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.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- 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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53271132%2fhow-do-i-use-the-null-value-as-a-variable-call-in-r-shiny%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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