Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why do some datasets need us to do `data(somedataset)` before we can use them?

Why do we have to use data(spam) before we can run lda on it ? spam is a dataset in the ElemsStatLearn package.

library(ElemStatLearn)
library(MASS) # for lda
spam[5] # is ok
spam.lda = lda(spam ~ . , data = spam) # not ok
data(spam)
spam.lda = lda(spam ~ . , data = spam) # ok 

We can access spam[5] even before we run data(spam).

like image 863
pkumar0 Avatar asked Dec 17 '25 23:12

pkumar0


1 Answers

Both calls to lda work fine for me. ElemStatLearn uses lazy loading of data so you don't need to call data

> packageDescription("ElemStatLearn")[["LazyData"]]
# [1] "yes"
like image 140
Romain Francois Avatar answered Dec 19 '25 13:12

Romain Francois



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!