Nizamuddin Siddiqui

Nizamuddin Siddiqui

1,958 Articles Published

Articles by Nizamuddin Siddiqui

Page 174 of 196

How to create a scatterplot in R using ggplot2 with different designs of points?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 21-Aug-2020 333 Views

Scatterplot helps us to identify the linear relationship between two variables and it is the first step of determining a predictive model. Before using any predictive modeling technique we must draw a scatterplot between independent and dependent variables to check what kind of relationship exists between them. A scatterplot generally represented by circular points on the plot area but we can have different types of points such as square, rectangle, diamond, etc. In ggplot2, pch argument of geom_point can help us to create scatterplot with these types of points.ExampleConsider the below data frame −set.seed(123) x

Read More

How to deal with error “Error in eval(predvars, data, env) : numeric 'envir' arg not of length one” in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 21-Aug-2020 2K+ Views

This error occurs when we do not pass the argument for independent variable as a data frame. The predict function will predict the value of the dependent variable for the provided values of the independent variable and we can also use the values of the independent variable using which the model is created.ExampleConsider the below data frame −set.seed(1) x

Read More

How to change the border color of points in a scatterplot created with ggplot2 in R?

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

Aesthetics is an essential part of a plot whether it is a scatterplot or any other plot. When we create a scatterplot with ggplot function of ggplot2 package, the border of the points is black if we fill the points with the sequence of a color but we can change these borders to any other color by using colour argument.ExampleConsider the below data frameRate

Read More

How to remove the border of the legend of a chart created by plot function in R?

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

When we create a chart using plot function and add a legend to that chart, the output of the chart has the legend that is covered with borders. But this breaks the flow of the chart and the area covered by the order make the chart unattractive. Therefore, we can use bty="n" with the legend function and it will remove the border of the legend.ExampleCreating the chart with legend that has border −plot(x=1:10, y=10:1) legend(1, 2, "This is a scatterplot between x and y")OutputCreating the chart with legend which does not have a border −Exampleplot(x=1:10, y=10:1) legend(1, 2, "This is ...

Read More

How to create colored Venn Diagrams?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 21-Aug-2020 472 Views

Reading transparent Venn Diagrams is a little difficult due to transparency in all areas, therefore, we should create Venn Diagrams that has different color in each of the area. This will help us to easily read the diagram and also the diagram will be more appealing to viewers. We can do this by using venn.diagram function of VennDiagram package.Installing and Loading VennDiagram package −Exampleinstall.packages(“VennDiagram”) library(VennDiagram)Creating the colored Venn Diagram (Note: The colored diagram will be saved in default folder for R in your system, mostly it is documents folder) −venn.diagram(list(x=1:10, y=7:12), fill=c("yellow", "black"), + filename = "Example1.tiff")Outputvenn.diagram(list(x=1:10, y=7:12, z=9:16), fill=c("yellow", ...

Read More

How to change ordinal X-axis label to text labels using ggplot2 in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 21-Aug-2020 2K+ Views

A plot created with ordinal values on X-axis needs to be ordered for plotting, otherwise, the plot will have continuous values on the X-axis that includes ordinal values. If we want to convert those values to text then scale_x_discrete should be used with the number of breaks, these number of breaks are the actual number of labels we want to use in our plot.ExampleConsider the below data frame −x

Read More

How to subtract number of days from a date to get the previous date in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 21-Aug-2020 541 Views

In our daily life, we might want to know what was the date before some number of days. This is also required in professional life, especially in those professions where we work on projects and have tight deadlines. To find the date before a certain number of days we can just use subtraction sign after reading the date with as.Date.Examplesas.Date("2001-01-01")-30 [1] "2000-12-02" as.Date("2020-06-30")-30 [1] "2020-05-31" as.Date("2020-06-30")-50 [1] "2020-05-11" as.Date("2020-06-30")-100 [1] "2020-03-22" as.Date("2020-06-30")-120 [1] "2020-03-02" as.Date("2020-06-30")-15 [1] "2020-06-15" as.Date("2020-06-30")-45 [1] "2020-05-16" as.Date("2020-06-30")-40 [1] "2020-05-21" as.Date("2020-12-25")-20 [1] "2020-12-05" as.Date("2020-12-25")-300 [1] "2020-02-29" as.Date("2020-12-25")-125 [1] "2020-08-22" as.Date("2020-12-25")-80 [1] "2020-10-06"We can also use / to ...

Read More

How to create permutations as a list in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 21-Aug-2020 534 Views

The permutation is the combination with orders. For example, if we want to create a key for lock with a sequence of numbers then it must be order in some direction, otherwise, it will be difficult to remember and easy to unlock. We can find the permutation of some numbers or characters by using permn function of combinat package.Loading the combinat package −library(combinat)Examples that create list of permutations −permn(LETTERS[1:4]) [[1]] [1] "A" "B" "C" "D" [[2]] [1] "A" "B" "D" "C" [[3]] [1] "A" "D" "B" "C" [[4]] [1] "D" "A" "B" "C" [[5]] [1] "D" "A" "C" "B" [[6]] ...

Read More

How to reverse a vector in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 21-Aug-2020 834 Views

Sometimes the vector values are recorded in the reverse order in R, therefore, we need to again reverse those vectors to get the actual order we want. For example, a sequence of numbers might be recorded as 1 to 20 but we wanted it to be from 20 to 1. The reversing of order of the vector values can be easily done with the help of rev function.Examplesx1

Read More

How to visualize the normality of a column of an R data frame?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 21-Aug-2020 218 Views

The first step to analyze a variable is checking whether it is normally distributed or not and to visually do this, we create a histogram. If the histogram depicts a bell then we consider that the variable is normally distributed otherwise, it is not. We can create a histogram for any column of an R data frame by using hist function.ExampleConsider the below data frame −set.seed(9) df

Read More
Showing 1731–1740 of 1,958 articles
« Prev 1 172 173 174 175 176 196 Next »
Advertisements