Skip to main content
Karin Insights

The first step to enter the world of R

February 2, 1400Programmingtutul

After the talks that here I talked about my plans for the blog, today I decided to start the first post of this relatively specialized field. Today's post is about the funny language of R and my first experiences during 5-6 months of coding with it. which I think can be a rough road map for R developers who just want to start.

The first step to get familiar with R is to install R. That's why we go to our official website and the latest version Download we do The important thing is to get the latest version. Because many of the packages we want to work with are compatible with new versions of R and cannot work with old versions. After downloading and installing R, now we have an environment for scripting in R language. Exactly similar to what we have for Python by installing Python. An environment like the one below where we can do various programming tasks such as addition and subtraction. Where we can perform analytical and statistical tasks such as drawing various graphs, regressions and probability distributions and get output.

Now, for example, in this figure, I was able to draw the statistical graph of the incidence rate in the R environment and get answers from simple relations such as logarithm 2.

And but R Studio

The RGui environment is a complete environment that is useful for fast coding with R. But if we want to introduce a more complete environment with more access and a more beautiful design, we reach RStudio. R Studio is considered as an IDE of R language. Of course, it is not as beautiful and easy as the JetBrains IDE, but it is a light and open-source program in which we can develop all kinds of scripts and R packages, and most importantly, beautiful web applications. Therefore, in the next step, we will download and install this program in order to continue working together on an R project.

As we can see in this figure, there are different types of R projects in R-Studio. There is a model for designing and developing R packages, which of course I don't know anything about. There is a normal project model that is created by clicking New Project and another model is Shiny Web Application that I have been working with all this time.

What is shiney and what does it do?

Shiny is one of the R packages that helps a lot in the development and design of statistical and analytical or management websites. With Shaini, we can create a site, as we used to do with Html or Css and PHP. Now, with Shiney, we can easily put all these together several times. without worrying about the responsiveness of the program or its appearance in different browsers. In fact, Shiney is a very powerful package that makes websites like visit let's hit Without thinking about the length and width or the height of the external elements of the site, it is very easy and easy to get the output from our statistical analysis.

Next, by clicking on Shiny Web and creating a new project, we will go to the design and implementation of an easy web page. The figure below shows our first encounter with a shiny web. The first thing we have to do is click on app.R which can be seen in the right column in the files section. This file is like index.php in website design. Because when the program is run, it is the first file that is opened and its codes are read. To run the program, click on Run App and wait for it to load.

When the program is loaded, I see a page similar to the one below. A reactive and responsive page that reacts very quickly to the user's inputs and changes the output. As you can see, all this is written in less than 50 lines (including comments). That's what shows that Shiney is much easier and faster than what we even think.

So stay with me in the next episode to talk more about the components of a Shiny program and learn how to code with Shiny and have fun.