Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

regarding data( ) function in R

Tags:

r

tm

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.

like image 372
user288609 Avatar asked Apr 03 '12 02:04

user288609


1 Answers

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
like image 156
G. Grothendieck Avatar answered Oct 01 '22 06:10

G. Grothendieck