Nizamuddin Siddiqui has Published 2307 Articles

How to create the plot of a vector that contains missing values by adding the missing values in base R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 05-Feb-2021 10:03:42

257 Views

If there are missing values in a vector then the plot of such vector will not have all the values, only the non−missing values will be shown. If we want to create the plot by adding the missing values in the plot then we need to define the X−axis for ... Read More

How to print a large number of values in R without index?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 05-Feb-2021 10:00:33

838 Views

Whenever we print any vector then the left-hand side of the R window shows indexing, even if we have one value in the vector the index will be there. For example, if we print a vector that has value equal to 2 then the print output will be [1] 2, ... Read More

How to round exponential numbers in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 05-Feb-2021 09:56:22

903 Views

The exponential numbers are also called scientific numbers and these numbers have exponent representation by the letter e. For example, a number 12340000 can be represented as 1.234e + 107. We can round this to 1.2e + 107 and in R it can be done with the help of singif function.Example1 Live Demox1

How to create a vector with all dates in a particular year in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 05-Feb-2021 09:33:50

659 Views

We know that some years are leap years and some are normal years. The leap years have 366 days and the normal years have 365 days. To create a vector with all dates in a particular year we can use first date and the last date of the year by ... Read More

How to change the color of X-axis label using ggplot2 in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 05-Feb-2021 09:05:04

6K+ Views

The default color of labels is black but we might want to change that color to something else so that we can get attention of the viewer to the labels if it is needed. To change the color of X-axis label using ggplot2, we can use theme function that has ... Read More

How to extract column names that do not have even one missing value in an R data frame?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 05-Feb-2021 08:59:48

309 Views

The extraction of column names that do not have missing values can be done with the help of colnames function along with the complete.cases function. The complete.cases function will extract the columns that do not have missing values then colnames will extract those column names only.Example1Consider the below data frame ... Read More

How to convert dot to comma for numerical columns in an R data frame?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 05-Feb-2021 08:55:26

2K+ Views

Most European countries use a comma in place of a decimal. Therefore, if we have a data set that contains dot as a decimal market and we need to use that four such European countries or if dot is recorded in place of comma then we can replace the dot ... Read More

How to change the background color of legend in base R plot?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 05-Feb-2021 08:52:12

2K+ Views

To create the legend for a plot in base R, we can use legend function and if the background color of the legends needs to be changed from white to any other then bg argument in legend function will be used. For example, to change the background color to red ... Read More

How to increase the width of the median line in boxplot using ggplot2 in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 05-Feb-2021 08:48:53

803 Views

The default width of the median line is wider than the rest of the lines that represent minimum, first quartile, third quartile or maximum but we can make it a little wider to make it more appealing. This can be done with the help of fatten argument inside geom_boxplot function, ... Read More

How to change the color of points in a scatterplot using ggplot2 in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 05-Feb-2021 08:45:38

17K+ Views

To color the points in a scatterplot using ggplot2, we can use colour argument inside geom_point with aes. The color can be passed in multiple ways, one such way is to name the particular color and the other way is to giving a range or using a variable. If range ... Read More

Advertisements