When using downloaded R packages, such as "tm", the given example usually loads an example data set such as
data("crude")
How can I know what exactly this data set is, and in which kind of format, a matrix or a vector? Only by knowing this kind of information can I customize my input into the format required by this package.
Aside from using the help facilities to get more info on crude
we can do this:
# load crude into environment e
data(crude, verbose = TRUE, envir = e <- new.env())
# check what is in e
ls(e) # "crude"
# what is it?
class(e$crude)
summary(e$crude)
# we are satisfied that its what we want so remove e and load it into workspace
rm(e)
data(crude)
In the above case the crude
dataset contained just one object which was also called crude
but that is not always the case. For example, the state
dataset contains 7 objects and none of them are called state
:
# load state into environment e
data(state, verbose = TRUE, envir = e <- new.env())
# check what is in e
ls(e) # there are 7 objects in e
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With