Server Side Programming Articles

Page 1997 of 2109

How to create a line chart in R using plot function with larger width?

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

To create a line chart in base R using plot function, we need to use type = "l" so that R understand the plot needs to have a line instead of points. If we want to increase the width of the line then lwd argument can be used. The value lwd = 0 is the default value for the width.Consider the below vector and create the line chart −Examplex

Read More

How to create a chart by covering the area of the plot from bottom left to upper right in R?

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

The plot area in plot window is fixed by default and we can create a lint chart with extended width so that the chart covers the area of the plot from bottom left to upper right. This can be done by using very large width of the line chart with the help of lwd argument.Consider the below vector and create the very wide line chart to cover the plot area −Examplex

Read More

How to create varying width bar chart using barplot function in R?

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

The barplot function create the bars of equal width but if we have equal or unequal width values for each bar then we can use width within the barplot function. Thus, the newly generated barplot will have different width of the bars. For example, if we the width are defined for four categories as 0.25 each then each bar will be of equal width and if they vary as 0.30, 0.40, 0.20, 0.45 then the width of the bars will be different based on these widths.Consider the below vector x and the corresponding width vector −x

Read More

How to change the X-axis labels for boxplots created by using boxplot function in R?

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

When we create boxplots for multiple categories in R using boxplot function, by default the X-axis labels are represented by numbers. But we might want to express the categories by their name. In this situation, we can use names argument along with the boxplot function.Consider the below vectors that represent different categories and create the boxplot for these categories −ExampleClass1

Read More

How to change the color of bars in histogram for values that are greater than 0 or less than 0 in R?

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

Although, the histogram represents the distribution of a complete set of values but we might want to visualize that histogram based on the division of some threshold value. For example, we might want to visualize the histogram with different bars that have values greater than 1 or less than 1. This will help us to understand the distribution of the values in whole data set that lies above or below certain value. For this purpose, we can simply use hist function with col argument to change the color of the values that are greater than or less than a fixed ...

Read More

How to find residual variance of a linear regression model in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 14-Oct-2020 6K+ Views

The residual variance is the variance of the values that are calculated by finding the distance between regression line and the actual points, this distance is actually called the residual. Suppose we have a linear regression model named as Model then finding the residual variance can be done as (summary(Model)$sigma)**2.Examplex1

Read More

How to add a mathematical expression in axis label in a plot created by using plot function in R?

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

When we create a plot using plot function in R, the axes titles are either chosen by R automatically based on the vectors passed through the function or we can use ylab or xlab for particular axes. To add a mathematical expression in an axis label, we can use title function with expression function to define the mathematical expression.Consider the below vectors and create scatterplot between the two −Exampleset.seed(111) x

Read More

How to create a black and white word cloud in R?

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

According to Google, a word cloud is an image composed of words used in a particular text or subject, in which the size of each word indicates its frequency or importance. In R, we can create word cloud by using wordcloud function of wordcloud package. So, we have the same name of the function as the package, thus we should not get confused by it.Loading wordcloud package and creating a wordcloud −library("wordcloud") x

Read More

How to check whether a year or a vector of years is leap year or not in R?

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

Almost everyone knows that a leap has 366 instead of 365 days and it occurs once in four years. If we want to check whether a particular year is a leap year or in a range of years which years correspond to leap year then we can use leap_year function of leap year. The length function can be used with the year value and if the output is 1 then it will be a leap year otherwise the output will be 0 which refers to the non-leap year.Loading lubridate package −Examplelibrary("lubridate") year1

Read More

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 346 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
Showing 19961–19970 of 21,090 articles
Advertisements