r language tutorial - r language for beginners
R is a programming language developed by Ross Ihaka and Robert Gentleman University of Auckland, New Zealand. This language was named R after them and is currently developed by the R Development Core. It is available for free under the GNU General Public License. It is a language that is used for static analysis, graphics representation and reporting. This language is compatible with Windows, Linux and Make all platforms.
r language advantages - r language benefits
1- This language is used for software development and it is the primary language for data science, it is used by RShiny for the development of web applications.
In this, keeping in mind the need of the user, more than 10 thousand packages are available.
3- It does not require any compiler to execute the code.
4- It works on all platforms
5- It has the facility of graphics representation library like ggplot etc.
6- It has the ability to store and process a large amount of data, it also processes unstructured data.
7-It is easily integrated with other programming languages like java, c++, python etc.
8- It is available free on open source
9- It is also used for machine learning
r language data types
1- numeric data
This type of data in which numerical values are stored
Example
num1=3
>num1
[1] 3
>class(num1)
[1] "numeric"
2- character data
Words are stored inside this type of data. Double quotes have to be used to store character data.
Example
char1 = "hello"
>Char1
[1] "hello"
>class(char1)
[1] "character"
3- complex data
Two types of values are stored in this type of data, these are complex values.
Example
complex1=3+10i
>complex1
[1] 3+10i
>class(complex 1)
[1] "complex"
4- logical data
Logical value is stored inside this type of data, this logical value is true or false like adding true and true is true.
>log1= true
>log
[1] TRUE
R operators
r language commands
1- arithmetic operators
This type of operator is used for maths tasks.
Example
num1=20
num2=10
>num1+num2
[1] 30
>num1-num2
[1] 10
>num1*num2
[1] 200
>num1/num2
[1] 2
2- relational operator
This type operator is used to create relation between two variables
>num1==num2
[1] FALSE
>num1>num2
[1] TRUE
>num1<num2
[1] FALSE
>num1!=num2
[1] TRUE
Through the above example you can see the relational operator
3-logical operators
Using this type of operator we can see what happens when true and true come together and what happens when true and false come together
>log1= true
>log2= false
>log1& log2
[1] FALSE
>log1&log1
[1] TRUE
4-assignment operators
The use of this type of operator is added to something different, for example, see which operators are these.
A=1
,
>a
[1] 1
>b<-3
>b
[1] 3
>10 -> g
>g
[1] 10
R loops
Loops are a type of data in which the condition is applied that the condition it keeps on repeating and it is relieved to repeat until that condition becomes wrong There are 3 types of loops inside R
1- while loop
2-for in loop
3- repeat loop
R control statement
1- if statement
इस प्रकार के स्टेटमेंट एक कंडीसन को बताते हैं कि अगर ऐसा होगा तो कैसा रिजल्ट होना चाहिए
2- if else statement
इस प्रकार के स्टेमेन्ट भी कंडीसन को बताते हैं यदि ऐसा होगा तो ऐसा रिजल्ट होना चाहिए और यदी ऐसा नही होगा तो कैसा होना चाहिए
3- else statement
इसप्रकार के स्टेमेन्ट केवल एक कंडीसन अगर ऐसा नही होगा तो ऐसा होना चाहिए
4- switch case statement
5- break statement
6- next statement
R data objects
1- vector data
Inside this type of data, many values of the basic data types that we have are assigned together.
In this c is used to combine
>vec1<-c(1,2,3)
>vec1
[1] 123
>vec2<-c("a", "b", "c")
>vec2
[1] abc
>vec3<-c(T,F,T)
>vec3
[1] TFT
2- matrix
In this type of data, the data is stored in the form of matrices, these metrics are made in rows and columns.
>m1 <-matrix(c(1,2,3,4,5,6), nrow=2, ncol=3)
>m1
Or
>m1 <-matrix(c(1,2,3,4,5,6), nrow=2, ncol=3, by row=T)
>m1
3- lists
In this type of data, a list of data is made, in which many data is stored in a variable and their data types are different like
l1<- list(1, "a", TRUE)
>l1
>class(l1[[1]])
[1] numeric
>l2 <-list(c(1,2,3), c("a", "b", "c"), c(T, F,T)
>l2 [[2]] [2]
4- arrays
Arrays are said to be a small piece of any place or system of a type, if we talk about arrays, then it means many cities are included in it.
>vec1<-c(1,2,3,4,5,6)
>vec2<-c(7,8,9,10,11,12)
>array (c(vec1,vec2), dim=c(2,3,2)
where 2,3,2 are row, column and dim
5- data frame
Data frame means that we create a table in which there is a field first and the data of that field is stored inside that field, it is called data frame.
>data.frame(fruit_name=c("apple", "banana", "orange"), fruit_cost=c(10,20,30)) ->fruits()
>fruits
In the above furit_name is column 1 and inside which the name of the flow is stored, the same fruit_cost is the price of the fruit which is column 2, thus creating a data frame
R string and function
1- string
2- nchar()
3- paste ()
4-strsplit()
5-sub()
6-substr()
7-tolowear()
8-touper()
r language graphs
1- R Box and whisker plot
3- R line graphs
1- R bar graph chart
2- legend () function in R
r language histogram
Histogram is a very easy way to display any date, by importing any input data and showing it in different types of histograms so that the viewer can understand easily and quickly.
>ggplot()
>ggplot(data=diamond, aes(x=price))
>ggplot(data=diamond, see(x=price))+geom_histogram
Basic of PHP language
r pie chart
R Pie chart
A pie chart is a type of graph that is used to display data.
x<-c(21,62,10,53)
labels<-c("india", "africa", "china", "nepal")
pie(x,labels,main="list of countries", col=rainbow (length(x)))
3D Pie charts
I hope that you must have understood R easily, you must have come to know its basics.
Types of deta in PHP
PHP full course in hindi
0 Comments