Nizamuddin Siddiqui has Published 2307 Articles

How to create bar plot in base R with different limits for Y-axis?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 05-Mar-2021 07:24:35

1K+ Views

To create a bar plot in base R with different limits for Y-axis, we can use ylim argument but generally that behaves badly, such as extending the bars below X-axis. Therefore, we need to fix those things. Check out the below example to understand how it can be done.Example> x ... Read More

How to use column with colours to change the colour of points using ggplot2 in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 05-Mar-2021 07:17:27

2K+ Views

If we have a colour column in an R data frame and we want to change the point colours in ggplot2 using that column then colour argument will be used. For example, if we have a data frame called df that contains three columns say x, y, and color then ... Read More

How to match a column in a data frame with a column in another data frame in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 05-Mar-2021 07:17:06

3K+ Views

To match a column in a data frame with a column in another data frame, we can use match function. For example, if we have two data frames called df1 and df2 each having one similar column and the second having an extra column then the matching can be done ... Read More

How to find the length of columns for missing values in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 05-Mar-2021 07:16:44

419 Views

The length of columns for missing values means the number of missing values in the data frame. This can be easily done with the help of colSums function where we will find the total number of NA values with is.na. For example, if we have a data frame called df ... Read More

How to add suffix to column names in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 05-Mar-2021 07:12:54

5K+ Views

To add suffix to column names in R, we can use paste function. For example, if we have a data frame called df that contains three columns say x, y, and z and we want to add a suffix to these columns say underscore1 (_1) then it can be done ... Read More

How to add a vector to each row of a matrix in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 05-Mar-2021 07:12:36

879 Views

To add a vector to reach row of a matrix, we can use addition sign (+) and create the repetition of the vector up to the number of rows in the matrix. For example, if we have a matrix called M then a vector say v can be added to ... Read More

How to get the summary statistics including all basic statistical values for R data frame columns?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 05-Mar-2021 07:12:00

194 Views

When we apply summary function in R, the output gives minimum, first quartile, median, mean, third quartile, and maximum but there are many other basic statistical values that help us to understand the variable such as range, sum, standard error of mean, variance, standard deviation, and coefficient of variation. Therefore, ... Read More

How to convert a column values to column names in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 05-Mar-2021 07:08:50

5K+ Views

To convert a column values to column names, we can use dcast function of reshape2 package. For example, if we have a data frame called df that contains two columns say x and y, where x is categorical and y is numerical. Now if we want to convert the categories ... Read More

How to find the sum of variables by row in an R data frame?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 05-Mar-2021 07:08:33

553 Views

To find the sum of variables by row we mean the sum of row values in the data frame. This can be easily done with the help of rowSums function. For example, if we have a data frame called df then the sum of variables by row can be found ... Read More

How to add proportion total at margins on a table in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 05-Mar-2021 07:08:14

648 Views

The proportion total in a table helps us to understand the contribution of each row and each column in the total. Therefore, if we want to find the proportion total at margins, we can use addmargins function if we have the proportion table and if we do not have that ... Read More

Advertisements