Re: [R] How to format R code in LaTex documents
Another alternative is to simply use LyX (www.lyx.org), which is a WYSIWYG (graphical) front-end for LaTeX. There's an code environment where you can paste everything right in, and it'll show in your PDF output exactly as it appears while editing. Also, not an answer to your question, but you might also want to check out xtable (http://cran.r-project.org/src/contrib/Descriptions/xtable.html), which allows R to output LaTeX that can be pasted into your .tex file. On 1/15/07, Tim Calkins [EMAIL PROTECTED] wrote: Consider using the fancyvrb package if you need additional customization. On 1/16/07, Benjamin Dickgiesser [EMAIL PROTECTED] wrote: Hi, I am planning on putting some R script in an appendix of a LaTex document. Can anyone recommend me a way of how to format it? Is there a way to keep all line breaks without having to insert \\ in every single line? Thank you! Benjamin __ 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 and provide commented, minimal, self-contained, reproducible code. -- Tim Calkins 0406 753 997 __ 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 and provide commented, minimal, self-contained, reproducible code. -- Ubuntu Linux 6.06 (Dapper Drake) [[alternative HTML version deleted]] __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] Filtering a data frame by regular expression
Hello, I am having difficulty filtering a data frame. I would like to take all the rows of a data frame where column A contains the regular expression UTI (or some other regex). Here's what I've got: utiRE - function (avector) { occurs - c() r1 - UTI for (x in avector) { if (!is.na(grep(r1,x,perl=TRUE))) { occurs - c(occurs, TRUE) } else { occurs - c(occurs, FALSE) } I know this is a clunky way of doing it, but I tried more natural ways first (i.e. without iteration), to no avail. I think the problem is that when I iterate through the list, the strings in avector get turned into numbers. Any solutions? Thanks! -- Ubuntu Linux 6.06 (Dapper Drake) [[alternative HTML version deleted]] __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Filtering a data frame by regular expression
Thank you so much! It looks like as.character was the missing ingredient. Neil On 12/9/06, Chuck Cleland [EMAIL PROTECTED] wrote: Neil McLeod wrote: Hello, I am having difficulty filtering a data frame. I would like to take all the rows of a data frame where column A contains the regular expression UTI (or some other regex). Here's what I've got: utiRE - function (avector) { occurs - c() r1 - UTI for (x in avector) { if (!is.na(grep(r1,x,perl=TRUE))) { occurs - c(occurs, TRUE) } else { occurs - c(occurs, FALSE) } I know this is a clunky way of doing it, but I tried more natural ways first (i.e. without iteration), to no avail. I think the problem is that when I iterate through the list, the strings in avector get turned into numbers. Any solutions? The following approach works for me: iris[grep(a$, iris$Species),] iris[grep(^v, as.character(iris$Species)),] Thanks! -- Chuck Cleland, Ph.D. NDRI, Inc. 71 West 23rd Street, 8th floor New York, NY 10010 tel: (212) 845-4495 (Tu, Th) tel: (732) 512-0171 (M, W, F) fax: (917) 438-0894 -- Ubuntu Linux 6.06 (Dapper Drake) [[alternative HTML version deleted]] __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] How to access a column by its label?
Hi all, Is there any way to access a column of a data frame by its label (title) rather than its column index? For example, I'd like to be able to select animals[,weight] rather than animals[,3], if the third column of the animals data frame has the label weight. Thank you! [[alternative HTML version deleted]] __ 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 and provide commented, minimal, self-contained, reproducible code.