Nizamuddin Siddiqui has Published 2307 Articles

How to check if a matrix has any missing value in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 05-Nov-2021 06:41:26

1K+ Views

To check if a matrix has any missing value in R, we can use any function along with is.na function.For Example, if we have a matrix called M then we can use the below command to check whether M contains any missing value or not −any(is.na(M))Example 1Following snippet creates a ... Read More

How to remove line numbers from data.table object in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 05-Nov-2021 06:31:38

2K+ Views

To remove line numbers from data.table object in R, we can set row.names to FALSE and print the data.table object.For Example, if we have a data.table object called DT then we can remove line numbers from DT by using the command given below −print(DT, row.names=FALSE)Example 1To load data.table object and ... Read More

Create stacked bar plot for one categorical variable in an R dataframe.

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 05-Nov-2021 06:20:11

1K+ Views

To create stacked bar plot for one categorical variable in an R data frame, we can use ggplot function and geom_bar function of ggplot2 and provide 1 as the X variable inside aes.For Example, if we have a data frame called df that contains a one categorical column say C ... Read More

Find the value in an R data frame column that exist n times.

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 05-Nov-2021 06:15:19

116 Views

To find the value in an R data frame column that exist n times, we first need to tabulate the column with factor then extracting the levels of the column after that reading them with as.numeric.Check out the Examples given below to understand how it can be done.Example 1Following snippet ... Read More

How to round matrix values in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 05-Nov-2021 06:06:36

3K+ Views

To round matrix values, we can use round function.For Example, if we have a matrix called M and we want to round the value in M to 2 decimal places by using the below command −M

How to display numbers with decimal in R data frame column?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 05-Nov-2021 05:59:31

6K+ Views

To display numbers with decimal in R data frame column, we can use format function with round function and nsmall argument.For Example, if we have a data frame called df that contains an integer column say X then we can display numbers in X with 2 decimal places by using ... Read More

Change the decimal point of every value in an R data frame column.

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 05-Nov-2021 05:54:26

3K+ Views

To change the decimal point of every value in an R data frame column, we can use round function.For Example, if we have a data frame called df that contains a column say X and we want to have each value with 3 decimal places then we can use the ... Read More

Why Output of mean of normal random variable created using rnorm equals to 10 is not 10 in manual calculation with R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 05-Nov-2021 05:49:19

48 Views

When we find the mean of normal random variable which is created with rnorm(“sample_size”, 10) is not 10 because rnorm will create a random variable hence mean will be changed but as we increase the sample size the mean will become closer to 10.Check out the Examples given below to ... Read More

Find the missing numbers in a sequence in R data frame column.

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 03-Nov-2021 10:13:49

794 Views

To find the missing numbers in a sequence in R data frame column, we can use setdiff function.For Example, if we have a data frame called df that contains a column say X and we want to check which values between 1 to 20 are missing in this column then ... Read More

How to extract columns having at least one non-duplicate in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 03-Nov-2021 10:07:38

72 Views

To extract columns from an R data frame having at least one non-duplicate, we can use Filter function.For Example, if we have a data frame called df that contains some columns having duplicate values and columns that do not contains at least one non-duplicate then we can extract columns having ... Read More

Advertisements