[R] list manipulation

From: Thompson, David (MNR) <David.John.Thompson_at_ontario.ca>
Date: Tue, 06 May 2008 14:35:54 -0400


I have a set of one-liners (many thanks to previous responses from this list) that I use to look at newly imported data sets with functions like dim(), names(), str(), etc. within lapply(). Generally, these commands work for me but, I am apparently still missing some aspect of list manipulation. I don't understand why I get a set of NULL list elements at the end of each output as demonstrated below. How can I generate this (and similar) result(s) without all the trailing NULLs?

> lapply(ls(pattern='bn'), function(x) cat(x, dim(get(x)), "\t", names(get(x)), "\n"))
bn1993 2885 11 oplt rplt rsiz tree bd ht oaz odst raz rdst spr bn1994 3158 7 oplt tree bd ht spr stat dam

bn1995 734 7     oplt tree bd ht spr stat dam 
bn1996 293 7     oplt tree bd ht spr stat dam 
bn1997 264 7     oplt tree bd ht spr stat dam 
bn1998 768 7     oplt tree bd ht spr stat dam 
bn1999 654 7     oplt tree bd ht dbh stat dam 
bn2003 1407 9 oplt tree bd94 ht94 ht99 ht02 ht03 stat dam








NULL Thanx, DaveT.

Silviculture Data Analyst
Ontario Forest Research Institute
Ontario Ministry of Natural Resources

R-help_at_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. Received on Tue 06 May 2008 - 18:47:23 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 06 May 2008 - 19:30:35 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive