| 1 |
\name{data}
|
1 |
\name{data}
|
| 2 |
\alias{data}
|
2 |
\alias{data}
|
| 3 |
\alias{print.packageIQR}
|
3 |
\alias{print.packageIQR}
|
| 4 |
\title{Data Sets}
|
4 |
\title{Data Sets}
|
| 5 |
\description{
|
5 |
\description{
|
| 6 |
Loads specified data sets, or list the available data sets.
|
6 |
Loads specified data sets, or list the available data sets.
|
| 7 |
}
|
7 |
}
|
| 8 |
\usage{
|
8 |
\usage{
|
| 9 |
data(\dots, list = character(0), package = .packages(),
|
9 |
data(\dots, list = character(0), package = .packages(),
|
| 10 |
lib.loc = NULL, verbose = getOption("verbose"),
|
10 |
lib.loc = NULL, verbose = getOption("verbose"),
|
| 11 |
envir = .GlobalEnv)
|
11 |
envir = .GlobalEnv)
|
| 12 |
}
|
12 |
}
|
| 13 |
\arguments{
|
13 |
\arguments{
|
| 14 |
\item{\dots}{a sequence of names or literal character strings.}
|
14 |
\item{\dots}{a sequence of names or literal character strings.}
|
| 15 |
\item{list}{a character vector.}
|
15 |
\item{list}{a character vector.}
|
| 16 |
\item{package}{a character vector giving the packages to look
|
16 |
\item{package}{a character vector giving the packages to look
|
| 17 |
in for data sets. By default, all packages in the search path are
|
17 |
in for data sets. By default, all packages in the search path are
|
| 18 |
used, then the \file{data} subdirectory (if present) of the current
|
18 |
used, then the \file{data} subdirectory (if present) of the current
|
| 19 |
working directory.}
|
19 |
working directory.}
|
| 20 |
\item{lib.loc}{a character vector of directory names of \R libraries,
|
20 |
\item{lib.loc}{a character vector of directory names of \R libraries,
|
| 21 |
or \code{NULL}. The default value of \code{NULL} corresponds to all
|
21 |
or \code{NULL}. The default value of \code{NULL} corresponds to all
|
| 22 |
libraries currently known. If the default is used, the loaded
|
22 |
libraries currently known. If the default is used, the loaded
|
| 23 |
packages are searched before the libraries.}
|
23 |
packages are searched before the libraries.}
|
| 24 |
\item{verbose}{a logical. If \code{TRUE}, additional diagnostics are
|
24 |
\item{verbose}{a logical. If \code{TRUE}, additional diagnostics are
|
| 25 |
printed.}
|
25 |
printed.}
|
| 26 |
\item{envir}{the \link{environment} where the data should be loaded.}
|
26 |
\item{envir}{the \link{environment} where the data should be loaded.}
|
| 27 |
}
|
27 |
}
|
| 28 |
\value{
|
28 |
\value{
|
| 29 |
a character vector of all data sets specified, or information about
|
29 |
a character vector of all data sets specified, or information about
|
| 30 |
all available data sets in an object of class \code{"packageIQR"} if
|
30 |
all available data sets in an object of class \code{"packageIQR"} if
|
| 31 |
none were specified.
|
31 |
none were specified.
|
| 32 |
}
|
32 |
}
|
| 33 |
\details{
|
33 |
\details{
|
| 34 |
Currently, four formats of data files are supported:
|
34 |
Currently, four formats of data files are supported:
|
| 35 |
|
35 |
|
| 36 |
\enumerate{
|
36 |
\enumerate{
|
| 37 |
\item files ending \file{.R} or \file{.r} are
|
37 |
\item files ending \file{.R} or \file{.r} are
|
| 38 |
\code{\link{source}()}d in, with the \R working directory changed
|
38 |
\code{\link{source}()}d in, with the \R working directory changed
|
| 39 |
temporarily to the directory containing the respective file.
|
39 |
temporarily to the directory containing the respective file.
|
| 40 |
|
40 |
|
| 41 |
\item files ending \file{.RData} or \file{.rda} are
|
41 |
\item files ending \file{.RData} or \file{.rda} are
|
| 42 |
\code{\link{load}()}ed.
|
42 |
\code{\link{load}()}ed.
|
| 43 |
|
43 |
|
| 44 |
\item files ending \file{.tab}, \file{.txt} or \file{.TXT} are read
|
44 |
\item files ending \file{.tab}, \file{.txt} or \file{.TXT} are read
|
| 45 |
using \code{\link{read.table}(\dots, header = TRUE)}, and hence
|
45 |
using \code{\link{read.table}(\dots, header = TRUE)}, and hence
|
| 46 |
result in a data frame.
|
46 |
result in a data frame.
|
| 47 |
|
47 |
|
| 48 |
\item files ending \file{.csv} or \file{.CSV} are read using
|
48 |
\item files ending \file{.csv} or \file{.CSV} are read using
|
| 49 |
\code{\link{read.table}(\dots, header = TRUE, sep = ";")},
|
49 |
\code{\link{read.table}(\dots, header = TRUE, sep = ";")},
|
| 50 |
and also result in a data frame.
|
50 |
and also result in a data frame.
|
| 51 |
}
|
51 |
}
|
| 52 |
If more than one matching file name is found, the first on this list
|
52 |
If more than one matching file name is found, the first on this list
|
| 53 |
is used.
|
53 |
is used.
|
| 54 |
|
54 |
|
| 55 |
The data sets to be loaded can be specified as a sequence of names or
|
55 |
The data sets to be loaded can be specified as a sequence of names or
|
| 56 |
character strings, or as the character vector \code{list}, or as both.
|
56 |
character strings, or as the character vector \code{list}, or as both.
|
| 57 |
|
57 |
|
| 58 |
For each given data set, the first two types (\file{.R} or \file{.r},
|
58 |
For each given data set, the first two types (\file{.R} or \file{.r},
|
| 59 |
and \file{.RData} or \file{.rda} files) can create several variables
|
59 |
and \file{.RData} or \file{.rda} files) can create several variables
|
| 60 |
in the load environment, which might all be named differently from the
|
60 |
in the load environment, which might all be named differently from the
|
| 61 |
data set. The second two (\file{.tab}, \file{.txt}, or \file{.TXT},
|
61 |
data set. The second two (\file{.tab}, \file{.txt}, or \file{.TXT},
|
| 62 |
and \file{.csv} or \file{.CSV} files) will always result in the
|
62 |
and \file{.csv} or \file{.CSV} files) will always result in the
|
| 63 |
creation of a single variable with the same name as the data set.
|
63 |
creation of a single variable with the same name as the data set.
|
| 64 |
|
64 |
|
| 65 |
If no data sets are specified, \code{data} lists the available data
|
65 |
If no data sets are specified, \code{data} lists the available data
|
| 66 |
sets. It looks for a new-style data index in the \file{Meta} or, if
|
66 |
sets. It looks for a new-style data index in the \file{Meta} or, if
|
| 67 |
this is not found, an old-style \file{00Index} file in the \file{data}
|
67 |
this is not found, an old-style \file{00Index} file in the \file{data}
|
| 68 |
directory of each specified package, and uses these files to prepare a
|
68 |
directory of each specified package, and uses these files to prepare a
|
| 69 |
listing. If there is a \file{data} area but no index, available data
|
69 |
listing. If there is a \file{data} area but no index, available data
|
| 70 |
files for loading are computed and included in the listing, and a
|
70 |
files for loading are computed and included in the listing, and a
|
| 71 |
warning is given: such packages are incomplete. The information about
|
71 |
warning is given: such packages are incomplete. The information about
|
| 72 |
available data sets is returned in an object of class
|
72 |
available data sets is returned in an object of class
|
| 73 |
\code{"packageIQR"}. The structure of this class is experimental. In
|
73 |
\code{"packageIQR"}. The structure of this class is experimental. In
|
| 74 |
earlier versions of R, an empty character vector was returned along
|
74 |
earlier versions of R, an empty character vector was returned along
|
| 75 |
with listing available data sets.
|
75 |
with listing available data sets.
|
| 76 |
|
76 |
|
| 77 |
If \code{lib.loc} is not specified, the data sets are searched for
|
77 |
If \code{lib.loc} is not specified, the data sets are searched for
|
| 78 |
amongst those packages already loaded, followed by the \file{data}
|
78 |
amongst those packages already loaded, followed by the \file{data}
|
| 79 |
directory (if any) of the current working directory and then packages
|
79 |
directory (if any) of the current working directory and then packages
|
| 80 |
in the specified libraries. If \code{lib.loc} \emph{is} specified,
|
80 |
in the specified libraries. If \code{lib.loc} \emph{is} specified,
|
| 81 |
packages are searched for in the specified libraries, even if they are
|
81 |
packages are searched for in the specified libraries, even if they are
|
| 82 |
already loaded from another library.
|
82 |
already loaded from another library.
|
| 83 |
|
83 |
|
| 84 |
To just look in the \file{data} directory of the current working
|
84 |
To just look in the \file{data} directory of the current working
|
| 85 |
directory, set \code{package = NULL}.
|
85 |
directory, set \code{package = NULL}.
|
| 86 |
}
|
86 |
}
|
| 87 |
\note{
|
87 |
\note{
|
| 88 |
The data files can be many small files. On some file systems it is
|
88 |
The data files can be many small files. On some file systems it is
|
| 89 |
desirable to save space, and the files in the \file{data} directory of
|
89 |
desirable to save space, and the files in the \file{data} directory of
|
| 90 |
an installed package can be zipped up as a zip archive
|
90 |
an installed package can be zipped up as a zip archive
|
| 91 |
\file{Rdata.zip}. You will need to provide a single-column file
|
91 |
\file{Rdata.zip}. You will need to provide a single-column file
|
| 92 |
\file{filelist} of file names in that directory.
|
92 |
\file{filelist} of file names in that directory.
|
| 93 |
|
93 |
|
| 94 |
One can take advantage of the search order and the fact that a
|
94 |
One can take advantage of the search order and the fact that a
|
| 95 |
\file{.R} file will change directory. If raw data are stored in
|
95 |
\file{.R} file will change directory. If raw data are stored in
|
| 96 |
\file{mydata.txt} then one can set up \file{mydata.R} to read
|
96 |
\file{mydata.txt} then one can set up \file{mydata.R} to read
|
| 97 |
\file{mydata.txt} and pre-process it, e.g., using \code{transform}.
|
97 |
\file{mydata.txt} and pre-process it, e.g., using \code{transform}.
|
| 98 |
For instance one can convert numeric vectors to factors with the
|
98 |
For instance one can convert numeric vectors to factors with the
|
| 99 |
appropriate labels. Thus, the \file{.R} file can effectively contain
|
99 |
appropriate labels. Thus, the \file{.R} file can effectively contain
|
| 100 |
a metadata specification for the plaintext formats.
|
100 |
a metadata specification for the plaintext formats.
|
| 101 |
}
|
101 |
}
|
| 102 |
\seealso{
|
102 |
\seealso{
|
| 103 |
\code{\link[utils]{help}} for obtaining documentation on data sets,
|
103 |
\code{\link[utils]{help}} for obtaining documentation on data sets,
|
| 104 |
\code{\link{save}} for \emph{creating} the second (\file{.rda}) kind
|
104 |
\code{\link{save}} for \emph{creating} the second (\file{.rda}) kind
|
| 105 |
of data, typically the most efficient one.
|
105 |
of data, typically the most efficient one.
|
| 106 |
}
|
106 |
}
|
| 107 |
\examples{
|
107 |
\examples{
|
| - |
|
108 |
require(utils)
|
| 108 |
data() # list all available data sets
|
109 |
data() # list all available data sets
|
| 109 |
data(package = "base") # list the data sets in the base package
|
110 |
data(package = "base") # list the data sets in the base package
|
| 110 |
data(USArrests, "VADeaths") # load the data sets 'USArrests' and 'VADeaths'
|
111 |
data(USArrests, "VADeaths") # load the data sets 'USArrests' and 'VADeaths'
|
| 111 |
help(USArrests) # give information on data set 'USArrests'
|
112 |
help(USArrests) # give information on data set 'USArrests'
|
| 112 |
}
|
113 |
}
|
| 113 |
\keyword{documentation}
|
114 |
\keyword{documentation}
|
| 114 |
\keyword{datasets}
|
115 |
\keyword{datasets}
|