Re: [R] Export to LaTeX

From: Tobias Verbeke <tobias.verbeke_at_gmail.com>
Date: Fri 14 Jul 2006 - 18:44:06 EST

Mag. Ferri Leberl wrote:
> Dear Everybody!
> I want to export data to LaTeX. As I want to employ the data as freely as
> possible I want to avoid the xtable-command and instead generate some List
> like
>
> \MyOwnPrettyCommand{Adam}{Auer}{17}
> \MyOwnPrettyCommand{Bertram}{Bauer}{14}
> \MyOwnPrettyCommand{Christoph}{Huber}{75}
> \MyOwnPrettyCommand{Damian}{Dorfer}{69}
> \MyOwnPrettyCommand{Emanuel}{Eder}{43}
>
> with \MyOwnPrittyCommand defined elsewhere.
> As a pitty, if I make up about such a table in r, lets call it "A", and use
> the commands
>
> sink("tabelle.tex")
> A
> sink("anderedatei")
>
> tabelle.tex will look like this:
>
> [,1] [,2] [,3] [,4] [,5] [,6] [,7]
> [1,] "MyOwnPrettyCommand{" "Adam" "}{" "Auer" "}{" "17" "}"
> [2,] "MyOwnPrettyCommand{" "Bertram" "}{" "Bauer" "}{" "14" "}"
> [3,] "MyOwnPrettyCommand{" "Christoph" "}{" "Huber" "}{" "75" "}"
> [4,] "MyOwnPrettyCommand{" "Damian" "}{" "Dorfer" "}{" "69" "}"
> [5,] "MyOwnPrettyCommand{" "Emanuel" "}{" "Eder" "}{" "43" "}"
>
> So my question is how to export the data properly, without line-indices,
> without quotes but WITH backslashes.
>
mydf <- as.data.frame(

      rbind(c("Adam",      "Auer",   17),
      c("Bertram",   "Bauer",  14),
      c("Christoph", "Huber",  75),
      c("Damian",    "Dorfer", 69),
      c("Emanuel",   "Eder",   43))
      )

cat(

    paste("\\MyCommand{", mydf[,"V1"], "}{", mydf[,"V2"], "}{", mydf[,"V3"], "}",

          sep ="", collapse = "\n")
    , file = "tabelle.tex")

HTH,
Tobias
> Thank you in advance.
> Yours,
> Mag. Ferri Leberl
>
> ______________________________________________
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>
>
>



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Fri Jul 14 18:54:04 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Fri 14 Jul 2006 - 20:14:06 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.