Nizamuddin Siddiqui

Nizamuddin Siddiqui

1,958 Articles Published

Articles by Nizamuddin Siddiqui

Page 44 of 196

Roll up R data frame columns for summation by group if missing values exist in the data frame.

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 02-Nov-2021 533 Views

The summation of column values if missing values exist in the R data frame can be found with the help of summarise_each function of dplyr package where we can remove missing values by setting na.rm argument to TRUE.Since, we we will have groups in the data frame hence group_by function of the same package will help the summarise_each function to perform the summation by group. Check out the below Examples to understand how it works.Example 1Following snippet creates a sample data frame −Grp

Read More

How to create a base R plot without axes but keeping the frame of the plot?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 02-Nov-2021 442 Views

To create a base R plot without axes but keeping the frame of the plot, we can set axes argument to FALSE and frame.plot argument to TRUE.For example, if we have a vector called V and we want to create a plot of V without axes but with the frame of the plot then, we can use the command given below −plot(V,axes=FALSE,frame.plot=TRUE)Check out the below example to understand how it works.ExampleConsider the following snippet −x

Read More

How to find the variance of frequency data in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 02-Nov-2021 568 Views

If we have frequency data then we first need to find the total data or complete data by repeating the values up to the frequency corresponding to each value after that we can apply var function on this complete data.For Example, if we have a data frame called df that contains two columns say X and Frequency then we can find the total data by using the command given below −Total_data

Read More

How to find the autocorrelation values from ACF plot in R?

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

The autocorrelation plot or ACF plot is a display of serial correlation in data that changes over time. The ACF plot can be easily created by using acf function.For example, if we have a vector called V then we can create its autocorrelation plot by using the command acf(V). If we want to extract autocorrelation values then we would need to save the plot values in an object by using the below command. This will not create the plot.Autocorrelation_x

Read More

How to find the row means for each matrix stored in an R list?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 02-Nov-2021 400 Views

To find the row mean of all matrices stored in an R list, we can use sapply function along with rowMeans function.For example, if we have a list called LIST that contains some matrices then the row means for each matrix can be found by using the following command −sapply(LIST,rowMeans)Check out the below example to understand how it works.ExampleFollowing snippet creates the matrices −M1

Read More

How to find the median of frequency data in R?

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

If we have frequency data then we first need to find the total data or complete data by repeating the values up to the frequency corresponding to each value after that we can apply median function on this complete data.For Example, if we have a data frame called df that contains two columns say X and Frequency then we can find the total data by using the following command −Total_data

Read More

How to find the sample size for t test in R?

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

To find the sample size for t test, we can use pwr.t.test function of pwr package, wherever we can pass the arguments for alternative hypothesis such as one-sided or two-sided, significance level, power of the test and difference for two samples.Check out the below examples to understand how it works.Example 1Consider the following code to find sample size for t test −library("pwr") pwr.t.test(power=0.80, d=1, sig.level=0.05, alternative="two.sided")OutputIf you execute the above given code, it generates the following Output for the two-sample t test power calculation −   n = 16.71472    d = 1 sig.level = 0.05    power = 0.8 alternative ...

Read More

How to make duplicate factor levels unique in an R data frame?

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

The factor with duplicate levels represents grouping data but if we want to convert the grouping data into nominal data then duplicate values must be removed or converted into unique values. To make duplicate factor levels unique in an R data frame, we can use make.unique function.Check out the below Examples to understand how it works.Example 1Following snippet creates a sample data frame −Factor

Read More

How to divide each value in an R data frame by 100?

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

We sometimes need to perform mathematical operations on all values in the data set. One such operation could be dividing each value by 100.For example, if we have a data frame called df then we can divide each value in df by 100 by using the below command −df[,1:ncol(df)]/100ExampleFollowing snippet creates a sample data frame −x1

Read More

How to find the groupwise common value for a data.table object?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 02-Nov-2021 216 Views

To find the groupwise common value for a data.table object, we can use Reduce function with intersect function.For example, if we have a data.table object called DT that contains a numerical column say Num and a categorical column say C where C exists at the first position then the groupwise common value can be found by using the command given below −Reduce(intersect,DT[,.(list(unique(Num))),C]$V1)ExampleConsider the below data.table object −Group

Read More
Showing 431–440 of 1,958 articles
« Prev 1 42 43 44 45 46 196 Next »
Advertisements