
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

367 Views
Often, we have multiple values, vectors or columns of an R data frame that needs to be plotted on a single graph so that we can compare them at the same time or they have some kind of relationship among them. Therefore, we can use layout function along with matrix function to divide the plot window as shown in the below exampleConsider the below layout and plot of individual values −Examplelayout(matrix(c(1, 2, 3, 3, 4, 5, 6, 6), nrow=4, ncol=2, byrow=FALSE)) plot(500) plot(525) plot(530) plot(531) plot(540) plot(528)OutputChanging the layout and creating the plots −Examplelayout(matrix(c(1, 2, 3, 3, 4, 5, 6, ... Read More

961 Views
The fisher test helps us to understand whether there exists a significant non-random relationship among categorical variables or not. It is applied on contingency tables because these tables are used to represent the frequency for categorical variables and we can apply it on a matrix as well as matrices have the similar form. In R, we can use fisher.test function to perform the fisher test.Example Live DemoM1

2K+ Views
If a column in an R data frame contain string values that are separated with an underscore and stretches the size of the column values that also contain common values then it would be wise to remove underscore sign from all the values at once along with the values that is common. This will help us to read the data properly as well as analysis will become easy. For this purpose, we can use gsub functionConsider the below data frame −Example Live Demoset.seed(191) ID

2K+ Views
If we have a grouping column in an R data frame and we believe that one of the group values is not useful for our analysis then we might want to remove all the rows that contains that value and proceed with the analysis, also it might be possible that the one of the values are repeated and we want to get rid of that. In this situation, we can do subsetting of the data frame using negation and single square brackets.Example Live Demoset.seed(1212) x

476 Views
We know that a list can multiple elements of different types as well as of different size. For example, a list that contains two elements then one element may contain fifteen elements and the other might have twenty-five elements. In this situation, we might want to fill the first element with ten more elements so that the size of both the elements become equal. This can be done by using lapply function as shown in the below examples.Consider the below list −Example Live Demoset.seed(101) x1

7K+ Views
Each value in Bernoulli random variable represents success or a failure for a single trial that makes it different from Binomial random variable because a Binomial random variable represents number of success or failure for a number of trials. To generate a Bernoulli random variable, we can use rbinom function but we need to pass 1 for size argument.Example Live Demorbinom(120, 1, 0.71)Output[1] 1 1 1 1 1 1 0 0 0 1 1 1 1 1 1 1 1 1 1 0 0 0 1 1 1 0 0 0 1 1 1 1 1 1 1 0 ... Read More

846 Views
A data frame in R can have infinite number of unique values and it can also contain many repeated values. Therefore, finding the number of all unique values in the data frame can help us to understand the diversity in the data but this most done in situations where we expect to have repeated elements otherwise it would not make sense. To count the number of occurrences of all unique values, we can use table function along with the unlist as shown in the below examples.Consider the below data frame −Example Live Demox1

1K+ Views
In general, we can say that the homogeneity of variance test is the type of test that compares the variance of two or more variables and finds the significant difference between or among them if exists. For a two-way anova, one of the most commonly used homogeneity of variance test is Levene’s Test and it can be easily done with the help of leveneTest function of car package in base R.Consider the below data frame −Example Live Demoset.seed(151) x1F) group 6 0.6593 0.6835 13

9K+ Views
In data analysis, sometimes we need to count the number of values that are greater than or less than a certain value, and this certain value could be a threshold. For example, we might have a vector that contain values for blood pressure of people and we might want check how many values are greater than 120. In this type of situation, we can use length function as shown in the below examples.Example Live Demox11])Output[1] 9 Example Live Demox25])Output[1] 93Example Live Demox35])Output[1] 42Example Live Demox40])Output[1] 108Example Live Demox51])Output[1] 107Example Live Demox65])Output[1] 31Example Live Demox71])Output[1] 21Example Live Demox84])Output[1] 19Example Live Demox9118])Output[1] 11Example Live Demox105000])Output[1] 68Read More

2K+ Views
The matrix can be created by using matrix function in R and if we want to create a matrix by replicating a vector then we just need to focus on the replication. For example, if we have a vector V and we want to create matrix by replicating V two times then the matrix can be created as matrix(replicate(2,V),nrow=2).Example1 Live DemoV1