Skip to content

R2HTML and output from a function

2 messages · Fredrik Karlsson, Bart Joosen

#
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
#
Hello,

did you try to replace the print commands with HTML?
But first you have to specify a file through HTMLStart and at the end of the
function HTMLStop.
Including plots is no problem, but you have to save them and then with the
HTMLInsertGraph function insert them into your report.

Kind regards

Bart
Fredrik Karlsson wrote: