Nizamuddin Siddiqui

Nizamuddin Siddiqui

1,958 Articles Published

Articles by Nizamuddin Siddiqui

Page 177 of 196

How to create a scatterplot with log10 of dependent variable in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 24-Aug-2020 523 Views

Most of the times, the relationship between independent variable and dependent variable is not linear. Therefore, we want to transform the dependent variable or independent variable based on our experiences. Hence, we also want to plot those transformations to visualize the relationship, one such transformation is taking log10 of the dependent variable. To plot this transformation of the dependent variable, we can use scale_y_continuous(trans='log10').ExampleConsider the below data frame −set.seed(10) x

Read More

What is the difference between NA and in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 24-Aug-2020 510 Views

The missing values are represented by NA but if we read them as "NA" then it becomes a level of a factor variable. If we believe that a vector is numeric and we have an "NA" in that vector then it will not be a numeric vector. On the other hand, if we have a vector with NA then it will be a numeric vector.Examplesx1

Read More

How to find the 95% confidence interval for the slope of regression line in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 24-Aug-2020 5K+ Views

The slope of the regression line is a very important part of regression analysis, by finding the slope we get an estimate of the value by which the dependent variable is expected to increase or decrease. But the confidence interval provides the range of the slope values that we expect 95% of the times when the sample size is same. To find the 95% confidence for the slope of regression line we can use confint function with regression model object.ExampleConsider the below data frame −set.seed(1) x

Read More

How to select a column of a matrix by column name in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 24-Aug-2020 3K+ Views

When we create a matrix in R, its column names are not defined but we can name them or might import a matrix that might have column names. If the column names are not defined then we simply use column numbers to extract the columns but if we have column names then we can select the column by name as well as its name.Example1M1

Read More

How to draw a violin plot in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 24-Aug-2020 518 Views

A violin plot is similar to a boxplot but looks like a violin and shows the distribution of the data for different categories. It shows the density of the data values at different points. In R, we can draw a violin plot with the help of ggplot2 package as it has a function called geom_violin for this purpose.ExampleConsider the below data frame −set.seed(1) x

Read More

What is the difference between order and rank function in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 24-Aug-2020 1K+ Views

The rank function gives the rank of the values in a vector if the vector is sorted but in the same sequence as the original vector and the order function gives the position of the original value in the vector but in the sequence of the sorting in ascending order. The rank function is mostly used for ranking when we deal with ordinal variables, hence, we should use it whenever ranking of values is required, on the other hand, order is frequently used for ordering all numerical values.Examplesset.seed(100) x1

Read More

How to find the functions inside a package in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 24-Aug-2020 4K+ Views

There are so many packages in R and each of these packages have different objectives, thus, the number of functions in these packages are large enough to solve the problems in analysis. A package might have fifteen functions and the other might have hundred, it totally depends on the necessity. We can find the functions inside a package by using lsf.str function but we need to load the package prior to knowing the functions inside.Example1library(BSDA) lsf.str("package:BSDA") CIsim : function (samples = 100, n = 30, mu = 0, sigma = 1, conf.level = 0.95, type = "Mean") Combinations : function ...

Read More

How to extract a string that lies between two strings in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 24-Aug-2020 632 Views

If we have a long string then we might want to extract a part of string that lies between two strings. For example, if we have a string “E-learning changing the education system in the world” and we want to extract the string “the education system” brave then we must be very careful about passing the strings in string function, you get to know this in examples. The extraction is not difficult with gsub function but we have to make sure that we are using the correct syntax, otherwise, the result will become obnoxious.Examplesx1

Read More

How to find the number of runs in a sequence in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 24-Aug-2020 694 Views

Sometimes data is recorded as a sequence of numerical values or strings and we might to find the frequency for each of the sequences. This helps us to check the variation in the runs but we must make sure the total frequency is equal to the total number values, otherwise our calculation of frequency would be incorrect. To find the number of runs, we can use rle function in R that stands for Run Length Encoding.Examplesx1

Read More

How to add title at the top of multi-plots created by using gridExtra in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 24-Aug-2020 8K+ Views

The gridExtra package works as an alternative of par(mfrow) with ggplot2, therefore, we can create multiple plots using ggplot2 and gridExtra on a single plot window. Now, if we want to give a title to all of the plots or we can say if want to give a main title to multi-plots, the top argument will be used to make the title lie on the top of the title. Similarly, we can use bottom, left, and right on the basis of our requirement but we would also need grid package for this purpose.ExampleConsider the below data frame −set.seed(123) x1

Read More
Showing 1761–1770 of 1,958 articles
« Prev 1 175 176 177 178 179 196 Next »
Advertisements