<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>R Archives - Ger Inberg</title>
	<atom:link href="https://gerinberg.com/tag/r/feed/" rel="self" type="application/rss+xml" />
	<link>https://gerinberg.com/tag/r/</link>
	<description>data science developer</description>
	<lastBuildDate>Thu, 11 Aug 2022 18:09:06 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.8.1</generator>

<image>
	<url>https://gerinberg.com/wp-content/uploads/2017/05/favicon-150x150.jpg</url>
	<title>R Archives - Ger Inberg</title>
	<link>https://gerinberg.com/tag/r/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Multi page shiny apps</title>
		<link>https://gerinberg.com/2022/08/11/multi-page-shiny-apps/</link>
		
		<dc:creator><![CDATA[Ger]]></dc:creator>
		<pubDate>Thu, 11 Aug 2022 18:09:05 +0000</pubDate>
				<category><![CDATA[data viz]]></category>
		<category><![CDATA[shiny]]></category>
		<category><![CDATA[web development]]></category>
		<category><![CDATA[donation]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[R]]></category>
		<guid isPermaLink="false">https://gerinberg.com/?p=1834</guid>

					<description><![CDATA[<p>Web applications can have rich functionality nowadays. For example a website of an E-commerce shop has a page about the products they are selling, a page about their conditions, a shopping cart page and an order page. Furthermore it can handle different HTTP requests from [&#8230;]</p>
<p>The post <a href="https://gerinberg.com/2022/08/11/multi-page-shiny-apps/">Multi page shiny apps</a> appeared first on <a href="https://gerinberg.com">Ger Inberg</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Web applications can have rich functionality nowadays. For example a website of an E-commerce shop has a page about the products they are selling, a page about their conditions, a shopping cart page and an order page. Furthermore it can handle different HTTP requests from the user. A GET request is used to retrieve a page (e.g. products) from the server whereas a POST request is used to send information to the server (e.g. make order).</p>
<h4>Problem</h4>
<p>Shiny apps are, by default, a bit limited when looking at it from this perspective.  It can handle only GET requests by default, unless you are a technical expert in this field, see <a href="https://stackoverflow.com/questions/25297489/accept-http-request-in-r-shiny-application" target="_blank" rel="noopener">this stack overflow</a> post. Furthermore shiny apps can have just one entry-point &#8220;/&#8221;. So you can&#8217;t have another entry-point &#8220;/page2&#8221;. Thus, the e-commerce shop is not possible out of the box in R shiny.</p>
<h4>Solution</h4>
<p>There are multiple solutions to support multiple pages. The one that I am using since a while is the package <a href="https://github.com/ColinFay/brochure" target="_blank" rel="noopener">brochure </a>developed by Colin Fay. It is still in development, so you might encounter some issues but I haven&#8217;t found any major bugs yet. A brochure app consists of a series of pages that are defined by an endpoint/path, a UI and a server function. Thus each page has its own shiny session, its own UI, and its own server! This is important to keep in mind.  A separate session for each page has some advantages but also some disadvantages (e.g. how to pass user data between pages?). A very simple brochureApp looks like this:</p>
<pre class="highlight"><code><span class="n">library(shiny)
library(brochure)

brochureApp</span><span class="p">(</span>
  <span class="c1"># First page</span>
  <span class="n">page</span><span class="p">(</span>
    <span class="n">href</span> <span class="o">=</span> <span class="s2">"/"</span><span class="p">,</span>
    <span class="n">ui</span> <span class="o">=</span> <span class="n">fluidPage</span><span class="p">(</span>
      <span class="n">h1</span><span class="p">(</span><span class="s2">"My first page"</span><span class="p">),</span> 
      <span class="n">plotOutput</span><span class="p">(</span><span class="s2">"plot"</span><span class="p">)</span>
    <span class="p">),</span>
    <span class="n">server</span> <span class="o">=</span> <span class="k">function</span><span class="p">(</span><span class="n">input</span><span class="p">,</span> <span class="n">output</span><span class="p">,</span> <span class="n">session</span><span class="p">){</span>
      <span class="n">output</span><span class="o">$</span><span class="n">plot</span> <span class="o">&lt;-</span> <span class="n">renderPlot</span><span class="p">({</span>
        <span class="n">plot</span><span class="p">(</span><span class="n">iris</span><span class="p">)</span>
      <span class="p">})</span>
    <span class="p">}</span>
  <span class="p">),</span> 
  <span class="c1"># Second page, no server-side function</span>
  <span class="n">page</span><span class="p">(</span>
    <span class="n">href</span> <span class="o">=</span> <span class="s2">"/page2"</span><span class="p">,</span> 
    <span class="n">ui</span> <span class="o">=</span>  <span class="n">fluidPage</span><span class="p">(</span>
      <span class="n">h1</span><span class="p">(</span><span class="s2">"My second page"</span><span class="p">)</span>
    <span class="p">)</span>
  <span class="p">)</span>
<span class="p">)</span></code></pre>
<h4>Donation app</h4>
<p>Coming back to the E-commerce shop example, I have developed an app where one can sponsor me for my open source work on R packages. The app has an integration with Stripe to make a donation and a thank you and error page. When calling Stripe you have to give the two endpoints for these pages and by using brochure, I am able to setup these endpoints. See the app on <a href="https://ginberg.shinyapps.io/donate/" target="_blank" rel="noopener">shinyapps.io</a> and of course I would appreciate it, if you use the app!:-)</p>
<p>The post <a href="https://gerinberg.com/2022/08/11/multi-page-shiny-apps/">Multi page shiny apps</a> appeared first on <a href="https://gerinberg.com">Ger Inberg</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Speed skating viz updated</title>
		<link>https://gerinberg.com/2021/12/30/speed-skating-viz-updated/</link>
		
		<dc:creator><![CDATA[Ger]]></dc:creator>
		<pubDate>Thu, 30 Dec 2021 14:54:12 +0000</pubDate>
				<category><![CDATA[data viz]]></category>
		<category><![CDATA[beijing]]></category>
		<category><![CDATA[d3js]]></category>
		<category><![CDATA[olympic games]]></category>
		<category><![CDATA[R]]></category>
		<category><![CDATA[speedskating]]></category>
		<guid isPermaLink="false">https://gerinberg.com/?p=1817</guid>

					<description><![CDATA[<p>Speed skating is one of my favorite sports to practice and to watch. This winter the Winter Olympics will be held in Beijing, China.  Will the Dutch be as successful as they were in Sochi and PyeongChang?  How many medals will the Chinese win? Four [&#8230;]</p>
<p>The post <a href="https://gerinberg.com/2021/12/30/speed-skating-viz-updated/">Speed skating viz updated</a> appeared first on <a href="https://gerinberg.com">Ger Inberg</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<div class="olympic-section-wrapper">
<div id="olympic-introduction">
<p class="bold-start">Speed skating is one of my favorite sports to practice and to watch. This winter the Winter Olympics will be held in Beijing, China.  Will the Dutch be as successful as they were in Sochi and PyeongChang?  How many medals will the Chinese win?</p>
<p><a href="http://gerinberg.com/2017/11/04/speed-skating-olympic-medalists/">Four years ago</a>, I created a visualization about past medal winners at the Olympic Games. I have updated it now with the results of the games in 2018 at PyeongChang.</p>
</div>
</div>
<p>See the <a href="https://gerinberg.com/speedskating">live version</a>. Let me know if you like it or you are interested in some other charts. Enjoy the Winter Olympics!</p>
<p>The post <a href="https://gerinberg.com/2021/12/30/speed-skating-viz-updated/">Speed skating viz updated</a> appeared first on <a href="https://gerinberg.com">Ger Inberg</a>.</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
