Nizamuddin Siddiqui

Nizamuddin Siddiqui

1,958 Articles Published

Articles by Nizamuddin Siddiqui

Page 173 of 196

How to change the title of a graph to italic created by using plot function in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 14-Oct-2020 340 Views

If a graph is created by specifying main title of the plot using the plot function then the default font is plain text. We might want to change the style of the font to italic so that the title gets a little more attraction of the viewers. This can be done by using font.main argument with plot function. The value 4 of font.main refers to the bold italic font and if we want to make it bold then we can use the value 3.Consider the below vectors and create the scatterplot between the two with title of the plot −Examplex

Read More

How to create a histogram using weights in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 10-Oct-2020 1K+ Views

A histogram using weights represent the weighted distribution of the values. In R, we can use weighted.hist function of plotrix package to create this type of histogram and we just need the values and weights corresponding to each value. Since plotrix is not frequently used, we must make sure that we install this package using install.packages("plotrix") then load it in R environment.Loading plotrix package −library("plotrix")Consider the below vector and the weight associated with that vector −Examplex

Read More

How to find prime numbers between two values or up to a value in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 10-Oct-2020 1K+ Views

We know that the prime numbers are the numbers that are not divisible by any number except by themselves or 1 and 1 is not considered as a prime number. In R, we can find the prime numbers up to a number or between two numbers by using Prime function of numbers package. If we want to find the total number of prime numbers between 1 and 10, then we just need to pass 10 inside the Prime function, otherwise range will be required.Loading numbers package −library("numbers")Primes(10)[1] 2 3 5 7Primes(100)[1] 2 3 5 7 11 13 17 19 23 ...

Read More

How to create side-by-side boxplot in base R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 10-Oct-2020 483 Views

Often, we need to compare continuous variables using boxplots and thus side-by-side boxplots are required. Creating side-by-side boxplot in base R can be done with the help of creating space for graphs with the help of par(mfrow=). In this function, we can define the number of graphs and the sequence of these graphs, thus creation of side-by-side boxplot will become easy.Consider the below vectors −set.seed(100) x

Read More

How to create two plots using ggplot2 arranged in a vertical manner in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 09-Oct-2020 719 Views

The two plots created by using ggplot2 can be arranged in a vertical manner with the help gridExtra package, we simply needs to use grid.arrange function to do so. For example, if we have two plots created by using ggplot2 and saved in objects p1 and p2 then they can be vertically arranged as grid.arrange(p1,p2)Consider the below data frame −Exampleset.seed(151) x

Read More

How to simulate normal distribution for a fixed limit in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 09-Oct-2020 735 Views

To simulate the normal distribution, we can use rnorm function in R but we cannot put a limit on the range of values for the simulation. If we want simulate this distribution for a fixed limit then truncnorm function of truncnorm package can be used. In this function, we can pass the limits with and without mean and standard deviation.Loading and installing truncnorm package −>install.packages("truncnorm") >library(truncnorm)Examplertruncnorm(n=10, a=0, b=10)[1] 0.76595522 0.33315633 1.29565988 0.67154230 0.04957334 0.38338705 [7] 0.75753005 0.65265304 0.63616552 0.45710877rtruncnorm(n=50, a=0, b=100)[1] 0.904997947 0.035692016 0.402963452 1.001102057 1.445190636 0.109245234 [7] 0.205630845 0.312428027 0.465876772 0.424647787 0.309222394 0.442172805 [13] 0.365503292 1.277570451 0.235747661 1.128447123 ...

Read More

How to create a transparent histogram using ggplot2 in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 08-Oct-2020 3K+ Views

When we create a histogram using ggplot2 package, the area covered by the histogram is filled with grey color but we can remove that color to make the histogram look transparent. This can be done by using fill="transparent" and color="black" arguments in geom_histogram, we need to use color argument because if we don’t use then the borders of the histogram bars will also be removed and this color is not restricted to black color only.ExampleConsider the below data frame −set.seed(987) x

Read More

How to select values less than or greater than a specific percentile from an R data frame column?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 08-Oct-2020 744 Views

The percentiles divide a set of numeric values into hundred groups or individual values if the size of the values is 100. We can find percentiles for a numeric column of an R data frame, therefore, it is also possible to select values of a column based on these percentiles. For this purpose, we can use quantile function.ExampleConsider the below data frame −set.seed(111) x

Read More

How to convert integers into integers written in words in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 08-Oct-2020 145 Views

If we have numbers then we might want to convert those numbers into words. For example, converting 1 to one. This might be required in cases where we have text data and numbers are part of the text. Therefore, it would be better to represent the numbers in text form to make the uniformity in the text. This can be done by using replace_number function qdap package.Installing and loading qdap package−install.packages("qdap") library("qdap")Examplereplace_number("1") [1] "one" replace_number("10") [1] "ten" replace_number("100") [1] "one hundred" replace_number("1000") [1] "one thousand" replace_number("1001") [1] "one thousand one" replace_number("12000") [1] "twelve thousand" replace_number("12214") [1] "twelve thousand two hundred ...

Read More

How to fill the NA values from above row values in an R data frame?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 08-Oct-2020 1K+ Views

Sometimes we have missing values that can be replaced with the values on the above row values, it often happens in situations when the data is recorded manually and the person responsible for it just mention the unique values because he or she understand the data characteristics. But if this data needs to be re-used by someone else then it does not make sense and we have to connect with the concerned person. If the concerned person tells us that the first value in each row can be filled for every NA in the same column then it can be ...

Read More
Showing 1721–1730 of 1,958 articles
« Prev 1 171 172 173 174 175 196 Next »
Advertisements