No need to install/load any package. datasets
are
already pre-installed.
?datasets()
library(help = "datasets")
?swiss # give information on data set 'swiss'
help(USArrests) # give information on data set 'USArrests'
You will find some code that can be used to create graphs in the help files.
require(stats); require(graphics)
pairs(swiss, panel = panel.smooth, main = "swiss data",
col = 3 + (swiss$Catholic > 50))
Another way to access the same datasets above - using the
utils
package. There are always multiple ways to do the
same thing in R.
require(utils)
?data
data() # list all available data sets
See datasets here.
# install.packages("AER")
library(AER)
## Loading required package: car
## Loading required package: carData
## Loading required package: lmtest
## Loading required package: zoo
##
## Attaching package: 'zoo'
## The following objects are masked from 'package:base':
##
## as.Date, as.Date.numeric
## Loading required package: sandwich
## Loading required package: survival
??AER
xyplot
from lattice
package produces
bivariate scatterplots or time-series plots.
data("Guns")
## visualization
library("lattice")
?xyplot
xyplot(log(violent) ~ as.numeric(x = as.character(year)) | state,
data = Guns,
type = "l")
?OrchardSprays
df <- OrchardSprays
xyplot(x = decrease ~ treatment, data = OrchardSprays, groups = rowpos,
type = "a",
auto.key =
list(space = "right", points = FALSE, lines = TRUE))