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
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
ABC <- 123
R ABC -> 123
ABC = 123
XYZ <- c(cheer)
Would give output
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.
TO KNOW WHAT KIND OF VECTOR USE “TYPEOF”
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.
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.
A <-c(“aa”,”bb”,”cc”)B<-c(“4”,”5”,”6”)C<- c( A, B, “7”)
Therefor C would be
Now calling for “cc” here we have to use
Where 3 is the position of the vector and A is the object to check into, so the output would be
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.
List<- list(“cheer”,”leer”, c(22,44,55),678,”NEAR”, TRUE)
To view the created list we can use
The output would be
[] “cheer”[] “leer”[] 22 44 55[] 678[] “NEAR”[] TRUE
To access a specific object for example the 4th element we use
This would give the output
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.
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.