<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Posts | AKitsche Blog</title><link>https://akitsche.netlify.app/post/</link><atom:link href="https://akitsche.netlify.app/post/index.xml" rel="self" type="application/rss+xml"/><description>Posts</description><generator>Wowchemy (https://wowchemy.com)</generator><language>en-us</language><copyright>© 2021 Andreas Kitsche</copyright><image><url>https://akitsche.netlify.app/images/icon_hufdd866d90d76849587aac6fbf27da1ac_464_512x512_fill_lanczos_center_2.png</url><title>Posts</title><link>https://akitsche.netlify.app/post/</link></image><item><title>Tidy Tuesday 52 2020</title><link>https://akitsche.netlify.app/post/tidy-tuesday-52-2020/</link><pubDate>Thu, 07 Jan 2021 00:00:00 +0000</pubDate><guid>https://akitsche.netlify.app/post/tidy-tuesday-52-2020/</guid><description>
&lt;script src="https://akitsche.netlify.app/rmarkdown-libs/header-attrs/header-attrs.js">&lt;/script>
&lt;link href="https://akitsche.netlify.app/rmarkdown-libs/panelset/panelset.css" rel="stylesheet" />
&lt;script src="https://akitsche.netlify.app/rmarkdown-libs/panelset/panelset.js">&lt;/script>
&lt;p>Hey folks,&lt;/p>
&lt;p>this is the first of a series of blog post where I want to participate on the &lt;a href="https://github.com/rfordatascience/tidytuesday/blob/master/README.md">tidytuesday&lt;/a> weekly social data project in R.&lt;/p>
&lt;blockquote>
&lt;p>The intent of Tidy Tuesday is to provide a safe and supportive forum for individuals to practice their wrangling and data visualization skills independent of drawing conclusions.&lt;/p>
&lt;/blockquote>
&lt;p>The goal of this series is to help me&lt;/p>
&lt;ul>
&lt;li>practice data visualization and data wrangling in R (&lt;span class="citation">R Core Team (2019)&lt;/span>) using the tidyverse (&lt;span class="citation">Wickham et al. (2019)&lt;/span>)&lt;/li>
&lt;li>adopt this skillset to learn Python&lt;/li>
&lt;li>master to publish the applications using &lt;a href="https://bookdown.org/yihui/rmarkdown-cookbook/">R Markdown&lt;/a>&lt;/li>
&lt;/ul>
&lt;div class="panelset">
&lt;!-- First panel -->
&lt;div class="panel">
&lt;p>&lt;span class="panel-name">R code&lt;/span>&lt;/p>
&lt;p>Check the R code below:&lt;/p>
&lt;pre class="r">&lt;code>lm(mpg ~ drat, data = mtcars)&lt;/code>&lt;/pre>
&lt;/div>
&lt;!-- Second panel -->
&lt;div class="panel">
&lt;p>&lt;span class="panel-name">Stata code&lt;/span>&lt;/p>
&lt;pre>&lt;code>regress y x
&lt;/code>&lt;/pre>
&lt;/div>
&lt;!-- Third panel -->
&lt;div class="panel">
&lt;p>&lt;span class="panel-name">R output&lt;/span>&lt;/p>
&lt;pre>&lt;code>##
## Call:
## lm(formula = mpg ~ drat, data = mtcars)
##
## Coefficients:
## (Intercept) drat
## -7.525 7.678&lt;/code>&lt;/pre>
&lt;/div>
&lt;/div>
&lt;div id="references" class="section level1 unnumbered">
&lt;h1>References&lt;/h1>
&lt;div id="refs" class="references csl-bib-body hanging-indent">
&lt;div id="ref-R-base" class="csl-entry">
R Core Team. 2019. &lt;em>R: A Language and Environment for Statistical Computing&lt;/em>. Vienna, Austria: R Foundation for Statistical Computing. &lt;a href="https://www.R-project.org">https://www.R-project.org&lt;/a>.
&lt;/div>
&lt;div id="ref-tidyverse" class="csl-entry">
Wickham, Hadley, Mara Averick, Jennifer Bryan, Winston Chang, Lucy D’Agostino McGowan, Romain François, Garrett Grolemund, et al. 2019. &lt;span>“Welcome to the &lt;span class="nocase">tidyverse&lt;/span>.”&lt;/span> &lt;em>Journal of Open Source Software&lt;/em> 4 (43): 1686. &lt;a href="https://doi.org/10.21105/joss.01686">https://doi.org/10.21105/joss.01686&lt;/a>.
&lt;/div>
&lt;/div>
&lt;/div></description></item><item><title>Bonsai Impression Spring 2018</title><link>https://akitsche.netlify.app/post/bonsai_impressions_2018/bonsai_impressions_2018/</link><pubDate>Sun, 30 Apr 2017 21:13:14 -0500</pubDate><guid>https://akitsche.netlify.app/post/bonsai_impressions_2018/bonsai_impressions_2018/</guid><description>
&lt;script src="https://akitsche.netlify.app/rmarkdown-libs/header-attrs/header-attrs.js">&lt;/script>
&lt;p>During the last weeks I did some work including root cutting, potting and styling on a couple of my pre-bonsai trees. My collection consists of a stock of approximately 100 trees ranging from European oak (&lt;a href="https://en.wikipedia.org/wiki/Quercus_robur">&lt;em>Quercus robur&lt;/em>&lt;/a>), small-leaved lime (&lt;a href="https://en.wikipedia.org/wiki/Tilia_cordata">&lt;em>Tilia cordata&lt;/em>&lt;/a>), pin oak (&lt;a href="https://en.wikipedia.org/wiki/Quercus_palustris">&lt;em>Quercus palustris&lt;/em>&lt;/a>), horse-chestnut (&lt;a href="https://en.wikipedia.org/wiki/Aesculus_hippocastanum">&lt;em>Aesculus hippocastanum&lt;/em>&lt;/a>), European beech (&lt;a href="https://en.wikipedia.org/wiki/Fagus_sylvatica">&lt;em>Fagus sylvatica&lt;/em>&lt;/a>), &lt;a href="https://en.wikipedia.org/wiki/Ginkgo_biloba">&lt;em>Ginkgo biloba&lt;/em>&lt;/a>, Common hazel (&lt;em>Corylus avellana&lt;/em>), Creeping pine (&lt;a href="https://en.wikipedia.org/wiki/Pinus_mugo">&lt;em>Pinus mugo&lt;/em>&lt;/a>), Scots pine (&lt;a href="https://en.wikipedia.org/wiki/Scots_pine">&lt;em>Pinus sylvestris&lt;/em>&lt;/a>), English Yew (&lt;a href="https://en.wikipedia.org/wiki/Taxus_baccata">&lt;em>Taxus Baccata&lt;/em>&lt;/a>), … . Most of them are currently planted in the field.&lt;/p>
&lt;p>The following gallery shows some impression in spring 2018:&lt;/p>
&lt;p>&lt;img src="https://akitsche.netlify.app/img/IMG_20180428_161032.jpg" style="width:70.0%" alt="Acer monspessulanum" />
&lt;a href="https://en.wikipedia.org/wiki/Acer_monspessulanum">Acer monspessulanum&lt;/a>&lt;/p>
&lt;p>&lt;img src="https://akitsche.netlify.app/img/IMG_20180428_174619.jpg" style="width:70.0%" alt="Test" />
&lt;a href="https://en.wikipedia.org/wiki/Tilia_cordata">&lt;em>Tilia cordata&lt;/em>&lt;/a>&lt;/p>
&lt;p>&lt;img src="https://akitsche.netlify.app/img/IMG_20180428_161132.jpg" style="width:70.0%" />
Collection of pre-bonsais currently planted in the field&lt;/p>
&lt;p>&lt;img src="https://akitsche.netlify.app/img/IMG_20180428_161302.jpg" style="width:70.0%" />&lt;/p>
&lt;p>&lt;a href="https://en.wikipedia.org/wiki/Ginkgo_biloba">&lt;em>Ginkgo biloba&lt;/em>&lt;/a>&lt;/p>
&lt;p>&lt;img src="https://akitsche.netlify.app/img/IMG_20180428_161146.jpg" style="width:70.0%" />
&lt;a href="https://en.wikipedia.org/wiki/Tilia_cordata">&lt;em>Tilia cordata&lt;/em>&lt;/a>&lt;/p>
&lt;p>&lt;img src="https://akitsche.netlify.app/img/IMG_20180428_161207.jpg" style="width:70.0%" />&lt;/p>
&lt;p>&lt;a href="https://en.wikipedia.org/wiki/Tilia_cordata">&lt;em>Tilia cordata&lt;/em>&lt;/a>&lt;/p>
&lt;p>&lt;img src="https://akitsche.netlify.app/img/IMG_20180428_161221.jpg" style="width:70.0%" />&lt;/p>
&lt;p>&lt;a href="https://en.wikipedia.org/wiki/Aesculus_hippocastanum">&lt;em>Aesculus hippocastanum&lt;/em>&lt;/a>&lt;/p>
&lt;p>&lt;img src="https://akitsche.netlify.app/img/IMG_20180428_161232.jpg" style="width:70.0%" />&lt;/p>
&lt;p>&lt;a href="https://en.wikipedia.org/wiki/Aesculus_hippocastanum">&lt;em>Aesculus hippocastanum&lt;/em>&lt;/a>&lt;/p>
&lt;p>&lt;img src="https://akitsche.netlify.app/img/IMG_20180414_131952_BURST001_COVER.jpg" style="width:70.0%" />
&lt;a href="https://en.wikipedia.org/wiki/Ginkgo_biloba">&lt;em>Ginkgo biloba&lt;/em>&lt;/a>&lt;/p></description></item><item><title>Connecting R with Salesforce.com</title><link>https://akitsche.netlify.app/post/r_salesforce/r_salesforce/</link><pubDate>Thu, 23 Jul 2015 21:13:14 -0500</pubDate><guid>https://akitsche.netlify.app/post/r_salesforce/r_salesforce/</guid><description>
&lt;script src="https://akitsche.netlify.app/rmarkdown-libs/header-attrs/header-attrs.js">&lt;/script>
&lt;p>Hey folks,&lt;/p>
&lt;p>this blog post will give a short introduction on how to connect &lt;a href="https://www.salesforce.com">salesforce.com&lt;/a> with &lt;a href="https://cran.r-project.org/">R&lt;/a>.
According to &lt;a href="http://de.gravatar.com/hiratake55">Takekatsu Hiramura&lt;/a>&lt;/p>
&lt;blockquote>
&lt;p>R statistical computing environment is the most populous statistical computing software, and Salesforce.com is the world´s most innovative cloud-computing based SaaS (Software-as-a-Service) CRM package.&lt;/p>
&lt;/blockquote>
&lt;p>&lt;img src="https://akitsche.netlify.app/img/R_salesforce_blog_picture.png" />&lt;/p>
&lt;p>To connect R with salesforce.com Takekatsu Hiramura developed the R add-on package &lt;a href="https://cran.r-project.org/web/packages/RForcecom/">RForcecom&lt;/a>. The source code of the package is available from &lt;a href="https://github.com/hiratake55/RForcecom">github&lt;/a>. You can install the package from &lt;a href="http://cran.r-project.org/">CRAN&lt;/a>:&lt;/p>
&lt;pre class="r">&lt;code>install.packages(&amp;quot;RForcecom&amp;quot;)
library(RForcecom)&lt;/code>&lt;/pre>
&lt;p>To sign in to salesforce.com we can use the &lt;code>rforcecom.login()&lt;/code> function. We have to set the &lt;code>username&lt;/code>, &lt;code>password&lt;/code>, &lt;code>instanceURL&lt;/code>, &lt;code>apiVersion&lt;/code> arguments as follows:&lt;/p>
&lt;pre class="r">&lt;code>username &amp;lt;- &amp;quot;yourname@yourcompany.com&amp;quot;
password &amp;lt;- &amp;quot;YourPasswordSECURITY_TOKEN&amp;quot;
instanceURL &amp;lt;- &amp;quot;https://login.salesforce.com/&amp;quot;
apiVersion &amp;lt;- &amp;quot;26.0&amp;quot;
(session &amp;lt;- rforcecom.login(username, password, instanceURL, apiVersion))&lt;/code>&lt;/pre>
&lt;p>Please note: do not forget your security token in the password field. The &lt;a href="https://success.salesforce.com/answers?id=90630000000glADAAY">Salesforce community&lt;/a> shows how to reset the security token.&lt;/p>
&lt;p>Unfortunatly we probably get an error: &lt;em>Error in curl::curl_fetch_memory(url, handle = handle) : Couldn’t resolve host name&lt;/em>, because the corporate network environment uses HTTP Proxy. To pick out the proxy setting we can use the &lt;code>ie_proxy_info()&lt;/code> function from the &lt;a href="https://cran.r-project.org/web/packages/curl/index.html">curl&lt;/a> R add-on package.:&lt;/p>
&lt;pre class="r">&lt;code>#install.packages(&amp;quot;curl&amp;quot;)
library(curl)
ie_proxy_info()&lt;/code>&lt;/pre>
&lt;p>Obviously the corporate network environment uses a global &lt;a href="https://en.wikipedia.org/wiki/Proxy_auto-config">proxy auto-configuration (PUC)&lt;/a> file that defines how web browsers and other user agents can automatically choose the appropriate proxy server. We can get the info of the proxy for a specific URL using the &lt;code>ie_get_proxy_for_url()&lt;/code> function:&lt;/p>
&lt;pre class="r">&lt;code>ie_get_proxy_for_url(target_url = &amp;quot;https://login.salesforce.com/&amp;quot;)&lt;/code>&lt;/pre>
&lt;p>The function returns a character string with two proxies and their corresponding port. We will further use the first proxy displayed: **. Now we have to set the proxy configurations with the &lt;code>set_config()&lt;/code> and &lt;code>use_proxy()&lt;/code> functions from the &lt;a href="https://cran.r-project.org/web/packages/httr/index.html">httr&lt;/a> R add-on package:&lt;/p>
&lt;pre class="r">&lt;code>#install.packages(&amp;quot;httr&amp;quot;)
library(httr)
proxy_for_url &amp;lt;- &amp;quot;your proxy&amp;quot; #from ie_get_proxy_for_url(target_url = &amp;quot;https://login.salesforce.com/&amp;quot;)
port_for_url &amp;lt;- 8080
set_config(
use_proxy(url = proxy_for_url&amp;quot;,
port = port_for_url,
username = &amp;quot;windows_username&amp;quot;,
password = &amp;quot;windows_password&amp;quot;,
auth = &amp;quot;ntlm&amp;quot;)
)&lt;/code>&lt;/pre>
&lt;p>Under some circumstances you will get the following error message at this point: &lt;em>Error in curl::curl_fetch_memory(url, handle = handle) : Problem with the SSL CA cert (path? access rights?)&lt;/em>.
In this case your security certificate, e.g. &lt;em>curl-ca-bundle.crt&lt;/em> is located in the wrong folder. You have to paste the file into &lt;em>C:/mingw64/ssl/certs&lt;/em>.&lt;/p>
&lt;p>Et voilà, we reached our goal to connect R with salesforce.com:&lt;/p>
&lt;pre class="r">&lt;code>session &amp;lt;- rforcecom.login(username = username, password = password, loginURL = instanceURL, apiVersion = apiVersion)
session&lt;/code>&lt;/pre>
&lt;p>Use the function &lt;code>rforcecom.retrieve()&lt;/code> to retrieve a dataset:&lt;/p>
&lt;pre class="r">&lt;code>rforcecom.retrieve(session = session,
objectName = &amp;quot;Contact&amp;quot;,
fields = c(&amp;quot;ID&amp;quot;, &amp;quot;Name&amp;quot;),
limit = 50)&lt;/code>&lt;/pre>
&lt;p>After setting up our environment these procedures are very easy and are very useful for projects using R and Salesforce.com. Please let me know if you have any further questions or suggestions.&lt;/p></description></item></channel></rss>