similar to: apply with zero-row matrix

Displaying 20 results from an estimated 10000 matches similar to: "apply with zero-row matrix"

2018 Jul 23
2
oddity in transform
Note the inconsistency in the names in these two examples. X.Time in the first case and Time.1 in the second case. > transform(BOD, X = BOD[1:2] * seq(6)) Time demand X.Time X.demand 1 1 8.3 1 8.3 2 2 10.3 4 20.6 3 3 19.0 9 57.0 4 4 16.0 16 64.0 5 5 15.6 25 78.0 6 7 19.8 42 118.8 >
2018 Jul 30
0
apply with zero-row matrix
Hi David, Besides Martins point, there is also the issue that for a lot of cases you would still like to have the right class returned. Right now these are returns: > apply(matrix(NA_integer_,0,5), 1, class) character(0) > apply(matrix(NA_integer_,0,5), 1, identity) integer(0) > apply(matrix(NA,0,5), 1, identity) logical(0) In your case,
2018 Jul 24
2
oddity in transform
The idea is that one wants to write the line of code below in a general way which works the same whether you specify ix as one column or multiple columns but the naming entirely changes when you do this and BOD[, 1] and transform(BOD, X=..., Y=...) or other hard coding solutions still require writing multiple cases. ix <- 1:2 transform(BOD, X = BOD[ix] * seq(6)) On Tue, Jul 24, 2018 at
2018 Oct 02
1
Relevel confusing with numeric value
Something that bit me: The function relevel takes a factor, and a reference level to be promoted to the first place. If ?ref? is a character this level is promoted, if it?s a numeric the ?ref?-th level is promoted. Which turns out to be very confusing if you have factor with numeric values (e.g. when reading in a csv with some dirty numeric columns and stringsAsFactors TRUE) For example:
2018 Sep 14
3
Bug when calling system/system2 (and request for Bugzilla account)
Hi all, I found some strange behaviour, which I think is a bug. Could someone make an account for me on Bugzilla or pass on my report? The problem: When pressing Ctrl-C when a file is sourced in R, run from Terminal (macOS), sometimes the entire session is ended right away, while I just want to stop the script. This is the case when I press Ctrl-C while some functions are running that don?t
2018 Sep 14
2
Bug when calling system/system2 (and request for Bugzilla account)
I hope it's not too specific in my setup... I've tried with system2 added on the first line, so: Example.R: system2('ls', timeout=5) cat('Start non-interruptable functions\n') sample_a <- sample(1:1e7) sample_b <- sample(1:2e7) matching <- match(sample_a, sample_b) cat('Finished\n') Sys.sleep(10) And in terminal/bash: R --vanilla
2018 Aug 29
7
ROBUSTNESS: x || y and x && y to give warning/error if length(x) != 1 or length(y) != 1
# Issue 'x || y' performs 'x[1] || y' for length(x) > 1. For instance (here using R 3.5.1), > c(TRUE, TRUE) || FALSE [1] TRUE > c(TRUE, FALSE) || FALSE [1] TRUE > c(TRUE, NA) || FALSE [1] TRUE > c(FALSE, TRUE) || FALSE [1] FALSE This property is symmetric in LHS and RHS (i.e. 'y || x' behaves the same) and it also applies to 'x && y'.
2018 Jun 09
4
Date class shows Inf as NA; this confuses the use of is.na()
And now I've seen I copied the wrong part of ?is.na > The default method for is.na applied to an atomic vector returns a logical vector of the same length as its argument x, containing TRUE for those elements marked NA or, for numeric or complex vectors, NaN, and FALSE otherwise. Key point being "atomic vector" here. On Sat, Jun 9, 2018 at 1:41 PM, Joris Meys <jorismeys at
2018 Oct 15
4
sys.call() inside replacement functions incorrectly returns *tmp*
Kia Ora Let's say we have: "myreplacementfunction<-" = function (..., value) { call = sys.call () print (as.list (call) ) 0 } Then we call: x = 0 myreplacementfunction (x, y, z) = 0 It will return: [[1]] `myreplacementfunction<-` [[2]] `*tmp*` [[3]] y [[4]] z $value <promise: 0x06fb6968> There's two problems here. Firstly, x has to be defined otherwise we
2018 Aug 15
5
validspamobject?
Greetings, My R package has been showing warnings of the form: `validspamobject()` is deprecated. Use `validate_spam()` directly None of my code uses the function validspamobject, so it must be a problem in another package I'm calling, possibly spam or spdep. Has this problem occurred with other people? It doesn't have any deleterious effect, but it's annoying. In particular,
2017 Jun 07
2
purrr::pmap does not work
Hi All, I try to do a scatterplot for a bunch of variables. I plot a dependent variable against a bunch of independent variables: -- cut -- graphics::plot( v01_r01 ~ v08_01_up11, data = dataset, xlab = "Dependent", ylab = "Independent #1" ) -- cut -- It is tedious to repeat the statement for all independent variables. Found an alternative, i.e. : -- cut -- mu
2018 Jul 30
3
apply with zero-row matrix
Hi Martin, Fair enough for R functions in general. But the behaviour of apply violates the expectation that apply(m, 1, fun) calls fun n times when m has n rows. That seems pretty basic. Also, I understand from your argument why it makes sense to call apply and return a special result (presumably NULL) for an empty argument; but why should apply call fun? Cheers David On Mon, 30 Jul 2018 at
2018 Jul 30
0
apply with zero-row matrix
>>>>> David Hugh-Jones >>>>> on Mon, 30 Jul 2018 05:33:19 +0100 writes: > Forgive me if this has been asked many times before, but I > couldn't find anything on the mailing lists. > I'd expect apply(m, 1, foo) not to call `foo` if m is a > matrix with zero rows. In fact: > m <- matrix(NA, 0, 5) > apply(m,
2018 Jul 03
0
Inconsistencies when extracting with non-integer numeric indices near zero
Dear R-devel, When I was playing around with different kind of indices when subsetting I noticed some unexpected behaviours when using non-integer numeric indices, especially near zero. From the docs: ?Numeric values are coerced to integer as by as.integer<http://127.0.0.1:14277/help/library/base/help/as.integer> (and hence truncated towards zero).? But some behaviour differs from that, and
2018 Jul 24
0
oddity in transform
I don't think it has much to do with transform in particular: > BOD <- data.frame(Time = 1:6, demand = runif(6)) > BOD[["X"]] <- BOD[1:2] * seq(6); BOD Time demand X.Time X.demand 1 1 0.8649628 1 0.8649628 2 2 0.5895380 4 1.1790761 3 3 0.6854635 9 2.0563906 4 4 0.4255801 16 1.7023206 5 5 0.5738793 25 2.8693967 6 6 0.9996713
2018 Jul 24
0
oddity in transform
I think you meant to call BOD[,1] From ?transform, the ... arguments are supposed to be vectors, and BOD[1] is still a data.frame (with one column). So I don't think it's surprising transform gets confused by which name to use (X, or Time?), and kind of compromises on the name "Time". It's also in a note in ?transform: "If some of the values are not vectors of the
2018 Jun 11
2
Date class shows Inf as NA; this confuses the use of is.na()
Emil et al., On Mon, Jun 11, 2018 at 1:08 AM, Emil Bode <emil.bode at dans.knaw.nl> wrote: > I don't think there's much wrong with is.na(as_date(Inf, > origin='1970-01-01'))==FALSE, as there still is some "non-NA-ness" about > the value (as difftime shows), but that the output when printing is > confusing. The way cat is treating it is clearer: it
2009 Jun 24
1
"by" question
Hello all I have a big data frame and I regularly want to break it down into subsets, calculate some new data, and add it back to the data frame. At the moment my technique seems a bit ugly and embarrassing. Something like: result <- by(mydata, mydata$some_factor, function (x) { # do something to create a vector v with length(v) == nrow(x) return(v) }) # now result has a big list, argh...
2018 Aug 04
2
Puzzle or bug with matrix indexing
I'm not sure why this is happening: tmp <- data.frame( a = letters[1:2], b=c(TRUE, FALSE), stringsAsFactors = FALSE ) idx <- matrix(c(1, 2, 2, 2), 2, byrow = TRUE) tmp[idx] [1] " TRUE" "FALSE" Notice there is a space before the TRUE: " TRUE". This space isn't happening purely because of coercion: c("blah", TRUE, FALSE) [1]
2012 May 30
2
Prevent Samba clients from changing group ownership?
How can I prevent Samba clients from changing the group ownership of files? With the security mask parameter I can prevent Samba clients from changing some permission bits, but I can't find a parameter to prevent changing the group ownership