Displaying 20 results from an estimated 300 matches similar to: "How to format R code in LaTex documents"
2006 Sep 25
3
Best use of LaTeX listings package for pretty printing R code
This is what I have been using. Does anyone have a better way? In
particular I would like to see letters in comment strings not stretched
so much. Thanks -Frank
\documentclass{article}
\usepackage{listings,relsize}
\lstloadlanguages{R}
\newcommand{\lil}[1]{\lstinline|#1|}
\begin{document}
\lstset{language=R,basicstyle=\smaller,commentstyle=\rmfamily\smaller,
showstringspaces=false,%
2012 Nov 01
1
How to nicely display R code with the LaTeX package 'listings'?
Dear expeRts,
What's a 'good' (nice-looking, easy-to-read) setup for the LaTeX package
'listings' to display R code?
The two versions below are partly inspired by the settings of the package
SweaveListingUtils and
http://r.789695.n4.nabble.com/R-How-to-format-R-code-in-LaTex-documents-td816055.html
Any suggestions, comments, or improvements are welcome.
Cheers,
Marius
###
2008 Oct 17
1
R-code in Latex --- $ sign causes error
hi,
here's what i have:
\lstset{
basicstyle=\ttfamily,
keywordstyle=\bfseries,
showstringspaces=false,
columns = fullflexible,
mathescape = true,
language=R
}
\begin{lstlisting}
lst$val<-val
\end{lstlisting}
./software.tex:16:Extra }, or forgotten \endgroup. lst$
the culprit here is the $ sign.
thanks.
ps:
i'm posting here rather than Latex is bec i guess an R user is
2011 Nov 23
1
R-latex syntax highlighting?
Hello,
Can anyone provide or point me to a good setup for the listings latex package that would produce nice R-syntax highlighting?
I am using an example I found in internet for setting up listings like this:
\lstset{
language=R,
basicstyle=\scriptsize\ttfamily,
commentstyle=\ttfamily\color{gray},
numbers=left,
numberstyle=\ttfamily\color{red}\footnotesize,
stepnumber=1,
numbersep=5pt,
2004 Oct 04
4
Off-Topic: LaTeX package listings
Hola!
I ask here since I learnt from this list that the LaTeX package listings
should be good
for typesetting R code. I encountered one problem:
\begin{lstlisting}
X %*% V
\end{lstlisting}
in the output the * in %*% disappears! same with %/%, etc, the /
disappears.
Any ideas?
Kjetil
--
Kjetil Halvorsen.
Peace is the most effective weapon of mass construction.
--
2006 Sep 17
2
Insert R code in LaTeX document
Un texte encapsul? et encod? dans un jeu de caract?res inconnu a ?t? nettoy?...
Nom : non disponible
Url : https://stat.ethz.ch/pipermail/r-help/attachments/20060917/27772bd9/attachment.pl
2004 Apr 26
1
need settings for the listings package
Hi,
I am typesetting R code in TeX using the listings package. I have
experimented with various settings for the text, but all look a bit
ugly. This might be because I have no typographic experience ;-)
I would really appreciate if people sent me the settings they use for
the listings package (eg in the \usepackage line, or \lstset, I am
thinking about choices for basicstyle, ... etc). I
2010 Jan 09
4
parsing pdf files
I have a pdf file that I would like to parse into R:
http://www.williams.edu/Registrar/geninfo/faculty.pdf
For now, I open the file in Acrobat by hand, then save it "as text"
and then use readLines(). That works fine but a) I am concerned that
some information may be lost and b) I may be doing this a lot, so I
would rather have R grab the information from the pdf file directly.
So: is
2003 Apr 05
3
slides in linux R
Hello,
In S-Plus Windows you can transform graphics to Powerpoint very easily, in R Windows you can use enhanced metafiles (.emf) and Powerpoint almost as easy. Is there a simular way with R in Linux to transform to the presentation program in StarOffice or OpenOffice or are you stuck with the pdf device?
Fredrik Lundgren
2009 Sep 03
1
Sweavelistingutil: Encoding problems
Hello,
I am not sure whether this is a bug or lack of R experience.
However, I am using your Sweavelistingutil package, which is very
nice. Obviously I use it to create LaTeX files. These are encoded in
utf8.
However, when I use the Sweavelistingutil is uses some funky
character for "`" and "'" that is not recognized.
Here is an example from my tex-file:
,----
|
2009 Jan 28
2
OT: Adding verbatim R code text into LaTeX documents: texttt; verb or url?
Hi all
I use Sweave extensively to mix R and LaTeX, and often have R code appearing in my LaTeX document.
Just a quick question then: What is the best way to add example of R commands into LaTeX in-line? (That is, not using Sweave.) For example, suppose I wish to place in my document this instruction:
...is done in R using the command \verb|lm( y ~ var.one + var.two )| as follows:
I
2007 Jan 08
4
Export dataframe to txt
Hi all,
Is there a function to export a dataframe to a text file?
I want to store a large set of data which I have saved in a dataframe
in my workspace and copy and past doesn't cut it.
Thank you,
Benjamin
2006 Oct 26
4
Header of dataframe
Hi
I am fairly new to R and I would appreciate some help to hopefully a
trivial problem.
I created a function:
summary.aggregate <- function(y, ...)
{
temp.mean <- aggregate(y, FUN=mean, ...)
temp.sd <- aggregate(y, FUN=sd, ...)
temp.length <- aggregate(y, FUN=length, ...)
temp <- data.frame(cbind(mean=temp.mean$x,stdev=temp.sd$x,n=temp.length$x))
}
this outputs e.g.:
2007 Mar 14
4
abs(U) > 0 where U is a vector?
Hi,
I am looking for a way to compare if every element of a vector is > 0.
i.e.
while(abs(U) > 0)
{
..
}
is there a function for this or do I have to write one?
I'd appreciate your help!
Benjamin
2002 Nov 13
1
Package documentation and rd.sty
Hi all,
I've got a basic question regarding package documentation and rd.sty. I
wrote my first own package, and now I would like to place the documentation
into the appendix of another LaTex document. Seemingly I cannot simply
\usepackage{Rd}, as this will modify the page-settings of my document. Is
there a minimum style file which will just define the environments and
commands needed for
2007 Jan 08
3
Speeding things up
Hi,
is it possible to do this operation faster? I am going over 35k data
entries and this takes quite some time.
for(cnt in 2:length(sdata$date))
{
if(sdata$value[cnt] < sdata$value[cnt - 1]) {
sdata$ddtd[cnt] <- sdata$ddtd[cnt - 1] + sdata$value[cnt - 1] -
sdata$value[cnt]
}
else sdata$ddtd[cnt] <- 0
}
return(sdata)
Thank you,
Benjamin
2007 Jan 09
2
Logical operations or selecting data from data.frames
Hi all,
why doesn't something like this does not work?
speedy <-
(sdata$VaR < sdata$DdtdAbs) && sdata$DdtdDuration >= qpois(pct,lambda) &&
sdata$Ddtd > MinDD
or sdata$Ddtd[sdata$Ddtd > 0 && sdata$VaR < sdata$DdtdAbs]
sdata looks like this:
dataId date value Ddtd VaR DdtdAbs DdtdDuration
18948 79637 2004-07-27 10085.10
2006 Nov 07
2
Boxplot
Hi,
I am new to R and am still trying to get a grip of it.
I have data in this format:
Run Lab Batch Y
1 1 1 1 608.781
2 2 1 2 569.670
3 3 1 1 689.556
4 4 1 2 747.541
5 5 1 1 618.134
6 6 1 2 612.182
7 7 1 1 680.203
8 8 1 2 607.766
9 9 1 1 726.232
and I want to make a boxplot of the Y values for each
2007 Feb 18
1
Help with pair plot
Hi,
I'm trying to create a plot using pair.
Currently I'm doing the following
pairs(~mpg + hp + wt , data=cars, labels = c("Miles per
Gallon","Horsepower","Weight"),pch = c(24,25)[unclass(cars$tr + 1)],
bg = c("red", "green3")[unclass(cars$tr + 1)],panel=panel.smooth)
for the attached dataset. However,instead of using panel.smooth I
2006 Nov 20
1
Basic R timeseries data manipulation
Hi,
suppose I have a time series rt. Why does this code not work?
rt <- data
n <- length(rt) - 2
at <- vector(length = n)
at = rt-(3.75101e-04 + 9.61877e-02 * rt[-1] - 2.48071e-02 * rt[-2])
Thank you,
Benjamin