Paul M
Paul M

Reputation: 697

Loading data from a program

I am trying to access a set of data which is part of a program. The result is the statement that the data does not exist. The code I am using follows:

library(survival)

Loading required package: splines

data(package="survival")

data(aml)

Warning message: In data(aml) : data set ‘aml’ not found

The command data(package="survival") produces a list of data including aml, yet the data(aml) command does make the data available. Am I missing a required command, or is it possible that there is a problem with the file of the survival package? How could I find the files and test the aml existence?

I have tested this for data files aml and am1 to make sure I did not misread the text. Neither one worked. According to the description in the list of data files, the name of this data file is all letters.

Upvotes: 4

Views: 943

Answers (1)

mnel
mnel

Reputation: 115382

In the case of survival, the package authors have implemented lazyData, which means you can access the data without needing to call data, it can be found on the search path already.

library(survival)
exists('aml')
## [1] TRUE

head(aml)
  time status          x
1    9      1 Maintained
2   13      1 Maintained
3   13      0 Maintained
4   18      1 Maintained
5   23      1 Maintained
6   28      0 Maintained

Upvotes: 5

Related Questions