Nizamuddin Siddiqui has Published 2307 Articles

What is the difference between ls() command and objects() command in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 04-Jan-2021 06:35:43

332 Views

They are actually no difference between the two commands as they give the same result that is the number of objects in the current workspace. If we have five different type of objects say a data frame, a matrix, a list, a data.table object, and a vector then both the ... Read More

What are levels in a column of a data frame in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 04-Jan-2021 06:34:37

1K+ Views

Most people get confused about levels and characters in R, especially the newbies. The difference is that levels specifically define the factor levels of a factor column and the characters are simple the character column that is not a factor or is not used as a factor but can be ... Read More

How to create a plot title with unicode characters using ggplot2 in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 02-Jan-2021 10:29:54

462 Views

If we want to use unicode characters in the title for a plot created with the help of ggplot2 package then the ggtitle function will be used combined with functions called expression and paste. Using the expression and paste functions, we can write unicode characters for the title of the ... Read More

How to visualize a data frame that contains missing values in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 02-Jan-2021 10:27:27

280 Views

If a data frame contains missing value then visualising it in base R is not easily possible but we can make use of visdat package for this purpose. The vis_dat function of visdat package helps to visualize any data frame even if it contains missing values. For example, if a ... Read More

How to create a line for equal values of x and y in scatterplot in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 02-Jan-2021 10:25:29

169 Views

To create a line for equal values of x and y in scatterplot, we can make use of segments function in base R but this can be done after creating the plot with the help of plot function. The segments function has four arguments, x0, y0, x1, and y1, we ... Read More

How to plot the confidence interval of the regression model using ggplot2 with transparency in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 02-Jan-2021 10:21:50

637 Views

To plot the confidence interval of the regression model, we can use geom_ribbon function of ggplot2 package but by default it will have dark grey color. It can become transparent with the help of alpha argument inside the same function, the alpha argument can be adjusted as per our requirement ... Read More

How to extract the column from a list of data frames in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 02-Jan-2021 10:19:01

629 Views

In Data Analysis, we often required to extract a single value, a single row, or a single column for a specific analysis. For example, if data frame contains column defined as height and weight then we might want to use only height then it can be extracted, this could be ... Read More

How to convert a matrix into a color matrix in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 02-Jan-2021 10:14:37

923 Views

To convert a matrix into a color matrix, we can make use of image function. There are multiple ways for assigning the colors but the easiest one might be by defining the minimum and maximum value in the matrix. Also, we can do this by using the shades of a ... Read More

How to create a plot in base R with tick marks but excluding axes lines?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 02-Jan-2021 10:09:28

99 Views

To create a plot with tick marks but without axes lines, we first need to create the plot without axes and then add the tick marks. This can be done with the help of plot function and axis function in base R. The axis function will help us to decide ... Read More

How to combine lists of data frames in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 02-Jan-2021 10:03:42

359 Views

If we have a list of data frames and the size of those data frames is same then we might want to combine the lists so that the data frames can be combined. This can be done by using mapply function along with cbind. For example, if we have two ... Read More

Advertisements