Nizamuddin Siddiqui has Published 2307 Articles

How to create a sequence increasing by 1 in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 10-Feb-2021 10:56:22

231 Views

If a sequence is increasing by 1 that means for every value the total number of values increases by that much. For example, the values 1 1 2 1 2 3 1 2 3 4 1 2 3 4 5 are creating a sequence of values starting from 1 to ... Read More

How to sort a large number of csv files in ascending order in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 10-Feb-2021 10:54:20

183 Views

To sort a large number of csv files in ascending order, we can use mixedsort function from gtools package. For example, if we have a list of csv files that are randomly arranged in a vector called FILES then the files can be sorted in ascending order using the command ... Read More

How to sort a column of data.table object in ascending order using column name stored in a vector in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 10-Feb-2021 10:53:02

234 Views

Sorting a column of data.table object can be done easily with column number but sorting with column name is different. If a column name is stored in a vector and we want to sort a column of data.table object in ascending order using this name then order function will be ... Read More

How to extract the closest value to a certain value in each category in an R data frame?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 10-Feb-2021 10:47:38

1K+ Views

In Data Analysis, we often deal with the comparison of values and this comparison could be also done after finding the closest value to a certain value that might be threshold. For this purpose, we can use filter function of dplyr package along with abs and min function, the abs ... Read More

How to perform shapiro test for all columns in an R data frame?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 10-Feb-2021 07:20:33

4K+ Views

The shapiro test is used to test for the normality of variables and the null hypothesis for this test is the variable is normally distributed. If we have numerical columns in an R data frame then we might to check the normality of all the variables. This can be done ... Read More

How to access the table values in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 10-Feb-2021 07:20:17

4K+ Views

Sometimes we want to extract table values, especially in cases when we have a big table. This helps us to understand the frequency for a particular item in the table. To access the table values, we can use single square brackets. For example, if we have a table called TABLE ... Read More

How to create a boxplot using ggplot2 for single variable without X-axis labels in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 10-Feb-2021 07:18:03

3K+ Views

The important part of a boxplot is Y−axis because it helps to understand the variability in the data and hence, we can remove X−axis labels if we know the data description. To create a boxplot using ggplot2 for single variable without X−axis labels, we can use theme function and set ... Read More

How to create the random sample by defining the probabilities for each unit in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 10-Feb-2021 07:16:52

99 Views

The random sample can be created by using sample function, this random sample gives equal chance for each unit to be selected in the sample, hence it is called simple random sample. If we want to have a sample where each unit has different chance of being selected in the ... Read More

How to remove dot and number at the end of the string in an R vector?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 10-Feb-2021 07:15:02

5K+ Views

To remove dot and number at the end of the string, we can use gsub function. It will search for the pattern of dot and number at the end of the string in the vector then removal of the pattern can be done by using double quotes without space. After ... Read More

How to create correlation matrix plot in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 10-Feb-2021 07:14:45

281 Views

To create a correlation matrix plot, we can use ggpairs function of GGally package. For example, if we have a data frame called df that contains five columns then the correlation matrix plot can be created as ggpairs(df). A correlation matrix plot using ggpairs display correlation value as well as ... Read More

Advertisements