R/dim.R

Defines functions dim

Documented in dim

#  "overload" to return dim() when it's sensible and length() elsewise
# Interesting fact --  the function  "dim" and the function  " dim<-" are different
# primitives, so this function here doesn't interfere with the latter.
dim <- function(item) {

if (is.null(base::dim(item)) ) {  
# I wanted to do dims$(thenameitself), but I fear only 
# eval(parse(text=paste("dims$",names,'<-length(get(names))',sep="")))
# would work. Simpler just to use numerical loop index
	dims<-length(item)  
	} else{
		dims  <- base::dim(item)  
		}

return(dims)
}

Try the cgwtools package in your browser

Any scripts or data that you put into this service are public.

cgwtools documentation built on Oct. 21, 2023, 1:06 a.m.