official logo of RStudio

BEGINNER’S GUIDE TO RSTUDIO

Milounee Purohit
4 min readMar 10, 2019

R Studio is a free IDE(integrated development environment: something that lets software engineers and programmers develop programmed with ease.) for the programming language R. It consists of various packages such as tidyverse, shiny, Rmarkdown , packrat etc are essentially just bundles of codes which makes it easier to code.

When you open R studio you see a screen like

screenshot of the RStudio

Here,the top left window is a called the source which is a built in text editor. the one under it is a console where the command is printed and the output would be viewed, after that the top right corner is called an environment which shows us the already existing Robject lists(explained below). The bottom right is where all the files and “help” for R studio is.

In this article we will see how basic operations in R work. R is a case insensitive and friendly platform. every object created in R is called an R object. Vector is the basic data structure in R. There are mainly two types of vectors- Atomic vectors and Recursive vectors(lists). Atomic vectors are used for homogeneous data types and lists for heterogeneous data. however since R is a dynamic platform, we need not specify the type of vector.

ASSIGNMENT OF VALUES IS DONE USING THE ASSIGNMENT OPERATORS

Eg:

ABC <- 123

O

R ABC -> 123

OR

ABC = 123

OR

XYZ <- c(cheer)
>ABC

Would give output

>123

ARITHMETIC OPERATIONS

Arithmetic operations in R are similar to using layman text syntax

For addition “+”

For subtraction “-“

For multiplication “*”

For division “ /”

However, these functions can be easily performed using calculator also, so the integrated use of it with out data set later would make these basic functions useful.

Examples:

>x<-123*2
>x
>246
Y <-67
>x*Y
>8241

TO KNOW WHAT KIND OF VECTOR USE “TYPEOF”

>typeof (ABC)

>double

You might be wondering why is it important to understand or know the type of vector we have used. It is necessary for when you want conduct an explicit coercion or to understand an implicit coercion. When you put in a function with a wrong type, r will run implicit coercion. For example , if you assign the value of 7939 in purely a categorical manner, R would still consider it as a numeric one and do implicit coercion. So, to make R understand that it is categorical we use the command “as.character” to inform it that 7939 is a character and not a number.

Ie,

>abc<-7939
>abc<-as.charachter(7939)

So it will show as “7939” in the R environment.

VECTOR ACCESSING AND MANIPULATION

You can access an individual element of a vector by its position. Multiple vectors can be accessed the same way.

Eg

A <-c(“aa”,”bb”,”cc”)B<-c(“4”,”5”,”6”)C<- c( A, B, “7”)

Therefor C would be

aa,bb,cc,4,5,6,7

Now calling for “cc” here we have to use

>A[3]

Where 3 is the position of the vector and A is the object to check into, so the output would be

>cc

CREATING LISTS IN R

Lists are more complex R objects which contain elements of different types of data structures eg-numbers, strings, vectors .List is created using list() function.

Eg:

List<- list(“cheer”,”leer”, c(22,44,55),678,”NEAR”, TRUE)

To view the created list we can use

>print(List)

The output would be

[[1]][1] “cheer”[[2]][1] “leer”[[3]][1] 22 44 55[[4]][1] 678[[5]][1] “NEAR”[[6]][1] TRUE

To access a specific object for example the 4th element we use

>list[[4]]

This would give the output

>[1]678

MATRIX

Matrix in R are much like Matrix in maths. They are the R objects in which the elements are arranged in a two-dimensional rectangular layout(atomic variables). We use matrices containing numeric elements to be used in mathematical calculations.

A Matrix is created using the matrix() syntax such that matrix(data,nrow,ncol,byrow,dimnames) where data is the value or variable to be put in matrix, nrow and ncol are the numbers of rows and numbers of columns to be created respectively and dimnames are the names to be assigned to the rows and columns.

Eg

ABC <- matrix(c(1:12), nrow=4,byrow=4)Print(ABC)[,1] [,2] [,3][1,] 1 2 3[2,] 4 5 6[3,] 7 8 9[4,] 10 11 12

With this we have learned the basics of Rstudio, however for Rstudio to be useful for bigdata we need to learn a lot more about data frames, importing of datas,loops etc. Due to the simplicity of usage that Rstudio brings to the coding and understanding it is one of the most recommended platforms by the coders.

--

--