similar to: Segfault with match()

Displaying 20 results from an estimated 30000 matches similar to: "Segfault with match()"

2015 Mar 30
1
Segfault with match()
I left out the warning - it's still there. The output object is malformed but either +.factor should prevent this or match() should check. Hadley On Mon, Mar 30, 2015 at 3:50 PM, William Dunlap <wdunlap at tibco.com> wrote: > Did you leave out the warning from "+", which should be an error, > as it produces an illegal ordered factor in this case and factor+factor >
2009 Nov 13
3
Escaping regular expressions
Hi all, Is there a method for escaping strings to be used regular expressions? i.e. if I have a user supplied string that I'd like to use as a fixed component is there a method that will turn (e.g.) ".$^" into "\\.\\$\\^" ? Thanks, Hadley -- http://had.co.nz/
2015 Jan 29
2
[Q] Get formal arguments of my implemented S4 method
I wish it didn't have to depend on the name '.local'. Back when I wrote a lot of S4 methods I avoided the auto-generated .local and named the local function something that made sense so that is was easier for a user to track down the source of an error. E.g., define the generic QQQ with numeric and integer methods: setGeneric("QQQ", function(x, ...)NULL)
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
2017 Mar 17
2
Support for user defined unary functions
Your example x = 5 exp = parse(text="f(uq(x)) + y +z") # expression: f(uq(x)) +y + z do_unquote(expr) # -> the language object f(5) + y + z could be done with the following wrapper for bquote my_do_unquote <- function(language, envir = parent.frame()) { if (is.expression(language)) { # bquote does not go into expressions, only calls
2018 May 03
0
Converting a list to a data frame
On Wed, May 2, 2018 at 11:53 AM, Jeff Newmiller <jdnewmil at dcn.davis.ca.us> wrote: > Another approach: > > ######## > library(tidyr) > L <- list( A = data.frame( x=1:2, y=3:4 ) > , B = data.frame( x=5:6, y=7:8 ) > ) > D <- data.frame( Type = names( L ) > , stringsAsFactors = FALSE > ) > D$data <- L
2017 Mar 17
2
Support for user defined unary functions
>After off list discussions with Jonathan Carrol and with >Michael Lawrence I think it's doable, unambiguous, >and even imo pretty intuitive for an "unquote" operator. For those of us who are not CS/Lisp mavens, what is an "unquote" operator? Can you expression quoting and unquoting in R syntax and show a few examples where is is useful, intuitive, and fits in to
2017 Mar 17
3
Support for user defined unary functions
I agree there is no reason they _need_ to be the same precedence, but I think SPECIALS are already have the proper precedence for both unary and binary calls. Namely higher than all the binary operators (except for `:`), but lower than the other unary operators. Even if we gave unary specials their own precedence I think it would end up in the same place. `%l%` <- function(x) tail(x, n =
2008 Nov 17
2
stringsAsFactors = FALSE
Hi all, I love the option to not automatically convert strings into factors, but there are three places that the current option doesn't work where I think it should: options(stringsAsFactors = FALSE) str(expand.grid(letters)) str(type.convert(letters)) df <- read.fwf(textConnection(paste(letters,collapse="\n")), 1) str(df) I think type.convert and read.fwf can be fixed by
2018 May 02
3
Converting a list to a data frame
Another approach: ######## library(tidyr) L <- list( A = data.frame( x=1:2, y=3:4 ) , B = data.frame( x=5:6, y=7:8 ) ) D <- data.frame( Type = names( L ) , stringsAsFactors = FALSE ) D$data <- L unnest(D, data) #> Type x y #> 1 A 1 3 #> 2 A 2 4 #> 3 B 5 7 #> 4 B 6 8 ######## On Wed, 2 May 2018, Eivind K.
2009 Jan 19
1
Floating point excepting when cbind()ing a matrix of grobs (or environments) with a 0-column matrix
library(grid) e <- rectGrob() # OR: # e <- environment() a <- matrix(list(e), ncol = 1, nrow = 2) b <- matrix(ncol = 0, nrow = 2) cbind(a, b) cbind(a, b) This reliably crashes R for me. I realise this is a rather esoteric error condition, but it crops up for me when creating matrices of grobs to be turned into a ggplot2 plot. Hadley -- http://had.co.nz/
2010 Feb 03
1
Proposal unary - operator for factors
Hi all, Why not make the unary minus operator return the factor with levels reversed? This would make it much easier to sort factors in descending order in part of an order statement. Hadley -- http://had.co.nz/
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,
2018 Aug 30
1
ROBUSTNESS: x || y and x && y to give warning/error if length(x) != 1 or length(y) != 1
Should the following two functions should always give the same result, except for possible differences in the 'call' component of the warning or error message?: f0 <- function(x, y) x || y f1 <- function(x, y) if (x) { TRUE } else { if (y) {TRUE } else { FALSE } } And the same for the 'and' version? g0 <- function(x, y) x && y g1 <- function(x, y) if
2019 Nov 04
3
Puzzled about a new method for "[".
On 5/11/19 3:41 AM, Hadley Wickham wrote: > For what it's worth, I don't think this strategy can work in general, > because a class might have attributes that depend on its data/contents > (e.g. https://vctrs.r-lib.org/articles/s3-vector.html#cached-sum). I > don't think these are particularly common in practice, but it's > dangerous to assume that you can restore a
2015 Jan 29
1
[Q] Get formal arguments of my implemented S4 method
Would we really need the special class or would simply checking the formals of the method against those of the generic be simple and fast enough? On Thu, Jan 29, 2015 at 9:41 AM, John Chambers <jmc at r-project.org> wrote: > I wouldn't want to add more to the current approach; if someone would like > to devote some time, the much preferable idea IMO would be to replace the >
2009 Oct 04
3
Stranger Behavior -maybe not
Hello everyone, When I run a for loop I noticed that the looping variable gets assigned the last value in the loop: For example, if I let h=200, and I run for(i in 1:h), i gets the value 200. What's wrong here? -- -Tony [[alternative HTML version deleted]]
2009 May 14
3
memory usage grows too fast
Hi All, I have a 1000x1000000 matrix. The calculation I would like to do is actually very simple: for each row, calculate the frequency of a given pattern. For example, a toy dataset is as follows. Col1 Col2 Col3 Col4 01 02 02 00 => Freq of ?02? is 0.5 02 02 02 01 => Freq of ?02? is 0.75 00 02 01 01 ? My code is quite simple as the following to find the pattern ?02?.
2017 Mar 16
2
Support for user defined unary functions
I guess this would establish a separate "namespace" of symbolic prefix operators, %*% being an example in the infix case. So you could have stuff like %?%, but for non-symbolic (spelled out stuff like %foo%), it's hard to see the advantage vs. foo(x). Those examples you mention should probably be addressed (eventually) in the core language, and it looks like people are already able
2010 Jul 30
3
simple table/matrix problem
Hi Given three vectors x <- c(fish=3, dogs=5, bats=2) y <- c(dogs=1, hogs=3) z <- c(bats=3, dogs=5) How do I create a multi-way table like the following? > out x y z bats 2 0 3 dogs 5 1 5 fish 3 0 0 hogs 0 3 0 ('out' is a matrix). See how the first line shows 'x' has 2 bats, 'y' has zero bats, and 'z' has 3 bats and so on for each