Instead of dir(), use: system.file("extdata", "resultsForTransgenerationalAnalysis.RDS", package="methylInheritance")