[R] Copying tables from R to Excel

Angel Rodriguez angel.rodriguez at matiainstituto.net
Wed Sep 24 12:32:14 CEST 2014


Dear Ivan, Duncan, David and Roger,

Thank you for your answers. 

Yes, I had typed library(R2HTML)

I've typed also:

> library("mediation")
> library("sandwich")
> set.seed(2014)
> med.fit <- glm(estuprimas ~ edad_c + sexo + regalf + deprinf, family="binomial" ,data=child65)
> out.fit <- glm(benvii ~ edad_c + sexo + regalf + deprinf + estuprimas, family="binomial" ,data=child65)
> med.out <- mediate(med.fit, out.fit, treat = "deprinf", mediator = "estuprimas", robustSE = TRUE, sims=1000, control.value = "no", treat.value = "s\xed")
> summary(med.out)


If I type now:

> HTML( summary(med.out), file("clipboard", "w"), append=F )

I can paste to Excel but results are not organized in columns.

If I try:

> toExcel <- function(x, tag=FALSE) {write.table(x, "clipboard-128", sep="\t", row.names=tag)}
> 
> toExcel(summary(med.out))
 Show Traceback
 
 Rerun with Debug
 Error in as.data.frame.default(x[[i]], optional = TRUE, stringsAsFactors = stringsAsFactors) : 
  cannot coerce class "c("summary.mediate", "mediate")" to a data.frame 


Angel Rodríguez-Laso

	[[alternative HTML version deleted]]



More information about the R-help mailing list