similar to: Escaping regular expressions

Displaying 20 results from an estimated 30000 matches similar to: "Escaping regular expressions"

2009 Nov 08
2
Extracting matched expressions
Hi all, Is there a tool in base R to extract matched expressions from a regular expression? i.e. given the regular expression "(.*?) (.*?) ([ehtr]{5})" is there a way to extract the character vector c("one", "two", "three") from the string "one two three" ? Thanks, Hadley -- http://had.co.nz/
2007 Jun 28
3
: regular expressions: escaping a dot
What's really the problem with: > regexpr( '\.odt$', "xxxxYodt", perl=TRUE ) Warning: '\.' is an unrecognized escape in a character string Warning: unrecognized escape removed from "\.odt$" [1] 5 attr(,"match.length") [1] 4 I know that I could use: > regexpr( '[.]odt$', "xxxxYodt", perl=TRUE ) But it seems to me that
2011 May 04
4
Recursive objects
Hi all, Does anyone have a comprehensive list of recursive-type objects in R? is.recursive defines them as by exclusion: "most types of objects are regarded as recursive, except for vector types, ?NULL? and symbols (as given by ?as.name?)." I think this that means recursive objects are: * lists * pairlists * calls * expressions Did I miss anything? Hadley -- Assistant
2010 Aug 21
3
problems with merge() - the output has many repeated lines
Hi everyone, I have been merging many big dataframes (about 80000 rows each) and I never had this problem, but now it happened to me and I want to know if someone knows what could be happening. The final dataframe has many rows, an impossible number! I have done edit(dataframe) and I saw that there are many repeated rows (all equal). Thanks for any help, Cec?lia Carmo Universidade de
2011 Oct 18
9
readRDS and saveRDS
Hi all, Is there any chance that readRDS and saveRDS might one day become read.rds and write.rds? That would make them more consistent with the other reading and writing functions. Hadley -- Assistant Professor / Dobelman Family Junior Chair Department of Statistics / Rice University http://had.co.nz/
2010 Feb 08
5
Fast way to determine number of lines in a file
Hi all, Is there a fast way to determine the number of lines in a file? I'm looking for something like count.lines analogous to count.fields. Hadley -- http://had.co.nz/
2011 Dec 31
4
Base function for flipping matrices
Hi all, Are there base functions that do the equivalent of this? fliptb <- function(x) x[nrow(x):1, ] fliplr <- function(x) x[, nrow(x):1] Obviously not hard to implement (although it needs some more checks), just wondering if it had already been implemented. Hadley -- Assistant Professor / Dobelman Family Junior Chair Department of Statistics / Rice University http://had.co.nz/
2010 Mar 10
2
ggplot2: "varwidth"-equivalent for geom_boxplot?
Hi, Is there such a thing? If no: is it easily simulated? thanks, Joh
2011 Sep 21
3
Quelplot
Hi all, Does anyone have an R implementation of the queplot (K.?M. Goldberg and B.?Iglewicz. Bivariate extensions of the boxplot. Technometrics, 34(3):pp. 307?320, 1992)? I'm struggling with the estimation of the asymmetry parameters. Hadley -- Assistant Professor / Dobelman Family Junior Chair Department of Statistics / Rice University http://had.co.nz/
2007 Dec 11
5
book on regular expressions
Hello, Could someone recommend a good book on regular expressions with focus on applications/use as it might relate to R. I remember there was a mention of such a reference book recently, but I could not locate that message on the archive. Thanks. -Christos Christos Hatzis, Ph.D. Nuvera Biosciences, Inc. 400 West Cummings Park Suite 5350 Woburn, MA 01801 Tel: 781-938-3830
2010 Mar 19
5
Encrypt/decrypt in R
Hi all, Does any one know of any encryption/decryption algorithms in R? I'm not looking for anything robust - I want some way of printing output to the screen that the user can't read immediately, but can decrypt a little later. The main thing I don't want to the user to see is a number, so (e.g.) ROT13 isn't appropriate. Hadley -- Assistant Professor / Dobelman Family Junior
2012 Jul 27
1
Version of substitute that evaluates it's first argument
Hi all, Does there already exist a version of substitute that evaluates it's first argument? (i.e. it accepts an already quoted expression). This seems like something that's pretty handy, but I haven't found any existing function to do it: substitute_e <- function(expr, env) { eval(substitute(substitute(expr, env), list(expr = expr))) } f <- quote(x + y + z) substitute(f,
2010 Aug 24
2
Comparing/diffing strings
Hi all, all.equal is generally very useful when you want to find the differences between two objects. It breaks down however, when you have two long strings to compare: > all.equal(a, b) [1] "1 string mismatch" Does any one know of any good text diffing tools implemented in R? Thanks, Hadley -- Assistant Professor / Dobelman Family Junior Chair Department of Statistics / Rice
2015 Mar 30
3
Segfault with match()
This is admittedly a contrived example, but... data(housing, package ="MASS") x <- housing$Type + housing$Sat match(x, unique(x)) Hadley -- http://had.co.nz/
2010 Nov 09
3
How to detect if a vector is FP constant?
Hi all, What's the equivalent to length(unique(x)) == 1 if want to ignore small floating point differences? Should I look at diff(range(x)) or sd(x) or something else? What cut off should I use? If it helps to be explicit, I'm interested in detecting when a vector is constant for the purpose of visual display. In other words, if I rescale x to [0, 1] do I have enough precision to get
2011 May 02
2
Using substitute to access the expression related to a promise
Hi all, The help for delayedAssign suggests that you can use substitute to access the expression associated with a promise, and the help for substitute says: "If it is a promise object, i.e., a formal argument to a function or explicitly created using ?delayedAssign()?, the expression slot of the promise replaces the symbol. But this doesn't seem to work: > a <- 1 > b <- 2
2011 Apr 13
2
Line plots in base graphics
Am I missing something obvious on how to draw multi-line plots in base graphics? In ggplot2, I can do: data(Oxboys, package = "nlme") library(ggplot2) qplot(age, height, data = Oxboys, geom = "line", group = Subject) But in base graphics, the best I can come up with is this: with(Oxboys, plot(age, height, type = "n")) lapply(split(Oxboys[c("age",
2010 Aug 24
3
require is to suggests as what is to imports?
Hi all, If a package suggests another package in its description, you can check it at runtime with requires. How do you do check if a package is available without loading it, if you only want to access one function in the package namespace. Thanks, Hadley -- Assistant Professor / Dobelman Family Junior Chair Department of Statistics / Rice University http://had.co.nz/
2009 Sep 03
2
clearNames and unname
Just noticed these two functions (clearNames is stats and unname in base) that do the same thing. Hadley -- http://had.co.nz/
2010 Oct 08
2
What do you call the value that represents a missing argument?
Hi all, What's the official name for the value that represents a missing argument? e.g. formals(plot)$x str(formals(plot)$x) deparse(formals(plot)$x) is.symbol(formals(plot)$x) What's the correct way to create an object like this? (for example if you are manipulating the formals of a function to add an argument with no default value, as in http://stackoverflow.com/questions/3892580/).