method
Direct call plot()
function, passing vectors x and y vector run command.
For ggplot2 system can be used qplot()
to obtain the same results of drawing functions:
If the vector contains two parameters in a data frame, the following commands:
Draw a line chart
method
Use plot()
need to pass in a function to draw the coordinates of parameters, and the use of parameters type="l"
:
If you want to add a point or polyline On this basis, we need to point()
function and lines()
implement functions.
You can use ggplot
the package to achieve a similar effect.
Draw a bar graph
method
The barplot()
two arguments, a first set heights of the bars, a second set corresponding to the label (optional).
Sometimes, the bar represents the frequency of each element in the packet, which is similar with the histogram. However, the x-axis is no longer seen in FIG continuous values, but discrete. Use table()
frequency computing function category.
You can use ggplot2
the system functions, attention needs to be converted as the abscissa variable is a type and a parameter setting factor.
Draw a histogram
Similarly, we use both methods to draw
Drawing boxplot
Use plot()
passing it two vectors when plotted as a function boxplot: x, y. When the variable x is a factor, it will default to draw boxplot.
When these two variable parameters contained in the same data block, use the formula syntax.
Use the following ggplot2
draw
Using the interaction()
function to grouping variables can be plotted together boxplot multi-packet-based variables.