Nizamuddin Siddiqui has Published 2307 Articles

Find the column index of least value for each row of an R matrix

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 01-Nov-2021 07:00:30

324 Views

To find the column index of least value for each row in an R matrix, we can use apply function.For Example, if we have a matrix called M then we can find column that has the least value for each row by using the command as follows −apply(M, 1, which.min)Example ... Read More

How to convert days in a week to number in R data frame column?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 01-Nov-2021 06:43:51

909 Views

To convert days in a week to number in R data frame column, we would need to convert the column into a factor by defining the weekdays as the levels and then read that column as integer.If we provide the correct sequence of weekdays during conversion then Monday will be ... Read More

How to create transparent boxplot in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 01-Nov-2021 06:31:21

948 Views

Be default, the boxplot created in base R or by using ggplot2 are not transparent in nature. If we want to create a transparent boxplot then we can use bwplot function from lattice package.For Example, if we have a vector called X then we can create transparent boxplot of X ... Read More

Find the column name with the largest value for each row in an R data frame.

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 01-Nov-2021 06:22:24

3K+ Views

To find the column name that has the largest value for each row in an R data frame, we can use colnames function along with apply function.For Example, if we have a data frame called df then we can find column name that has the largest value for each row ... Read More

How to find the quartile for each value in an R vector?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 01-Nov-2021 06:05:00

440 Views

Any numerical data can be divided into four parts (four quarters) by using three quartiles, first quartile at 25%, second quartile at 50% and third quartile at 75% hence there will be four quarters to represent first 25%, second 25%, third 25% and the last 25% in a set of ... Read More

How to match and replace column names stored in R data frames in R-Programming?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 01-Nov-2021 05:57:48

680 Views

If we have a data frame that contains a column of column names which matches with the column names of a data frame and another column that has different values then we can set these different values as the new column names of the data frame having matched column names.This ... Read More

Convert a data frame with grouping column into a list based on groups in R.

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 01-Nov-2021 05:47:37

1K+ Views

To convert a data frame with grouping column into a list based on groups, we can use split function.For Example, if we have a data frame called df that contains a categorical column say Group and a numerical column say DV then we can convert df into a list based ... Read More

Define column and row names of a square matrix in a single line code if they are same in R.

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 01-Nov-2021 05:38:12

289 Views

If we have a square matrix or we want to create a square matrix and the row names and column names for this matrix are same then we can define these names in a single line of code.For Example, if we have a matrix called M that has 10 rows ... Read More

How to subset non-duplicate values from an R data frame column?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 01-Nov-2021 05:02:17

1K+ Views

Generally, the duplicate values are considered after first occurrence but the first occurrence of a value is also a duplicate of the remaining. Therefore, we might want to exclude that as well.The subsetting of non-duplicate values from an R data frame column can be easily done with the help of ... Read More

Create a data.table object of combination of correlation coefficients.

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 28-Oct-2021 15:01:09

126 Views

To create a data.table object of combination of correlation coefficients, we first need to find the correlation matrix then the combination of variables for which the correlation matrix is created then data.table will be used to combine the combination of variables and the correlation coefficients.Check out the below Examples to ... Read More

Advertisements