Nizamuddin Siddiqui has Published 2307 Articles

How to display superscript for X-axis title in base R plot?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 02-Nov-2021 05:47:12

957 Views

To display superscript for X-axis title in base R plot, we can use ^ sign inside mtext function before defining the plain text.For example, if we want to display X2 at position 5 on X-axis then it can be done by using the below command −mtext(expression(paste(plain("X")^plain("2"))), side=1, line=2, at=5, cex=1.2)ExampleConsider ... Read More

How to change the order of independent variables for regression summary output in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 02-Nov-2021 05:41:22

545 Views

To change the order of independent variables in regression Output, we can pass the variables in the sequence we want while creating the regression model.For example, if we want to have three independent variables and we want to display first at the last position then it can be done as ... Read More

How to check matrix values equality with a vector values in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 01-Nov-2021 10:44:14

148 Views

If we have a vector called V that contains five values and a matrix say M that contains five columns and we want to check whether first value in the vector is present in the first column of each row in the matrix and so on for each value in ... Read More

Find the row means for columns starting with a string in an R data frame.

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 01-Nov-2021 10:23:12

736 Views

To find the row means for columns starting with specific string in an R data frame, we can use mutate function of dplyr package along with rowMeans function.For Example, if we have a data frame called df that contains three columns say x1_x2, x1_x3, x1_x2 and we want to find ... Read More

How to find the row mean for selected columns in R data frame?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 01-Nov-2021 09:56:41

3K+ Views

To find the row mean for selected columns in R data frame, we can use mutate function of dplyr package along with rowMeans function.For Example, if we have a data frame called df that contains three columns say X, Y, and Z then mean of each row for columns X ... Read More

Find the column and row names in the R data frame based on condition.

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 01-Nov-2021 08:28:55

7K+ Views

To find the column names and row names in an R data frame based on a condition, we can use row.names and colnames function. The condition for which we want to find the row names and column names can be defined inside these functions as shown in the below Examples.Example ... Read More

How to find the groupwise order of values in an R data frame?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 01-Nov-2021 08:22:21

431 Views

To find the groupwise order of values in an R data frame, we can use mutate function of dplyr package along with rank function and grouping will be done with the help of group_by function.For Example, if we have a data frame called df that contains two columns say Group ... Read More

Extract columns with a string in column name of an R data frame.

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 01-Nov-2021 07:58:40

4K+ Views

To extract columns with a particular string in column name of an R data frame, we can use grepl function for column names and then subset the data frame with single square brackets.For Example, if we have a data frame called df and we want to extract columns that has ... Read More

How to replace 0 with NA in an R matrix?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 01-Nov-2021 07:39:43

3K+ Views

To replace 0 with NA in an R matrix, we can use subsetting with single square brackets and then set zeros to NA.For Example, if we have a matrix called M that contains some zeros then we can replace 0 with NA by using the command mentioned below −M[M==0]

Find the column number with largest value for each row in an R matrix.

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 01-Nov-2021 07:11:25

372 Views

To check which column has the largest 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 largest value for each row by using the command given below −apply(M, 1, which.max)Example ... Read More

Advertisements