Nizamuddin Siddiqui

Nizamuddin Siddiqui

1,958 Articles Published

Articles by Nizamuddin Siddiqui

Page 153 of 196

How to remove question mark from corrplot in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 03-Nov-2021 2K+ Views

When we have NAs present in the data frame or matrix then correlation matrix contains NA values. Now if we create the correlation matrix plot using corrplot function the Output display question marks.If we want to create the correlation matrix without question marks then we can use the na.label argument and set it to blank as shown in the below Example.ExampleFollowing snippet creates a sample matrix −M

Read More

How to create a block diagonal matrix using a matrix in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 03-Nov-2021 2K+ Views

To create a block diagonal matrix using a matrix in R, we can use bdiag function of Matrix package.For Example, if we have a matrix called M and we want to create block diagonal using M 4 times by using the below command −bdiag(replicate(4,M,simplify=FALSE))Check out the Examples given below to understand how it can be done.Example 1Following snippet creates a sample matrix −M1

Read More

How to create a table with sub totals for every row and column in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 03-Nov-2021 3K+ Views

The sub totals for every row and column are actually called marginal sums. Therefore, we can use addmargins function to our table to get the sub totals for every row and column.For example, if we have table called TABLE then we can add the sub totals by using the command given below −TABLE

Read More

How to create table of two factor columns in an R data frame?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 03-Nov-2021 6K+ Views

To create table of two factor columns in an R data frame, we can use table function and with function.For Example, if we have a data frame called df that contains two factor columns say F1 and F2 then we can create table of these two columns by using the below command −with(df,table(F1,F2))Example 1Following snippet creates a sample data frame −Group

Read More

How to find the sample size for two sample proportion tests with given power in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 03-Nov-2021 1K+ Views

To find the sample size for two sample proportion tests with given power, we can use the function power.prop.test where we need to at least pass the two proportions and power.By default the significance level will be taken as 0.05 and if we want to change it then sig.level argument will be used.Given below are some examples with the display of significance levels.Example 1Use the code given below to find the sample size for two sample proportion tests −power.prop.test(p1=8/20, p2=6/20, power=0.90, sig.level=0.05)OutputIf you execute the above given snippet, it generates the following Output for the two-sample comparison of proportions power ...

Read More

How to remove rows that have NA in R data frames stored in a list?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 03-Nov-2021 1K+ Views

To remove rows that have NA in R data frames stored in a list, we can use lapply function along with na.omit function.For example, if we have a list called LIST that contains some data frames each containing few missing values then the removal of rows having missing values from these data frames can be done by using the command given below −lapply(LIST,na.omit)Check out the below given example to understand how it works.ExampleFollowing snippet creates a sample data frame −df1

Read More

How to remove first character from column name in R data frame?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 03-Nov-2021 4K+ Views

To remove first character from column name in R data frame, we can use str_sub function of stringr package.For Example, if we have a data frame called df that contains two columns say XID and XDV then we can remove X from both the column names by using the below mentioned command −names(df)=str_sub(names(df),2)Example 1Following snippet creates a sample data frame −XColor

Read More

How to increase the width of the X-axis line for a ggplot2 graph?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 03-Nov-2021 5K+ Views

To increase the width of the X-axis line for a ggplot2 graph in R, we can use theme function where we can set the axis.line.x.bottom argument size to desired size with element_line.Check out the below Example to understand how it can be done.ExampleFollowing snippet creates a sample data frame −x

Read More

Change the color of X-axis line for a graph using ggplot2.

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 03-Nov-2021 7K+ Views

To change the color of X-axis line for a graph using ggplot2, we can use theme function where we can set the axis.line.x.bottom argument color to desired color with element_line.Check out the below Example to understand how it can be done. This might be required when we want to highlight the X-axis for viewers.ExampleFollowing snippet creates a sample data frame −x

Read More

How to find the row wise mode of strings in an R data frame?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 03-Nov-2021 529 Views

To find the row wise model of strings in an R data frame, we can use apply function along with custom function for mode, if ties will be there then first value will be chosen based on alphabetical ordering.For Example, if we have a data frame called df that contains string values then we can find the row wise mode of strings by using the command given below −df$RowM

Read More
Showing 1521–1530 of 1,958 articles
« Prev 1 151 152 153 154 155 196 Next »
Advertisements