Nizamuddin Siddiqui has Published 2307 Articles

How to find the number of zeros in each column of a data.table object in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 15-Nov-2021 06:22:07

101 Views

To find the number of zeros in each column of a data.table object in R, we can follow the below steps −First of all, create a data.table object.Then, use colSums function to find the number of zeros in each column.Example 1Create the data.table objectLet’s create a data.table as shown below ... Read More

How to separate two values in single column in data.table object in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 15-Nov-2021 06:18:16

264 Views

To separate two values in single column in data.table object in R, we can follow the below steps −First of all, create a data.table object.Then, use separate function from tidyr package to separate the values in single column.ExampleCreate the data.table objectLet’s create a data.table object as shown below −library(data.table) DTRead More

How to convert first letter into capital in single column data.table object in R using a function?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 15-Nov-2021 06:15:09

329 Views

To convert first letter into capital in single column data.table object in R, we can follow the below steps −First of all, create a data.table object with string column.Then, use capitalize function from R.utils package to convert first letter into capital in single columnExampleCreate the data.table objectLet’s create a data.table ... Read More

How to convert first letter into capital in data.table object column in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 15-Nov-2021 06:12:11

93 Views

To convert first letter into capital in data.table object column in R, we can follow the below steps −First of all, create a data.table object with string column.Then, use sub function to convert first letter into capital in string column.ExampleCreate the data.table objectLet’s create a data.table as shown below −library(data.table) ... Read More

How to remove a particular value from a vector in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 12-Nov-2021 08:37:14

1K+ Views

To remove a particular value from a vector, we can use negation of value.For example, if we have a vector called V that contains repetitive values starting from 1 to 10 and if we want to remove all 10s from V then we can use the command given below −V

How to find rows in an R data frame that do not have missing values?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 12-Nov-2021 08:27:59

402 Views

Dealing with missing values is one of the most critical task in data analysis. If we have a large amount of data then it is better to remove the rows that contains missing values. For the removal of such rows we can use complete.cases function.For example, if we have a ... Read More

How to highlight a value with underline in base R plot?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 12-Nov-2021 08:24:01

578 Views

To highlight a value with underline in base R plot, we can use underline function within text function. The text function will be used to define the value that we need to underline in the plot and underline function will only underline that part.Check out the below given example to ... Read More

How to find the last non-missing value in each column of a data.table object?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 12-Nov-2021 08:22:30

473 Views

To find the last non-missing value in each column of a data.table object, we can use lapply function along with tail function for NA values.For example, if we have a data.table object called DT then we can find the last non-missing value in each column of DT by using the ... Read More

How to convert a text vector into a matrix in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 12-Nov-2021 08:15:37

571 Views

Sometimes numerical values are being read as strings and hence creating a matrix using that vector is not straight forward.For the conversion of text vector into a matrix, we need to use scan function and specify the appropriate number of rows or columns as shown in the below given examples.Example ... Read More

Find the combination of columns for correlation coefficient greater than a certain value in R

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 12-Nov-2021 08:13:33

509 Views

To find the combination of columns for correlation coefficient greater than a certain value, we would first need to create the correlation matrix and then melt the correlation with the help if melt function of reshape2 package. After that subset of the output will be taken based on the value ... Read More

Advertisements