
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 2038 Articles for R Programming

1K+ Views
To understand the difference ordered factors and unordered factors, it is better to understand them by creating the factor vectors by using ordered argument with TRUE and FALSE options. For example, if we have a vector x then it can be ordered or unordered as factor(x,ordered=TRUE) and factor(x,ordered=FALSE).Example1 Live Demox1

787 Views
To combine array of vectors we can use rbind function. For example, if we have multiple vectors say x, y, z of same size or different sizes but the total number of elements are even then we can use rbind(x,y,z) to combine those vectors. Check out the examples to understand how it works.Example1 Live Demox1

5K+ Views
To convert factor levels into character then we can use as.character function by accessing the column of the data frame that contain factor values. For example, if we have a data frame df which contains a factor column named as Gender then this column can be converted into character column as as.character(df$Gender).Example Live DemoConsider the below data frame −set.seed(121) x1

2K+ Views
The boxplot can be created by using boxplot function in base R but the Y−axis labels are generated based on the vector we pass through the function. If we want to remove the axis labels then axes = FALSE argument can be used. For example, if we have a vector x then the boxplot for x without axes labels can be created by using boxplot(x,axes=FALSE).Example Live DemoConsider the below vector x and creating boxplot −set.seed(777) x

11K+ Views
The t test is used to find the p−value for the correlation coefficient and on the basis of that we decide whether there exists a statistically significant relationship between two variables or not. In R, we can perform this test by using function cor.test. For example, if we have a vector x and y then we can find the p−value using cor.test(x,y).Example1 Live Demoset.seed(444) x1

237 Views
In base R, we use boxplot function to create the boxplots but if we have categorical vector and the corresponding numerical vector then the boxplot can be easily created. For this purpose, we should save those vectors in a data frame and use the $ operator and las = 2 argument to create the boxplot as shown in the below example.ExampleConsider the below vectors:Countries Rate

6K+ Views
In R, for the calculation of power we can simply use power operator ^ and this will be also used in case of generating a power sequence. For example, if we want to generate a power sequence from 1 to 5 of 2 then we can use the code 2^(1:5) this will result 2 4 8 16 32.Example Live Demo2^(0:2)Output[1] 1 2 4Example Live Demo2^(0:10)Output[1] 1 2 4 8 16 32 64 128 256 512 1024 Example Live Demo2^(0:50)Output[1] 1.000000e+00 2.000000e+00 4.000000e+00 8.000000e+00 1.600000e+01 [6] 3.200000e+01 6.400000e+01 1.280000e+02 2.560000e+02 5.120000e+02 [11] 1.024000e+03 2.048000e+03 4.096000e+03 8.192000e+03 1.638400e+04 [16] 3.276800e+04 6.553600e+04 1.310720e+05 2.621440e+05 5.242880e+05 [21] ... Read More

49K+ Views
To convert columns of an R data frame from integer to numeric we can use lapply() function. For example, if we have a data frame df that contains all integer columns then we can use the code lapply(df,as.numeric) to convert all of the columns data type into numeric data type.Example1Consider the below data frame − Live Demoset.seed(871) x1

3K+ Views
The point chart can be created by using geom_point function and if we want to create a point chart for single vector then we should pass the vector in both the places inside aes function. Also, by default the points are complete black circles and if we want to change the points to empty points then shape argument can be used.ExampleConsider the below data frame − Live Demoset.seed(171) x

1K+ Views
Random samples can be generated in many ways such as using discrete and continuous distributions, using integer vectors, using numerical vectors, using character vectors and/or factor vectors, also with columns of a data set. If we have the sample that is continuous in nature then the values are likely to contain many values after decimal point and we can limit those values to 4 or use any other limit using round function.Example Live Demox1