[R] check variables: a Q from a beginner

Petr Pikal petr.pikal at precheza.cz
Thu Jan 16 09:15:03 CET 2003


Hallo

you can try this function

#------------------------------------------------------------------------------------------
# listing objektu s udaji
# Posted by Dan Putler At 2002-07-15 16:13 
# As part of the obveRsive GUI project, we've written a function with much of
# the functionality that Patrick Connolly was suggesting (which is a bit more
# compact than the output from ls.str()). Alas, no date capabilities. The
# function is call ls.objects(), and example output appears below:
# modified by me 20.7.2002

ls.objects <- function (pos = 1, pattern, mode = NULL, type = NULL)
{
    	Obj.Name <- ls(pos = pos, envir = as.environment(pos), pattern = pattern)
	nnn.m<-sapply(sapply(Obj.Name,get),mode)
	nnn.c<-sapply(sapply(Obj.Name,get),class)
	nnn.d<-sapply(sapply(Obj.Name,get),dim)

	Obj.length<-length(nnn.m)

	nnn.pok<-rep(0,Obj.length*2)
	dim(nnn.pok)<-c(Obj.length,2)
	for (i in 1:Obj.length) nnn.pok[i,1]<-as.numeric(unlist(nnn.d[i]))[1]
	for (i in 1:Obj.length) nnn.pok[i,2]<-as.numeric(unlist(nnn.d[i]))[2]
	nnn.d<-nnn.pok
	vyber<-is.na(nnn.d)[,1]
	nnn.d[vyber,1]<-sapply(sapply(Obj.Name,get),length)[vyber]

	nnn.pok<-rep("-",Obj.length)
	for (i in 1:Obj.length) nnn.pok[i]<-as.character(unlist(nnn.c[i]))[1]

	vystup<-data.frame(nnn.m,nnn.pok,nnn.d)
	names(vystup)<-c("Object.Mode","Object.Type","Rows","Columns")
	vystup

}




On 15 Jan 2003 at 18:26, Yan Yu wrote:

> HI, all,
> How can i check the variables that is currently being loaded..
> ls() only list the variable name, but not the summary of the variable,
> like the dimension of the variable etc.. Is there a command in R,
> which is equivalent to "whos" in matlab, which let me check the
> variables currently loaded in Matlab.. also, Does anyone have
> recommendation on ~a good reference to R.. I could not find the answer
> to my Q in the documentation included with R package..
> 
> thanks,
> yan
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> http://www.stat.math.ethz.ch/mailman/listinfo/r-help

CheersPetr Pikal
Precheza a.s., Nabř.Dr.E.BeneÜe 24, 750 62 Přerov
tel: +420581 252 257 ; 724 008 364
petr.pikal at precheza.cz; p.pik at volny.cz
fax +420581 252 561




More information about the R-help mailing list