# Blog – R

# Blog on R

**11. June 2018 – Day 1**

R is a very important tool for statisticians. Now I’m talking on support of clinical trials (or life science research in general) – but this statement is true practically in all areas where statistical solutions work.

I decided that** I’ll spend at least one hour with R in the following 100 days**. Probably one day will be skipped. Maybe. But the original concept is to put a continuous work for a better understanding of the R phenomenon.

With this blog I primarily would like to learn. But I have other considerations as well. I’m curious to learn what does a massive 100 day long learning procedure mean in this area? What depth will I be able to reach in understanding of R (or at least some specific aspects)? I hope that there will be some fruits of this activity. And if so, I would like to share them with you, my Dear Follower.

Let’s start with a two sentence introduction.

I’m a statistician supporting pharma industry on the first place for 28 years. I met R first time around 2002. Since then I am continuously astonished what a great variety of solutions can be reached via R. The speed of the development of unique packages is terrific.

Now let’s focus on our original target: **R**.

I put the question to myself during the past years: is there anybody who could perfectly – optimally – benefit from the advantages of R? You probably know a solution for a problems, but it might happen that there are much better solutions – hidden for you. Is there anybody who can absolutely professionally adopt the methods implemented in R? How many statisticians or programmers are able to be updated on changes of packages and arrivals of new ones?

Let’s see an easy task: **regression**. Linear regression is supported already by the basic system [1]. Subset selection – among other opportunities – are supported by “* MASS”* [2] on the first place. A very good summary on logit regression can reached at [3] where the application of package “

*” is presented. Graphical interpretation of logistic modeling can be supported by “*

**aod***” or with “*

**ggplot2***” packages. According to Stephen Turner [4] the best package for multiple regression is “*

**regvis***“. On the same page Peter Flom places “*

**rms***” to the first choice in managing multiple regression problems.*

**car**The queue is long – hopefully not infinite – but I do not want to demoralize anybody with this example; on the contrary I would like underline the importance of all the activities aiming some order in this chaos.

Let’s start at the beginning.

R was dreamed and introduced by Ross Ihaka and Robert Gentleman at the University of Auckland, New Zealand. The first version was released only in 1995.

Today R is the 11th most important programming language [5] – where Java is the 1st. Probably the total number of available R packages can only be determined with difficulties – the number exceeded 11,000 (!) at 27 November 2017 [6] – but at least there is an up-to-date list with the most popular 40 packages at [7].

When I’m writing this blog, the most popular package was “* Rcpp*“, a package for proper C++ integration (with more than 989K downloads) [7]. It’s strange enough but programmers sometimes even put energies in implementation of “

*” things. R is a good example for this as well, namely you can play the well-known Miner game or demonstrate the Tower of Hanoi [8].*

**fun**

### End of Day 1

[1] https://www.r-bloggers.com/simple-linear-regression-2/[2] https://cran.r-project.org/web/packages/MASS/index.html

[3] https://stats.idre.ucla.edu/r/dae/logit-regression/

[4] https://www.quora.com/What-is-the-best-R-package-for-multiple-regression

[5] https://en.wikipedia.org/wiki/R_(programming_language)

[6] http://blog.revolutionanalytics.com/2017/01/cran-10000.html

[7] https://github.com/rstudio/RStartHere/blob/master/top_downloads_2016/top_packages

[8] https://cran.rstudio.com/web/packages/fun/fun.pdf

Picture references

/1/ http://blog.revolutionanalytics.com/2013/04/lahman-a-new-r-package-for-baseball-stats.html

/2/ https://yihui.name/en/2011/08/the-fun-package-use-r-for-fun/

**18. June 2018 – Day 2**

Only the second day and I already found it: Awesame-R [D2-1]. An R-related page with several interesting topics categorised by functionality like “Web technologies and services” or “Bayesian” or “Natural Language Processing”.

This exactly is the page I wanted to create.

Probably they started it more than 2 days ago. It looks very informative and promising.

Let’s examine some menu items.

I already mentioned NLP.

Today (11.06.2018) the relevant menu item contains 16 packages (from “* text2vec*” to “

*“). If you click on the first item (“*

**utf8***“) you get a Github link. Integration of such github content worths a detailed description in itself. Maybe next time. But “*

**text2vec***” can be installed directly from the R environment. If it works, it’s more comfortable to choose this option.*

**text2vec**I checked all the links listed here: all worked, though some of them is quite outdated (e.g. “

*” was updated on 09.08.2014 last time). The real surprise was the “*

**SnowballC***” link [D2-2], which referred to a book “Text mining with R” by Julia Silge and David Robinson. (You can reach the book here but only on business grounds).*

**tidytext**By the way, I just realised that NLP is not necessarily a self-evident concept to anybody.

In short, NLP (Natural Language Processing) is the secret dream of mankind (with some IT/statistical knowledge): a set of appropriate

algorithms which are able to interpret texts on their own. You probably heard the term text-mining. Text mining is the common term for procedures which are connected with text type variables. You can count words – after you identified words, define similarity measures for words or compare different word sets (“How many Shakespaers did write Shekespare’s Works?”).

NLP is a bit more. As I referred to it, definition of a word is not so trivial (in programmatic issues). Are ‘dog’ and ‘dogs’ two different words or not? Syntactically yes, but semantically no. Or let’s consider another example: are the terms “AMI” and “heart attack” identical? The answer might be yes, especially in life sciences, as AMI might mean acute myocardial infarction. But please check the different meanings of AMI [D2-3] and you can easily find examples, where AMI does not stand for infarct.

On the contrary of difficulties the brief summary of MS Simpson and D Demner-Fushman on “Biomedical Text Mining: A survey of recent progress” [D2-4] explains in the required details how many important tasks were already identified and – at least partly – solved.

Going back to the R-packages. The package “* tm*” states that it is a ‘comprehensive text mining framework for R’. It’s documentation can be found here [D2-5]. First of all the documentation makes it clear that the proposed framework was similar in complexity to commercial solutions like GATE, RapidMiner, SAS Miner and others – in 2008, when “

*” was introduced.*

**tm**The framework in itself supports the management of input data (raw, unstructured set of words), tagging of the input data, application of joining and filtering functionalities on the source data. “

*” provides technical support for memory management, while it applies the so called ‘term-document’ matrix approach in retrieval of really important information.*

**TM**I’ll go into more details regarding the original concept and I would like to investigate how this concept has developed during the last 10 years next time.

### End of Day 2

[D2-1] https://awesome-r.com/[D2-2] https://www.tidytextmining.com/

[D2-3] https://www.acronymfinder.com/AMI.html

[D2-4] https://pdfs.semanticscholar.org/6765/0376769aabd43c17de366f96a58961d8d7e0.pdf

[D2-5] https://www.jstatsoft.org/article/view/v025i05

Picture references

/1/ https://www.mediaupdate.co.za/media/142841/what-is-natural-language-processing

/2/ https://www.jstatsoft.org/article/view/v025i05