<?xml version="1.0" encoding="UTF-8" ?>
<!-- RSS generated by PHPBoost on Thu, 16 Apr 2026 15:49:48 +0200 -->

<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Last articles - STHDA : R packages]]></title>
		<atom:link href="https://www.sthda.com/english/syndication/rss/articles/16" rel="self" type="application/rss+xml"/>
		<link>https://www.sthda.com</link>
		<description><![CDATA[Last articles - STHDA : R packages]]></description>
		<copyright>(C) 2005-2026 PHPBoost</copyright>
		<language>en</language>
		<generator>PHPBoost</generator>
		
		
		<item>
			<title><![CDATA[Plotly: Create Interactive Plots in R]]></title>
			<link>https://www.sthda.com/english/articles/16-r-packages/59-plotly-create-interactive-plots-in-r/</link>
			<guid>https://www.sthda.com/english/articles/16-r-packages/59-plotly-create-interactive-plots-in-r/</guid>
			<description><![CDATA[<!-- START HTML -->

  <!--====================== start from here when you copy to sthda================-->
  <div id="rdoc">


<p><br/></p>
<p><strong>Plotly</strong> R package makes <strong>interactive</strong>, publication-quality graphs online. Examples of how to make line plots, scatter plots, area charts, bar charts, error bars, box plots, histograms, heatmaps, subplots, multiple-axes, and 3D (WebGL based) charts.</p>
<p>You can read more at: <a href="https://plot.ly/r/">Plotly R Library</a>.</p>
<p>In this document, we’ll show how to create an interactive <strong>ggplot2</strong>-based graphics using plotly.</p>
<div id="install-required-packages" class="section level2">
<h2>Install required packages</h2>
<pre class="r"><code>install.packages("ggplot2")
install.packages("plotly")</code></pre>
</div>
<div id="usage" class="section level2">
<h2>Usage</h2>
<pre class="r"><code>library(ggplot2)
library(plotly)

set.seed(100)
d <- diamonds[sample(nrow(diamonds), 1000), ]

p <- ggplot(data = d, aes(x = carat, y = price)) +
  geom_point(aes(text = paste("Clarity:", clarity)), size = .5) +
  geom_smooth(aes(colour = cut, fill = cut)) + facet_wrap(~ cut)

ggplotly(p)</code></pre>
<p>The plots look like this:</p>
<p><img src="https://www.sthda.com/english/sthda/RDoc/images/plotly-create-interactive-plots-r.png" alt="Plotly: create interactive plots in R" /></p>
</div>
</div><!--end rdoc-->
<!--====================== stop here when you copy to sthda================-->



<!-- END HTML -->]]></description>
			<pubDate>Tue, 08 Aug 2017 20:25:00 +0200</pubDate>
			
		</item>
		
		<item>
			<title><![CDATA[gganimate: Create Animations with ggplot2]]></title>
			<link>https://www.sthda.com/english/articles/16-r-packages/58-gganimate-create-animations-with-ggplot2/</link>
			<guid>https://www.sthda.com/english/articles/16-r-packages/58-gganimate-create-animations-with-ggplot2/</guid>
			<description><![CDATA[<!-- START HTML -->

  <!--====================== start from here when you copy to sthda================-->
  <div id="rdoc">
<p><br/></p>
<p>The <strong>gganimate</strong> package is an extension to <strong>ggplot2</strong> for creating an <strong>animated plot</strong>. It provides a supplementary aesthetic called <strong>frame</strong>, just like x, y, size, color, or so on. Thus, a variable in your data can be mapped to frame just as others are mapped to x or y.</p>
<div id="install" class="section level2">
<h2>Install</h2>
<pre class="r"><code>if(!require(devtools)) install.packages("devtools")
devtools::install_github("dgrtwo/gganimate")</code></pre>
</div>
<div id="demo-data-sets" class="section level2">
<h2>Demo data sets</h2>
<p>We’ll use the <em>gapminder</em> data set available in the package of the same name.</p>
<p>To install gapminder, type this:</p>
<pre class="r"><code>install.packages("gapminder")</code></pre>
<p>Inspect the data set:</p>
<pre class="r"><code>library(gapminder)
head(gapminder)</code></pre>
<pre><code>##       country continent year lifeExp      pop gdpPercap
## 1 Afghanistan      Asia 1952    28.8  8425333       779
## 2 Afghanistan      Asia 1957    30.3  9240934       821
## 3 Afghanistan      Asia 1962    32.0 10267083       853
## 4 Afghanistan      Asia 1967    34.0 11537966       836
## 5 Afghanistan      Asia 1972    36.1 13079460       740
## 6 Afghanistan      Asia 1977    38.4 14880372       786</code></pre>
</div>
<div id="simple-animation" class="section level2">
<h2>Simple animation</h2>
<ul>
<li>Plot the variable lifeExp (life expectancy at birth) by the variable gdpPercap (GDP per capita).</li>
<li>Make animation by year using the aesthetic <strong>frame = year</strong>.</li>
</ul>
<pre class="r"><code># Load required package
library(gapminder)
library(ggplot2)
library(gganimate)
# Basic scatter plot
mapping <- aes(x = gdpPercap, y = lifeExp, 
               size = pop, color = continent,
               frame = year) 
p <- ggplot(gapminder, mapping = mapping) +
  geom_point() +
  scale_x_log10()
# Animate
gganimate(p)</code></pre>
<p><img src="https://www.sthda.com/english/sthda/RDoc/images/simple-example-animate-ggplot2.gif" alt="Simple animation" /></p>
<ul>
<li>To animate across continent, use <strong>frame = continent</strong>.</li>
<li>For faster animation use the option <em>interval</em>, for example interval = 0.2</li>
</ul>
</div>
<div id="save-the-animation" class="section level2">
<h2>Save the animation</h2>
<p>Allowed format: an GIF, video, or an animated webpage.</p>
<pre class="r"><code>gganimate(p, "output.gif")
gganimate(p, "output.mp4")
gganimate(p, "output.swf")
gganimate(p, "output.html")</code></pre>
<p>System requirement: ffmpeg and ImageMagick drivers should be installed on your computer.</p>
</div>
<div id="customize" class="section level2">
<h2>Customize</h2>
<ul>
<li>Animate some of the plot layers by highlighting particular points:</li>
</ul>
<pre class="r"><code>p2 <- ggplot(gapminder, aes(gdpPercap, lifeExp, size = pop)) +
  geom_point() +
  geom_point(aes(frame = year), color = "red") +
  scale_x_log10()
gganimate(p2)</code></pre>
<p><img src="https://www.sthda.com/english/sthda/RDoc/images/gganimate-customize.gif" alt="customize animation" /></p>
<ul>
<li>Cumulative layer using the aesthetic <strong>cumulative = TRUE</strong>.</li>
</ul>
<pre class="r"><code>p3 <- ggplot(gapminder, aes(gdpPercap, lifeExp, frame = year)) +
  geom_path(aes(cumulative = TRUE, group = country)) +
  scale_x_log10() +
  facet_wrap(~continent)
gganimate(p3)</code></pre>
<p><img src="https://www.sthda.com/english/sthda/RDoc/images/cumulative-layers.gif" alt="cumulative layers" /></p>
</div>
</div><!--end rdoc-->
<!--====================== stop here when you copy to sthda================-->

<!-- END HTML -->]]></description>
			<pubDate>Tue, 08 Aug 2017 19:05:00 +0200</pubDate>
			
		</item>
		
		<item>
			<title><![CDATA[karyoploteR: Plot Karyotype and Visualize Genomic Data]]></title>
			<link>https://www.sthda.com/english/articles/16-r-packages/32-karyoploter-plot-karyotype-and-visualize-genomic-data/</link>
			<guid>https://www.sthda.com/english/articles/16-r-packages/32-karyoploter-plot-karyotype-and-visualize-genomic-data/</guid>
			<description><![CDATA[<strong>karyoploteR</strong> is an R/Bioconductor package to to plot virtually anything along the genome.<br />
<br />
Installation:<br />
<br />
<div class="formatter-container formatter-code code-R"><span class="formatter-title">Code R :</span><div class="formatter-content"><pre style="display:inline;"><pre class="r" style="font-family:monospace;">&amp;nbsp;
<span style="color: #0000FF; font-weight: bold;">source</span><span style="color: #080;">&amp;#40;</span><span style="color: #ff0000;">"https://bioconductor.org/biocLite.R"</span><span style="color: #080;">&amp;#41;</span>
biocLite<span style="color: #080;">&amp;#40;</span><span style="color: #ff0000;">"karyoploteR"</span><span style="color: #080;">&amp;#41;</span>
&amp;nbsp;</pre></pre></div></div><br />
<br />
Basic workflow to create a karyoplot:<br />
<br />
1) start with an empty plot with no data apart from the ideograms themselves using the function <strong>plotKaryotype</strong>() .<br />
<br />
2) add the data plots as required. To add the data there are functions based on the R base graphics: <strong>kpPoints</strong>(), <strong>kpLines</strong>(), <strong>kpSegments</strong>(), <strong>kpRects</strong>(), … -  that can be used to plot virtually anything along the genome and other functions at a higher level useful to plot more specific genomic data types -e.g. <strong>kpPlotRegions</strong>(), <strong>kpPlotCoverage</strong>(), …-.<br />
<br />
A simple example is to plot a set of regions representing copy-number gains and losses using the <strong>kpPlotRegions</strong>() function:<br />
<br />
<div class="formatter-container formatter-code code-R"><span class="formatter-title">Code R :</span><div class="formatter-content"><pre style="display:inline;"><pre class="r" style="font-family:monospace;">&amp;nbsp;
  gains <span style="color: #080;"><-</span> makeGRangesFromDataFrame<span style="color: #080;">&amp;#40;</span><span style="color: #0000FF; font-weight: bold;">data.<span style="">frame</span></span><span style="color: #080;">&amp;#40;</span>chr<span style="color: #080;">=</span><span style="color: #0000FF; font-weight: bold;">c</span><span style="color: #080;">&amp;#40;</span><span style="color: #ff0000;">"chr1"</span>, <span style="color: #ff0000;">"chr5"</span>, <span style="color: #ff0000;">"chr17"</span>, <span style="color: #ff0000;">"chr22"</span><span style="color: #080;">&amp;#41;</span>, <span style="color: #0000FF; font-weight: bold;">start</span><span style="color: #080;">=</span><span style="color: #0000FF; font-weight: bold;">c</span><span style="color: #080;">&amp;#40;</span><span style="color: #ff0000;">1</span>, <span style="color: #ff0000;">1000000</span>, <span style="color: #ff0000;">4000000</span>, <span style="color: #ff0000;">1</span><span style="color: #080;">&amp;#41;</span>,
                      <span style="color: #0000FF; font-weight: bold;">end</span><span style="color: #080;">=</span><span style="color: #0000FF; font-weight: bold;">c</span><span style="color: #080;">&amp;#40;</span><span style="color: #ff0000;">5000000</span>, <span style="color: #ff0000;">3200000</span>, <span style="color: #ff0000;">80000000</span>, <span style="color: #ff0000;">1200000</span><span style="color: #080;">&amp;#41;</span><span style="color: #080;">&amp;#41;</span><span style="color: #080;">&amp;#41;</span>
  losses <span style="color: #080;"><-</span> makeGRangesFromDataFrame<span style="color: #080;">&amp;#40;</span><span style="color: #0000FF; font-weight: bold;">data.<span style="">frame</span></span><span style="color: #080;">&amp;#40;</span>chr<span style="color: #080;">=</span><span style="color: #0000FF; font-weight: bold;">c</span><span style="color: #080;">&amp;#40;</span><span style="color: #ff0000;">"chr3"</span>, <span style="color: #ff0000;">"chr9"</span>, <span style="color: #ff0000;">"chr17"</span><span style="color: #080;">&amp;#41;</span>, <span style="color: #0000FF; font-weight: bold;">start</span><span style="color: #080;">=</span><span style="color: #0000FF; font-weight: bold;">c</span><span style="color: #080;">&amp;#40;</span><span style="color: #ff0000;">80000000</span>, <span style="color: #ff0000;">20000000</span>, <span style="color: #ff0000;">1</span><span style="color: #080;">&amp;#41;</span>,
                       <span style="color: #0000FF; font-weight: bold;">end</span><span style="color: #080;">=</span><span style="color: #0000FF; font-weight: bold;">c</span><span style="color: #080;">&amp;#40;</span><span style="color: #ff0000;">170000000</span>, <span style="color: #ff0000;">30000000</span>, <span style="color: #ff0000;">25000000</span><span style="color: #080;">&amp;#41;</span><span style="color: #080;">&amp;#41;</span><span style="color: #080;">&amp;#41;</span>
  kp <span style="color: #080;"><-</span> plotKaryotype<span style="color: #080;">&amp;#40;</span>genome<span style="color: #080;">=</span><span style="color: #ff0000;">"hg19"</span><span style="color: #080;">&amp;#41;</span>
  kpPlotRegions<span style="color: #080;">&amp;#40;</span>kp, gains, <span style="color: #0000FF; font-weight: bold;">col</span><span style="color: #080;">=</span><span style="color: #ff0000;">"#FFAACC"</span><span style="color: #080;">&amp;#41;</span>
  kpPlotRegions<span style="color: #080;">&amp;#40;</span>kp, losses, <span style="color: #0000FF; font-weight: bold;">col</span><span style="color: #080;">=</span><span style="color: #ff0000;">"#CCFFAA"</span><span style="color: #080;">&amp;#41;</span>
&amp;nbsp;</pre></pre></div></div><br />
<br />
<br />
<img src="https://www.sthda.com/english/english/upload/karyoploter.png" alt="" /><br />
<br />
<!-- START HTML -->

Read more: <a href = "https://bioconductor.org/packages/devel/bioc/html/karyoploteR.html", rel = "nofollow">karyoploteR</a>

<!-- END HTML -->]]></description>
			<pubDate>Tue, 01 Aug 2017 21:33:00 +0200</pubDate>
			
		</item>
		
		<item>
			<title><![CDATA[ggjoy: Create a ggplot2-based Joyplots]]></title>
			<link>https://www.sthda.com/english/articles/16-r-packages/30-ggjoy-create-a-ggplot2-based-joyplots/</link>
			<guid>https://www.sthda.com/english/articles/16-r-packages/30-ggjoy-create-a-ggplot2-based-joyplots/</guid>
			<description><![CDATA[<!-- START HTML -->
 <div id="rdoc">


<p><strong>Joyplots</strong> consist of partially overlapping line plots for visualizing changes in distribution over time or space. Joyplots can be easily created in R using the ggjoy package, which is an extension of ggplot2.</p>
<div id="install-ggjoy" class="section level2">
<h2>Install ggjoy</h2>
<pre class="r"><code>install.packages("ggjoy")</code></pre>
</div>
<div id="use-ggjoy" class="section level2">
<h2>Use ggjoy</h2>
<p>In the example below, we’ll use the iris demo data set. We’ll visualize the distribution of the variable Sepal.Length by groups (“Species”).</p>
<pre class="r"><code>library(ggplot2)
library(ggjoy)
ggplot(iris, aes(x = Sepal.Length, y = Species)) + 
  geom_joy() + 
  theme_joy()</code></pre>
<p><img src="https://www.sthda.com/english/sthda/RDoc/figure/sthda/ggjoy-ggjoy-joyplots-1.png" width="480" style="margin-bottom:10px;" /></p>
<p>Control the overlap of the different density plots. Use the argument <em>scale</em>.</p>
<pre class="r"><code>ggplot(iris, aes(x = Sepal.Length, y = Species)) + 
  geom_joy(scale = 0.9) + 
  theme_joy()</code></pre>
<p><img src="https://www.sthda.com/english/sthda/RDoc/figure/sthda/ggjoy-ggjoy-scale-1.png" width="480" style="margin-bottom:10px;" /></p>
</div>

</div><!--end rdoc-->
<!-- END HTML -->]]></description>
			<pubDate>Tue, 25 Jul 2017 19:20:00 +0200</pubDate>
			
		</item>
		
		<item>
			<title><![CDATA[FactoInvestigate R Package: Automatic Reports and Interpretation of Principal Component Analyses]]></title>
			<link>https://www.sthda.com/english/articles/16-r-packages/28-factoinvestigate-r-package-automatic-reports-and-interpretation-of-principal-component-analyses/</link>
			<guid>https://www.sthda.com/english/articles/16-r-packages/28-factoinvestigate-r-package-automatic-reports-and-interpretation-of-principal-component-analyses/</guid>
			<description><![CDATA[<!-- START HTML -->

  <!--====================== start from here when you copy to sthda================-->
  <div id="rdoc">
<p><br/></p>
<p><strong>FactoInvestigate</strong> makes it easy to generate an <strong>automatic report</strong> and <strong>interpretation</strong> of FactoMineR - based <strong>principal compoent analyses</strong>. The main function provided by the package is the function <em>Investigate</em>(), which can be used to create either a Word, PDF or a HTML report.</p>
<p>The report include the:</p>
<ul>
<li>detection of existing outliers,</li>
<li>identification of the major first principal components,</li>
<li>plots,</li>
<li>description of dimensions</li>
</ul>
<div id="install-and-load-required-packages" class="section level2">
<h2>Install and load Required packages</h2>
<pre class="r"><code>install.packages("FactoMineR", "FactoInvestigate")</code></pre>
</div>
<div id="demo-examples" class="section level2">
<h2>Demo examples</h2>
<pre class="r"><code># Load Packages
library("FactoMineR")
library("FactoInvestigate")
# Principal component analyses
data(decathlon)
res.pca <- PCA(decathlon, quanti.sup = 11:12, quali.sup = 13, graph = FALSE)
Investigate(res.pca, file = "PCA.Rmd", document = "pdf_document", 
            parallel = TRUE)
# Correpondance analysis
data(children)
res.ca = CA(children, row.sup = 15:18, col.sup = 6:8, graph = FALSE)
Investigate(res.ca, file = "CA.Rmd", document = "html_document")
# Multiple correspondance analysis
data(tea)
res.mca = MCA(tea, quanti.sup = 19,quali.sup = 20:36, graph = FALSE)
Investigate(res.mca, file = "MCA.Rmd", document = c("word_document", "pdf_document"))</code></pre>
<p>The output looks like this:</p>
<iframe src="http://www.slideshare.net/slideshow/embed_code/key/nccmW3YuqKUCUA" width="570" height="510" frameborder="0" marginwidth="0" marginheight="0" scrolling="no" style="border:1px solid #CCC; border-width:1px; margin-bottom:5px; max-width: 100%;" allowfullscreen>
</iframe>
<div style="margin-bottom:5px">
<strong> <a href="http://www.slideshare.net/kassambara/factoinvestigate-r-package" title="FactoInvestigate R Package" target="_blank">FactoInvestigate R Package</a> </strong> de <strong><a target="_blank" href="https://www.slideshare.net/kassambara">kassambara</a></strong>
</div>
</div>
</div><!--end rdoc-->
<!--====================== stop here when you copy to sthda================-->

<!-- END HTML -->]]></description>
			<pubDate>Wed, 19 Jul 2017 20:20:00 +0200</pubDate>
			
		</item>
		
	</channel>
</rss>
