Nizamuddin Siddiqui has Published 2307 Articles

How to check if some specific columns of an R data frame are equal to a column or not?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 21-Nov-2020 05:35:11

291 Views

If we have a large amount of data in a data frame and we suspect that some of the data columns are repeated or some of them are equal to a particular column then we can use sapply function in base R to figure it out. In this way, we ... Read More

How to convert a date or date vector to POSIXct in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 21-Nov-2020 05:33:09

4K+ Views

To convert a date or date vector to POSIXct, we can use as.POSIXct function but we also need to pass the appropriate date format inside the function. For example, if we have a date "2020-11-14" then it can be converted to POSIXct by using as.POSIXct("2020-11-14", format="%Y-%m-%d").Example1Live Demo> date1 as.POSIXct(date1, format="%Y-%m-%d")Output[1] ... Read More

How to create a horizontal bar plot using barplot function in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 21-Nov-2020 05:31:01

179 Views

To create a bar plot in base R, we can directly use barplot function but the table of frequencies should be passed inside this function. If we want to create the barplot in horizontal manner then horiz=TRUE argument must be added. For example, if we have a vector x that ... Read More

How to remove rows that contains NA values in certain columns of an R data frame?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 21-Nov-2020 05:29:15

1K+ Views

If we have missing data in our data frame then some of them can be replaced if we have enough information about the characteristic of the case for which the information is missing. But if that information is not available and we do not find any suitable way to replace ... Read More

How to create a replicated list of a list in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 21-Nov-2020 05:26:32

2K+ Views

Sometimes we want to created repeated values, this is helpful in different scenarios such as measuring an effect of a constant on multiple variables. The list values can be also replicated for similar purpose of analysis. The replication of list of a list can be created by using rep function. ... Read More

How to create a subset of a data frame in R without using column names?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 21-Nov-2020 05:23:41

421 Views

The subsetting of a data frame can be done by using column names as well as column number. Also, we can subset by subsequent as well as non-subsequent column numbers. For example, if we have a data frame df that contains column x, y, z then we can make a ... Read More

How to create a line that passes through specified points in an R plot?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 21-Nov-2020 05:20:43

567 Views

To create a line that passes through specified points, we first need to create the plot then using plot function then xspline function can be used to join the points with straight lines. The xspline function is specifically designed to draw curves and hence it can be also used to ... Read More

How to create an empty plot using ggplot2 in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 21-Nov-2020 05:19:05

2K+ Views

The two most easy ways to create an empty plot using ggplot2 are using geom_blank function and also adding the theme_bw along with the geom_blank. The geom_blank will create an empty plot with white gridlines and grey background, on the other hand, addition of theme_bw will create the empty plot ... Read More

How to perform post hoc test for Kruskal-Wallis in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 21-Nov-2020 05:16:30

6K+ Views

The Kruskal-Wallis test is the non-parametric analogue of one-way analysis of variance. The non-parametric tests are used in situations when the assumptions of parametric tests are not met. If we find significant difference in Kruskal-Wallis then post hoc tests are done to find where the difference exists. For this purpose, ... Read More

How to create two 3d plots at a time in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 21-Nov-2020 05:13:06

169 Views

The rgl package is specifically designed to create real-time interactive 3D plots and we can create two 3d plots using plot3d function of this package. Also, these plots can be viewed in the R console at a single point of time with the help of open3d() function.ExampleLoading rgl package:Example> library(rgl) ... Read More

Advertisements