SGSO
SGSO

Reputation: 59

Load dataset from a R package does not work always

aTrying to load specified data set from specified R package using data() from util R package. It does not load some data sets.

Using data() function of 'util' R package, I was trying to load data set (veg, bock.table etc.) using following syntax but it did not work on few data sets where the name of the data set has something in the parenthesis.

## see all the data set names in the psych R package
data(package='psych')

## if the data set name without parenthesis is 
## used, the data set loads in memory
data('income', package='psych')

## display the data set
income

## But, if an attempt is made to load the data set that has 
## some text in the parenthesis, it fails to load the data set.
data('veg (vegetables)', package='psych')

data('bock.table (bock)', package='psych')

## above two lines shows warning and does not load data set

I am using R GUI 3.4.4. First I ran data(package='psych') to get the list of all the data set available in the R package(here 'psych'). I pick a data set name from the list and try to load using data(), as shown in the code above. But loading data set does not work on the data set names those have some text in the parenthesis (see the list in R GUI). The ones without parenthesis part in the data set names, loads successfully. How do I load the data set those have some text in the parenthesis in their name like "bock.table (bock)" or "veg (vegetables)" ?

Upvotes: 2

Views: 1395

Answers (1)

Sonny
Sonny

Reputation: 3183

Use the part in brackets:

> data('vegetables', package='psych')
> data('Schmid', package='psych')
> data('bock', package='psych')

Upvotes: 3

Related Questions