90 likes | 106 Views
R is a programming language that is used for statistical and visualization analysis. It is also used for reporting. We use this language for data analysis, which gives us results in the form of graphs, pie charts, etc.
E N D
R Programming Language Overview www.studysection.com
R Programming Language Overview R is a programming language that is used for statistical and visualization analysis. It is also used for reporting. We use this language for data analysis, which gives us results in the form of graphs, pie charts, etc. R is an interpreted programming language. It is a simple and well-developed language that uses loops, functions, conditions, etc. For calculations, it uses arrays, matrix, list, and vectors. It provides a graphical representation of the data. It also processes large datasets.
The basic syntax is given below: In the R language, there is no need to give data type to a variable. Directly, give value to the variable. Following is the basic syntax of how to print string in R language: test<-” Good Morning”; print(test); o/p: [1] “Good Morning” To comment code in R language # is used. Eg: #test<-” Good Morning”;
DATA TYPES: To check the data type of the variable class() is used. • Logical: It is a type of data type used for True or False value.Eg: test<-TRUEprint(class(test))o/p: [1] "logical" • Numeric: It is used for numerical data or numbers.Eg: test<-8print(class(test))o/p: [1] "numeric" • Complex: It is used for complex data that contains iota values.Eg: test<-1+2iprint(class(test))o/p: [1] "complex" • Character: It is used for all the characters. For strings, it belongs to the character datatype.Eg: test<-”HELLO”print(class(test))o/p: [1] "character" • Raw: It is used for the raw character.Eg: test<-charToRaw(”HELLO”)print(class(test))o/p: [1] "raw"
R-Objects: These objects use data types as described above. • Vectors: Most basic R-object is vectors. Function c() is used for the vectors.Eg: test <- c('bmw','audi',’maruti’)print(test)o/p: [1] "bmw" "audi" "maruti"# To find class of the vectorprint(class(test))[1] "character" • Lists: It contains different types of elements in it. It can be numbers, characters, functions, even other lists, etc.Eg: l1 <- list(c(1,2,3),1.5,3.8)print(l1)o/p: [[1]] [1] 1 2 3[[2]] [1] 1.5 3.8 • Matrices: Matrix is a 2-D rectangular data set. It is created using vectors in matrix().Eg: m = matrix( c('1','2','3','4','5','6'), nrow = 2, ncol = 3, byrow = TRUE)#Where nrow is for number of rows, ncol is for number of columns.print(m)o/p: [,1] [,2] [,3] [1,] "1" "2" "3"[2,] "4" "5" "6"
Arrays: Unlike matrices, Arrays can have any number of dimensions. ‘dim’ attribute is used to create the required number of dimensions.Eg: arr <- array(c('e1','e2'),dim = c(3,3,2))# Set dimension of 3 * 3 and the number of arrays will be 2.print(arr)o/p:, , 1[,1] [,2] [,3] [1,] "e1" "e2" "e1"[2,] "e2" "e1" "e2"[3,] "e1" "e2" "e1",levels [,1] [,2] [,3] [1,] "e2" "e1" "e2"[2,] "e1" "e2" "e1"[3,] "e2" "e1" "e2" • Factors: They are created using vectors. factor() is used to create the factors and nlevels() gives the count of levels.Eg: f1<-c('1','1','2','3','3','2','1') # Create a factor object. fo <- factor(f1) # Print the factor. print(f1) print(nlevels(fo)) o/p: [1] 1 1 2 3 3 2 1 Levels: 1 2 3 [1] 3 • Data Frames: It is used for tabular data objects. Every column can contain different types of data. It is created with a list of vectors having an equal length. Data frames are created using data.frame().Eg: vehicle <- data.frame(car = c("c1", "c2","c3"),bike = c(1, 2, 3))print(vehicle)o/p: car bike1 c1 12 c2 23 c3 3
Online R Programming Certificate Exam R Programming Certification Exam(Foundation) R Programming Certification Exam(Advanced) R Programming Certification Exam(Expert)
About StudySection • Welcome to StudySection - the most loved online platform for eCertification in several subjects including but not limited to Software Development, Quality Assurance, Business Administration, Project Management, English, Aptitude and more. From more than 70 countries students are StudySection Certified. If you are not yet StudySection certified it's not late. You can start right now. • Being StudySection Certified helps you take your education level few notches up and have an edge over other candidates when you need it the most. Globally, our students are employed in different organizations and are utilizing the benefit of being certified with us.