
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 33676 Articles for Programming

381 Views
SVM is a supervised machine learning algorithm which can be used for both classification or regression challenges but mostly we use it for classification. The classification using svm can be done for two or more categories as well. In R, we can use simply use svm function of e1071 package.ExampleConsider the iris data − Live Demostr(iris)Output'data.frame': 150 obs. of 5 variables: $ Sepal.Length: num 5.1 4.9 4.7 4.6 5 5.4 4.6 5 4.4 4.9 ... $ Sepal.Width : num 3.5 3 3.2 3.1 3.6 3.9 3.4 3.4 2.9 3.1 ... $ Petal.Length: num 1.4 1.4 1.3 1.5 1.4 1.7 1.4 1.5 ... Read More

4K+ Views
The truncation means removing the number of decimal places but not rounding. For example, if we have a value 5.1742145 then truncating to one decimal place will be 5.1 and rounding will be 5.2. In R, we can do this by using trunc function as shown in the below examples.Example Live Demox1

7K+ Views
Sometimes we need maximum values, it helps us to identify which case or subject occurs at the greatest point hence we can understand the limit for the sample or population under study. If we want to find the maximum of values two or more columns for each row in an R data frame then pmax function can be used.ExampleConsider the below data frame − Live Demoset.seed(1997) x1

537 Views
To create a matrix without column and row indices, we first need to create the matrix and then prmatrix function can be used to convert that matrix without column and row indices but we would need to provide the number of rows inside the function. For example, if we have a matrix M that contains 5 rows and 5 columns then it can be converted to a matrix without column and row indices using prmatrix(M,rowlab=rep("",5),collab=rep("",5)).Example Live DemoM1

3K+ Views
The Poisson distribution is a discrete distribution that has only one parameter named as lambda and it is the rate parameter. The rate parameter is defined as the number of events that occur in a fixed time interval. To create a plot of Poisson distribution in R, we can use the plot function with the density of the Poisson distribution using dpois function.Example Live Demoplot(dpois(x=1:50,lambda=3))OutputExample Live Demoplot(dpois(x=1:50,lambda=3),type="l")OutputExample Live Demoplot(dpois(x=1:50,lambda=3),type="b")Output

645 Views
To create a plot without margins, we first need to define that margin in a way that the plot created after that will not have margins and this can be done by using par function. We would need to pass mar function within par function as par(mar=c(0,0,0,0)).Example Live Demopar(mar=c(0,0,0,0)) plot(1:10)OutputExample Live Demobarplot(1:10)Output

128 Views
The pheatmap function is used to create clustered heatmaps but we can change the aesthetics of the plot by using color argument which is one of the main functionalities of pheatmap function. There are many other arguments that differentiate pheatmap from heatmap function.Examplelibrary(pheatmap) M1

508 Views
If we want to create a table of sums of a discrete variable for two categorical variables then xtabs function can be used. The output will be a contingency table or cross tabulation table which looks like a matrix. For example, if we have a data frame df with two categorical column x and y and a count column freq then the table of sums for freq can be created by using xtabs(freq~x+y,data=df1).ExampleConsider the below data frame − Live Demox1

264 Views
To create a rectangle inside boxplot in base R, we can use rect function after creating the boxplot. The rect function has many arguments but for the creation of a rectangle only first four are necessary and these are defined as xleft - a vector (or scalar) of left x positions, ybottom - a vector (or scalar) of bottom y positions, xright - a vector (or scalar) of right x positions and ytop - a vector (or scalar) of top y positions.Example Live Demox

1K+ Views
A three-dimensional array can have matrices of different size and they are not necessarily to be square or rectangular. Also, all the elements in an array are of same data type. If we want to find the mean of a three-dimensional array then apply function can be used where we need to refer the columns and rows of the array elements using combination function.Example Live DemoA1 apply(A1,c(1,2),mean) [,1] [,2] [1,] 5 7 [2,] 6 8ExampleA2