navbar of shiny app interferes with navbar of rmarkdown webpage
I am starting a webpage for my lab, and among the products we have developed is a shiny app to check the global climate change.
Here is the website in that page and this is how the app looks standalone as you can see in the menu there are three options that are not seen in the website, in the intro tab, the Intro, Workflow, About and Changelog should be visible
Website yaml
I made a webpage using classic rmarkdown website building, so my webpage yaml looks like this:
name: "Sitio web de ecoinformática del laboratorio Marquet"
navbar:
title: "Ecoinformática"
left:
- text: "Home"
href: index.html
- text: "Sobre nosotros"
href: about.html
- text: "GCM compareR app"
href: GCMcompareR.html
- text: Docencia
icon: fa-gear
menu:
- text: Ecología BIO231c
- text: Modulo 1.1
href: Modulo1.1.html
- text: Modulo 1.2
href: Modulo1.2.html
- text: RPackages
icon: fa-gear
menu:
- text: RPackages
- text: NetworkExtinction
href: VignetteNetworkExt.html
output_dir: "."
output:
html_document:
theme: cosmo
highlight: textmate
include:
css: styles.css
Actual app Rmd
And in the tab of GCM compareR app I have the following:
---
title: ""
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
<iframe src="http://admin.ecoinformatica.net/shiny/rstudio/sample-apps/GCM/"style="border: 0; position:absolute; top:0; left:0; right:0; bottom:0; width:100%; height:100%"">
Solutions that might work but cant figure out
- Add a padding on the top to prevent both navbars to generate conflicts
- Remove the navbar of the website when I go to the app webpage
- Make the navbar of de website "deployable", so that it only appears when I move the cursor to the edge of the webpage
- change the navbar of the webpage to the left.
What I have tried:
Changing the borders :
<iframe src="http://admin.ecoinformatica.net/shiny/rstudio/sample-apps/GCM/"style="border: 100; position:absolute; top:100; left:0; right:0; bottom:0; width:100%; height:100%"">
make the app responsive
<div class="resp-container">
<iframe class="resp-iframe" src="http://admin.ecoinformatica.net/shiny/rstudio/sample-apps/GCM/" style="border: 100; position:absolute; top:100; left:0; right:0; bottom:0; width:100%; height:100%"">
use include_app
```{r}
knitr::include_app("http://admin.ecoinformatica.net/shiny/rstudio/sample-apps/GCM/", height = "600px")
```
Which kind of works, but I can't fix the width
Any help would be welcome
See also questions close to this topic
-
How to delete div and all element inside div? Javascript, html, css
I have a function that clears the entire div and it disappears but still appears in the inspect (html). This is a real problem because we have this input type field on the email and I got this empty data in email. I only want when this value is not chosen to completely remove me from html and inspect. Look at my code and try to catch the error. The most important things in the whole code that you need to pay attention are
onchange="checkSelected()"
in html and first script tag which manipulate with that. It should simply become a display none but it still stands there.<div class="modal fade" id="montageModal" tabindex="-1" role="dialog"> <div class="modal-dialog" role="document"> <div class="modal-content" style="display: flex;"> <div class="modal-body"> <form id="schedule_form" class="clearfix" action="index.php?route=api/reifenmontage" method="post"> <div class="container-fluid"> <div class="step_1" > <h3 class="modal-title">Reifenmontage Termin buchen </h3> <div class="row termin_row"> <div class="col-xs-12 col-sm-4"> <div class="row"> <label>Pneu-Typ</label> </div> </div> <div class="col-xs-12 col-sm-6"> <div class="row"> <select onchange="checkSelected()" class="form-control" name="pneu" id="pneu"> <option value="Motorrad">Motorrad</option> <option value="Auto">Auto</option> </select> </div> </div> </div> <div id="additionalRow" class="row termin_row" > <div id="reifenmontage-input" class="row termin_row"> <div class="col-xs-12 col-sm-4"> <div class="row"> <label>Mark und model</label> </div> </div> <div class="col-xs-12 col-sm-4"> <div class="row"> <select name="marka" class="form-control" id="button-getdata"> </select> </div> </div> <div class="col-xs-12 col-sm-4"> <div class="row"> <select name="model" class="form-control" id="result" > </select> </div> </div> </div> </div> <div class="row termin_row"> <div class="col-sm-4 col-xs-12"> <div class="row"><label>2. Terminvorschlag</label></div> </div> <div class="col-sm-4 col-xs-6"> <div class="row"> <div class="input-group date" id="date-2" data-termin="1"> <input type='text' class="form-control" name="date[1]" /> <span class="input-group-addon">um</span> </div> </div> </div> <div class="col-sm-4 col-xs-6"> <div class="row"> <div class="input-group time" id="time-2" data-termin="1"> <input type='text' class="form-control" name="time[1]" /> <span class="input-group-addon">Uhr</span> </div> </div> </div> </div> <div class="row"> <div class="checkbox"> <label> <input type="checkbox" name="accept" id="accept"> Ich akzeptiere die <a href="teilnahmebedingungen" target="_blank">Teilnahmebedingungen</a> </label> </div> </div> <div class="row text-center"> <button type="button" class="btn btn-primary btn-lg btn-submit" id="next_step" disabled="disabled">Anfrage senden</button> </div> </div> <div class="step_2"> <h3 class="modal-title">Your contact info</h3> <div class=""> <div class="form-group clearfix"> <input type="text" name="name" value="<?= $user['name'] ?>" placeholder="Name and Lastname" class="form-control name text" required /> </div> <div class="form-group clearfix"> <input type="text" name="phone" value="<?= $user['phone'] ?>" placeholder="Phone" class="form-control phone text" required /> </div> <div class="form-group clearfix"> <input type="email" name="email" value="<?= $user['email'] ?>" placeholder="Email" class="form-control email text" required /> </div> <div class="text-center"> <button type="submit" id="submit" class="btn btn-default btn-lg btn-submit" >Suchen</button> </div> </div> </div> </div> </form> </div> <div class="modal-footer"> <button type="button" class="close" data-dismiss="modal" aria-label="Close">SCHLIESSEN</button> </div> </div> </div> </div>
and my script tag
<script type="text/javascript"> let selectItem = document.getElementById('pneu'); let additionalRow = document.getElementById('additionalRow'); function checkSelected() { if (selectItem.selectedIndex == "1") { additionalRow.style.display = 'none'; } else { additionalRow.style.display = 'block'; } } </script> <script type="text/javascript"> $('#button-getdata').on('change', function() { $.ajax({ url: 'index.php?route=api/reifenmontage/get_marka_data', type: 'post', data: $('#reifenmontage-input select'), dataType: 'json', beforeSend: function() { }, success: function(json) { if (json['success']) { $("#result").empty(); for (i in json['success']) { var element = json['success'][i]; var o = new Option(element['model'], element['model']); $("#result").append(o); html = "\t<option value=\""+ element['model'] + "\">" + element['model'] + "</option>\n"; $("#result").append(o); } // document.getElementById("schedule_form").reset(); } } }); }); </script> <script type="text/javascript"> $.ajax({ url: 'index.php?route=api/reifenmontage/mark', context: document.body, success: function(data) { const selectControl = $('#button-getdata'); selectControl.html(data.map(ExtractData).join('')); } }); function ExtractData(item) { return ` <option value="${item.value}">${item.label}</option>`; } </script>
-
How can i get my table values from html to servlet?
I need to get my html table values in my servlet
Hi,
Im doing a project during my acadamic courses about sudoku website.
During my project I have encounterd a problem that I can't slove - get my table html values into my servlet. I have tried doing things like set hidden names and getParameterValues but none of them worked.
this is my html table
<table class="center"> <% int n =9; for(int s = 0; s<n; s++){ %> <tr> <% for(int f=0; f<n; f++) { %> <td><% int z = SF[s][f]; if(z==0) {%> <input type="text"> <% } else { %> <%=SF[s][f]%> <%}%> </td hidden name="z"> <% } %> </tr hidden name="z"> <% } %> </table>
and this is my empty servlet
package View; import org.omg.CORBA.SystemException; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.io.PrintWriter; @WebServlet(name = "CheckSudokuServlet",urlPatterns = "/CheckSudokuServlet") public class CheckSudokuServlet extends HttpServlet { protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { PrintWriter out = response.getWriter(); //tried - String td[]=request.getParameterValues("z"); } protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { } }
-
Cakephp 3.6.14: Display html formatted text in text field
I have a form with some text fields, I want to know if it is possible to display HTML formatted text in an editable text field.
This is the field:
echo $this->Form->control('instructions');
How I can display it HTML formatted? Do I need a
WYSIWYG Plugin
or there is another way? -
How can I use foreach function well?
I would like to use
foreach()
function in R.Here's my example code.
library(randomForestSRC) library(dplyr) library(ROCR) library(doParallel) data(pbc, package="randomForestSRC") data_na <- na.omit(pbc) data_na <- data_na %>% dplyr::select(-days) foreach(VAR=age) %do% { data_na <- data_na %>% mutate(Q4 = ifelse(data_na[,"VAR"]<=unname(quantile(data_na[,"VAR"], 0.25)), 0, ifelse(data_na[,"VAR"]<=unname(quantile(data_na[,"VAR"], 0.50)), 1, ifelse(data_na[,"VAR"]<=unname(quantile(data_na[,"VAR"], 0.75)), 2, 3)))) }
Without modifying the whole code, I want to change the code
foreach(VAR=age) or foreach(VAR=bili)..
. etc.But in the error message, this code consider
"age"
as an object.How can I run this code without error?
-
How to include a GIF in r-shiny
I try to include a
GIF
from my local folder to anr-shiny
app (runtime:shiny
) yet I have failed to find any solution or workaround and any help is much appreciated.The GIF itself is a series of
ggplot
s created within a loop and saved viaanimation::saveGIF()
.A potential workaround would be to run the loop within the app an create the
GIF
on-the-fly, but this is not working in shiny either.Thank you in advance!
-
How to expand the function of seq() to list or dataframe?
So now I have a list look like this:
$a [1] 2 $b [1] 5 $c [1] 3
Just wonder if there's a way to make them become:
$a [1] 1 2 $b [1] 1 2 3 4 5 $c [1] 1 2 3
Thank you very much for your answer!!
-
Capture a particular event from child iframe to parent iframe
I'm facing a issue where I have to load a particular event from iframe. Say I have a iframe (child) with a alert and onload events, I have to bind the two events to the two buttons in (parent) iframe. Is that possible? If so ca you suggest me some example which would be so useful
<!DOCTYPE html> <html> <head> <title> </title> </head> <body> <script type="text/javascript"> function onloadFunction(){ alert("Onload for the button"); } function onloadPrompt(){ prompt("test Prompt"); } </script> <button onclick="onloadPrompt()"> PROMPT</button> <button onclick="onloadFunction()"> LOAD</button> </body> </html>
PARENT:
<!DOCTYPE HTML> <html> <head> <title> Iframe test </title> </head> <meta charset='utf-8'> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js"></script> <style> .name{ font-family: monospace; } </style> <script type="text/javascript"> var iframe = $("C:Users/ajay.venkatesh/Desktop/IframeTEst1.html").contents(); console.log("Iframe working"); iframe.find('onloadFunction()').click(function(event){ console.log('work fine'); }); </script> <body> <iframe src="C:\Users\ajay.venkatesh\Desktop\IframeTEst1.html"></iframe> <h1 class="name"> Ajay Venkatesh</h1> <button onclick="onloadFunction()"> LOAD</button> </body> </html>
-
My angular 7 app does not loaded inside an iFrame when passing html content
I'm trying to load an angular 7 app inside an iFrame by passing the HTML content instead of simple url,
Here is the code that I use to create the iFrame:
// Wrapper div for the iFrame const iFrameContainerEl = document.createElement('div'); iFrameContainerEl.setAttribute('id', AppConfig.iFrameContainerDivID); iFrameContainerEl.setAttribute( 'style', /* For Manual position, the iFrame container will take the custom CSS from widget config file, * otherwise an auto-generated style will be provided, based on selected position * */ (widget.widgetPosition === WidgetPosition.Manually) ? widget.customCss : AppConfig.getIFrameContainerStyle(widget.widgetPosition)); // The main iFrame const iFrameHTMLContent = ` <!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>Survey</title> <base href="/"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="icon" type="image/x-icon" href="favicon.ico"> <link href="https://fonts.googleapis.com/css?family=Roboto:300,400,500" rel="stylesheet"> <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet"> </head> <body> <app-root></app-root> <script type="text/javascript" src="http://localhost:4200/runtime.js"></script> <script type="text/javascript" src="http://localhost:4200/es2015-polyfills.js"></script> <script type="text/javascript" src="http://localhost:4200/polyfills.js"></script> <script type="text/javascript" src="http://localhost:4200/main.js"></script> </body> </html> `; const iFrameEl = document.createElement('iframe'); iFrameEl.setAttribute('src', `data:text/html;charset=utf-8, ${encodeURI(iFrameHTMLContent)}`); iFrameEl.setAttribute('style', AppConfig.iFrameStyle); // add the iFrame to its container div iFrameContainerEl.appendChild(iFrameEl); // add the iFrame container div to the body document.body.appendChild(iFrameContainerEl);
I expect to see the angular app fully loaded inside the iFrame, but I get a blank page instead. The Angular app is working as expected when running it on standalone.
I see the assets are loaded correctly, but the page is blank always
-
How to filter postMessages?
On a client's donation page (https://www.resurge.org/donate/), the iframe's size is managed by iframeResizer which generates a new message on multiple events.
Meanwhile, I'm sending a separate message from the parent, containing a Google Analytics object with userId. This message is sent after a 0:02 timeout to ensure the iframe has fully loaded.
My event listener consistently pulls in the iframeResizer message. When that occurs, I can identify it and
return
, but how can I ensure that the iframe receives my .ga object?On the parent:
<script> setTimeout(function(){ ga(function(tracker) { var clientId = tracker.get('clientId'); var frameWindow = document.getElementById('my_iframe').contentWindow; // change https://xyz.shoppingcart.com to match your iFrame domain frameWindow.postMessage(clientId, 'https://app.etapestry.com'); }); }, 2000); </script>
in the iframe:
<script> window.addEventListener('message', function(event) { // Ignores messages from untrusted domains. if (event.origin != 'https://www.resurge.org') return; // test for [iFrameSizer] if (event.data.slice(0, 13) === '[iFrameSizer]') return; // This code never runs: // Creates the tracker with the data from the parent page. ga('create', 'UA-19540393-1', 'auto', {clientId: event.data}); // write data to log console.log("iFrame Child Page -- ID Creator in addEventListener", event.data); ga('send', 'pageview'); }); </script>
-
in a shiny app, ggmosaic gives an error: Discrete value supplied to continuous scale
In a shiny app, plots are made. One of them, based on ggmosaic and ggplot2, I can't render. It is giving me an error: "Warning: Error in : Discrete value supplied to continuous scale"
Trying to reproduce it on the console, I get the same error when the ggmosaic isn't loaded (library(ggmosaic)).
# Restart R library(ggplot2) library(dplyr) #library(ggmosaic) not loaded test_mosaic <- tibble::tribble( ~source, ~RegionSplit, ~RegionReport, ~SuppliesSplit, ~SuppliesPlot, ~fYear, ~measure, "Transac", "Region1", "Region1", "Supplies1", "MarketA", 2017L, 77010005, "Transac", "Region1", "Region1", "Supplies2", "MarketA", 2017L, 10880005, "Transac", "Region1", "Region1", "Supplies3", "MarketA", 2017L, 520005, "Store", "Region1", "Region1", "Supplies1", "MarketA", 2017L, 210005, "Store", "Region1", "Region1", "Supplies2", "MarketA", 2017L, 33305 ) test_mosaic <- test_mosaic %>% dplyr::mutate_if(is.character, forcats::as_factor) %>% dplyr::mutate_if(is.integer, ~forcats::as_factor(as.character(.))) ggplot2::ggplot(data = test_mosaic) + ggmosaic::geom_mosaic( ggplot2::aes(weight = as.numeric(measure), x = ggmosaic::product(source, SuppliesSplit), fill = source), na.rm = TRUE, offset = 0.005) # Error: Discrete value supplied to continuous scale
If the ggmosaic is loaded everything works. in my shiny app I must have the ggmosaic function available with the
#' @importFrom ggplot2 ggplot aes #' @importFrom ggmosaic geom_mosaic product
There are several ggplot2 plots working fine, so I really don't get what's not working in this case. Have I missed something obvious ?
thank you.
-
Write to shiny server without republishing
I'm wondering if I can move a Dropbox file to the permanent storage of my shiny app from within a running shiny app?
This would be done only by an authenticated administrator.
I'm using shinyapps.io.
Normally if I upload the the Dropbox file it's only available in that shiny session.
I'd rather not have to republish the app from R or read the Dropbox file on every instantiation of the shiny app.
-
How to get value of selected choice in Rshiny reactive dropdown box?
I have a reactive drop down box in Rshiny with the values for years- 2016 to 2019. After the user chooses the year, the year has to be passed onto an sql query with the year as the parameter.
So I tried the line given below (where
unique_vales2
holds the year values)--- title: "Dashboard" output: flexdashboard::flex_dashboard: orientation: rows vertical_layout: fill social: [ "twitter", "facebook", "menu"] runtime: shiny ```{r} mydb = dbConnect(MySQL(), user='xxx', password='xxx',dbname='xxx', host='xxx') selectInput("year", "Choose year", choices = unique_values2) num <- reactive(as.integer(input$year)) rs=dbSendQuery(mydb,paste("select * from employees where Year=",num," group by job;")) result=fetch(rs,n=-1) ```
But when I tried to use the num value in an sql query like given above,
It shows:
Error: cannot coerce the type 'closure' to vector of type 'character'.
Any way around this? Thanks in advance.
-
How to call R Markdown knit function from Python script
I have a Python script that creates multiple .Rmd files, and I wanted a way to automatically turn them into .html's without having to manually knit each within RStudio. I've probably spent around 4 hours researching and trying different options, and although I've managed to make it work by calling a .R script with
subprocess.Popen(['Rscript', '--vanilla', 'rmd2html.R'], shell=False)
that then does the knitting with
rmarkdown::render("dicionarioNew.Rmd", "html_document")
,this for some reason does not use UTF-8 (which I need) and doesn't easily allow me to store the number of times the program has been run (necessary for giving a different name to each html file).
-
Passing parameters from R Markdown to Latex
Good evening, I would like to pass custom parameters from Rmd to the header (using fancyhdr) of a pdf document. I tried the code below, but I don't know how it could interpret \parames$figureno ... and I get that error when knitting:
! Undefined control sequence. \f@nch@och ->\parames $figureno\strut l.169 \end{document}
Here is the code in Rmd:
output: pdf_document: keep_tex: true includes: in_header: header.tex params: figureno: "Fig. 1-1"
And the header.tex:
\usepackage{fancyhdr} \pagestyle{fancy} \fancyhead[CO,CE]{\parames$figureno} \fancyfoot[CO,CE]{And this is a fancy footer} \fancyfoot[LE,RO]{\thepage} \renewcommand\headrule{% \vspace{3pt} \hrulefill}
How can I make it working ?
Thank you in advance.