Try this: data(list = DS$results[,'Item'], package = 'vcdExtra', envir = ne <- new.env()) cbind(do.call(rbind, eapply(ne, function(x)data.frame(class = class(x), dim = paste(dim(x), collapse = 'x')))), Title = DS$results[,'Title'])
On Mon, Oct 25, 2010 at 1:45 PM, Michael Friendly <frien...@yorku.ca> wrote: > I can use data() to find the available datasets in a package, but I'd like > to extract and display some additional > information for each dataset than what is provided by data(), e.g., > class() and dim() for datasets for which > these are available. I'm stuck on using using lapply properly with > objects, rather than the names of objects > that I get from data() > > Example: > > > DS <- data(package="vcdExtra") > > DS$results[,c("Item", "Title")] > Item Title > [1,] "Abortion" "Abortion Opinion Data" > [2,] "Bartlett" "Bartlett data on plum root cuttings" > [3,] "Caesar" "Risk Factors for Infection in Caesarian Births" > [4,] "Cancer" "Survival of Breast Cancer Patients" > [5,] "Detergent" "Detergent preference data" > [6,] "Dyke" "Sources of knowledge of cancer" > [7,] "GSS" "General Social Survey-- Sex and Party affiliation" > [8,] "Gilby" "Clothing and Intelligence Rating of Children" > [9,] "Heart" "Sex, Occupation and Heart Disease" > [10,] "Heckman" "Labour Force Participation of Married Women 1967-1971" > [11,] "Hoyt" "Minnesota High School Graduates" > [12,] "ICU" "Death in the ICU" > [13,] "JobSat" "Cross-classification of job satisfaction by income" > [14,] "Mental" "Mental impariment and parents SES" > [15,] "Mobility" "Social Mobility data" > [16,] "TV" "TV Viewing Data" > [17,] "Vietnam" "Student Opinion About the War in Vietnam" > [18,] "Yamaguchi87" "Occupational Mobility in Three Countries" > > unlist(lapply(as.list(DS$results[,c("Item") ]), FUN=class)) > [1] "character" "character" "character" "character" "character" > "character" "character" > [8] "character" "character" "character" "character" "character" > "character" "character" > [15] "character" "character" "character" "character" > > Wanted: something like the results of doing > > > class(Abortion) > [1] "table" > > dim(Abortion) > [1] 2 2 2 > > class(Mental) > [1] "data.frame" > > dim(Mental) > [1] 24 3 > > > for all datasets in Item, giving a display like > > Item class dim Title > Abortion table 2x2x2 Abortion Opinion Data > Mental data.frame 24x2 Mental impariment and parents SES > > -- > Michael Friendly Email: friendly AT yorku DOT ca > Professor, Psychology Dept. > York University Voice: 416 736-5115 x66249 Fax: 416 736-5814 > 4700 Keele Street Web: http://www.datavis.ca > Toronto, ONT M3J 1P3 CANADA > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O [[alternative HTML version deleted]]
______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.