[R] R2HTML and output from a function

Fredrik Karlsson dargosch at gmail.com
Thu Dec 18 12:18:29 CET 2008


Dear list,

I am trying to construct a report function that would go through all
the object in the current environment and print them in HTML form.
What I have got is:

dataReport <- function(){

	#First tables
	tabs <- ls(sys.frame(), pattern=".*table")
	
	for(currT in tabs){
		cat("\n\n")
		print(currT)
		if(length(dim(get(currT))) > 2){
			#We have to use ftable
			require(Hmisc)
			print(ftable(get(currT)))	
		}
		else{
			print(get(currT))
			print(chisq.test(get(currT)))	
		}
		
	}	
	
	#Next, the lme models
	mods <- ls(sys.frame(), pattern=".*lme")
	require(nlme)
	for(currM in mods){
		if(class(get(currM)) %in% c("lme","lm")){
			cat("\n\n")
			print(currM)

			print(anova(get(currM)))	
		}
		
	}		
	
}

This generally works in the console. However, it I try to get the
output processed by R2HTML, I get only the output of one table.
So, now I have 2 questions:

1) Is there a way to get the output of all the print commands of the
function to be processed by R2HTML?
2) Is there a way to include saved plots in the output too?


/Fredrik


-- 
"Life is like a trumpet - if you don't put anything into it, you don't
get anything out of it."



More information about the R-help mailing list