Question: Can we draw graphics in R language?
Answer: Yes. R language produces high-quality statistical graphs. There are many useful and sophisticated kinds of graphs available in R.
Question: Where graphics are displayed in R?
Answer: In R, all graphs are produced in a window named Graphic Windows which can be resized.
Question: What is the use of plot function in R?
Answer: In R, plot() is a generic function that can be used to make a variety of point and line graphs. plot() function can also be used to define a coordinate space.
Question: What are the arguments of the plot() function?
Answer: There are many arguments used in the plot() function. Some of these arguments are x, y, type, xlab, ylab, etc. To see the full list of arguments of the plot() write the command in R console;
Question: Do all arguments are necessary to be used in R?
Answer: No. The first two arguments x and y provide the horizontal and vertical coordinates of points or lines to be plotted and also define a data-coordinate system for the graph. At least argument x is required.
Question: What is the use of the argument type in the plot() function?
Answer: The argument type determines the type of the graph to be drawn. There are several types of graph that can be drawn. The default type of graph type=’p’, plots points at the coordinates specified by x and y argument. Specifying type=’l’ produces a line graph, and type=’n’ sets up the plotting region to accommodate the data set but plots nothing.
Question: Is there other types of graph are?
Answer: Yes. Setting type=’b’, draw graphs having both points and lines. Setting type=’h’ draws histogram like vertical lines and setting type=’s’ and type=’S’ draws stair-step-like lines starting horizontally and vertically respectively.
[amazon_link asins=’331924275X,0521762936,1498779832,1449316956′ template=’ProductCarousel’ store=’rfaqs-20′ marketplace=’US’ link_id=’37a244ef-8286-11e8-ace0-8d7a701c4bf4′]
Question: What is the use of xlim and ylim in plot() function?
Answer: The argument xlim and ylim may be used to define the limits of the horizontal and vertical axes. Usually, these arguments are unnecessary, because R language reasonably picks limits from x and y.
Question: What are the purpose of xlab and xlab argument in the plot() function?
Answer: xlab and ylab argument tack character-string arguments to label the horizontal and vertical axes.
Question: Provide few examples of plot() function?
Answer: Suppose you have data set on variable x and y, such as
> x <- rnorm(100, m=10, sd=10)
> y <- rnorm(100)
> plot(x, y)
> plot(x, y, xlab=’X (Mean=10, SD=10)’, ylab=’Y (Mean=1, SD=1)’ , type=’l’)
> plot(x, y, xlab=’X (Mean=10, SD=10)’, ylab=’Y (Mean=1, SD=1)’ , type=’o’)
> plot(x, y, xlab=’X (Mean=10, SD=10)’, ylab=’Y (Mean=1, SD=1)’ , pch=10)
You must log in to post a comment.