search for: istru

Displaying 20 results from an estimated 157 matches for "istru".

Did you mean: istr
2009 Oct 10
1
isFALSE
Hello, Just wondering why there is "isTRUE" and not "isFALSE". Romain -- Romain Francois Professional R Enthusiast +33(0) 6 28 91 30 30 http://romainfrancois.blog.free.fr |- http://tr.im/BcPw : celebrating R commit #50000 |- http://tr.im/ztCu : RGG #158:161: examples of package IDPmisc `- http://tr.im/yw8E : New R package...
2010 Apr 07
1
Vectorized forms of isTRUE, identical and all.equal?
Dear all, I'm wondering if there exist vectorized forms of 'isTRUE()', 'identical()' and 'all.equal()'. My problem is that I wish to test if each element of a vector is equal to a particular value (or numerically close), whilst dealing carefully with NAs and so on. However, using sapply() with identical() is very slow because it makes so many...
2020 Aug 11
2
M[cbind()] <- assignment with Matrix object loses attributes
...igned attributes. I dug around in the R code for Matrix trying to find the relevant machinery but my brain started to hurt too badly ... ?? Will submit this as a bug if it seems warranted. library(Matrix) m1 <- matrix(1:9,3,3) m1 <- Matrix(m1) attr(m1,"junk") <- 12 stopifnot(isTRUE(attr(m1,"junk")==12))? ## OK m1[cbind(1:2,2:3)] <- 1 stopifnot(isTRUE(attr(m1,"junk")==12)) ## not OK attr(m1,"junk") ## NULL ## note I have to use the ugly stopifnot(isTRUE(...)) because a missing attribute returns NULL, an assignment to NULL returns NULL, and...
2006 Jan 10
2
Correct way to test for exact dimensions of matrix or array
...I thought that the following would work: > obj=matrix(1,nrow=3,ncol=5) > identical( dim( obj) , c(3,5) ) [1] FALSE But it doesn't because c(3,5) is numeric and the dims are integer. I therefore ended up doing something like: > identical( dim( obj) , as.integer(c(3,5))) OR > isTRUE(all( dim( obj) == c(3,5) )) Neither of which feel quite right. Is there a 'correct' way to do this? Many thanks, Greg Jefferis. PS Thinking about it, the second form is (doubly) wrong because: > obj=array(1,dim=c(3,5,3,5)) > isTRUE(all( dim( obj) == c(3,5) )) [1] TRUE OR >...
2006 Jan 30
2
'all' inconsistent?
Hello, I came across the following behavior, which seems illogical to me. I don't know if it is a bug or if I'm missing something: > all(logical(0)) [1] TRUE > any(logical(0)) [1] FALSE > isTRUE(logical(0)) [1] FALSE This actually came up in practice when I did something like > all( names(x) %in% vec ) as an error-handling, and I was hoping that it would work regardless of whether x had names or not. I can clearly work around it, but it seemed like strange behavior to me. Thanks, E...
2007 Sep 03
3
When 1+2 != 3 (PR#9895)
...following equation 1 + 2 == 3, I obviously obtain the value TRUE. But when I tryed to do the same using real number (i.e. 0.1 + 0.2 == 0.3) I obtained an unusual FALSE. In the online help there are some tricks for this problem. It suggests to use identical(...) which again answer FALSE. Only using isTRUE(all.equal(0.3, 0.1 + 0.2)) I can obtain the true value TRUE. But the problem does not concern only the operator ==. Many other functions, among over: sort, order, unique, duplicate, identical are not able to deal with this problem. This is very dangerous because no advice are provide by the onli...
2018 Sep 03
2
compairing doubles
Maybe a new Operator could be defined for a fast and easy double Comparison: `~~` `~~` <- function (e1, e2) all.equal(e1, e2) And document it properly.
2005 Aug 29
5
Testing if all elements are equal in a vector/matrix
Is there a canonical way to check if all elements of a vector or matrix are the same? Solutions below work, but look hackish to me. > x <- rep(1, 10) > all(x == x[1]) # == operator does not provide for small differences [1] TRUE > isTRUE(all.equal(x, rep(x[1], length(x)))) # ugly [1] TRUE Best, Vincent -- Vincent Goulet, Associate Professor ??cole d'actuariat Universit?? Laval, Qu??bec Vincent.Goulet at act.ulaval.ca http://vgoulet.act.ulaval.ca
2018 Mar 14
0
Possible Improvement to sapply
...anoseconds > expr min lq mean median uq max neval > identical("array", FALSE) 975 1058.5 1257.95 1119.5 1250.0 9299 100 > isFALSE("array") 409 433.5 658.76 446.0 476.5 9383 100 Thank you Henrik! The speed of the new isTRUE() and isFALSE() is indeed amazing compared to identical() which was written to be fast itself. Note that the new code goes back to a proposal by Herv? Pag?s (of Bioconductor fame) in a thread with R core in April 2017. The goal of the new code actually *was* to allow call like isTRUE(c(a = T...
2020 Aug 22
1
M[cbind()] <- assignment with Matrix object loses attributes
Thanks for taking a look! Hmm, really? In `R Under development (unstable) (2020-08-14 r79020)`, doing the indexed assignment with a regular matrix (as opposed to a Matrix) appears to preserve attributes. m1 <- matrix(1:9,3,3) attr(m1,"junk") <- 12 stopifnot(isTRUE(attr(m1,"junk")==12)) ## OK m1[cbind(1:2,2:3)] <- 1 stopifnot(isTRUE(attr(m1,"junk")==12)) ## OK attr(m1,"junk") ## 12 Do you lose attributes with this code? It would surprise me if this had changed in recent versions but I guess anything's possible ......
2005 Oct 21
1
The behavior of match function
> x<-1:10 > y<-x+1e-20 > x [1] 1 2 3 4 5 6 7 8 9 10 > y [1] 1 2 3 4 5 6 7 8 9 10 > identical(x,y) [1] FALSE > match(x,y) [1] 1 2 3 4 5 6 7 8 9 10 What's the principle the function use to determine if x match y? Thank you! 2005-10-21 ------ Deparment of Sociology Fudan University My new mail addres is ronggui.huang at gmail.com
2008 Feb 18
2
Number of digits of a value for problem 7.31 RFAQ
Hello dear R users! I did not find a function which gives information about the number of digits of a value shown by R. Do you know one? I need it to solve the problem (see RFAQ 7.31)that 0.2==0.2+0.1-0.1 FALSE The solution suggested in RFAQ is to use isTRUE(all.equal(0.2,0.2+0.1-0.1)) But if I want to compare inequality: 0.2<=0.2 +0.1-0.1 TRUE but 0.2<=0.2 +0.1-0.1 FALSE bad! but in this case all.equal does not work I think... Unless to write a double condition like 0.2>0.2 +0.1-0.1 | isTRUE(all.equal(0.2,0.2 +0.1-0.1)) The solution I fou...
2020 Feb 21
0
function(x) !is.na(x) & x "is_true(.)" etc. was: [R] How to index..
Diverted from R-help to R-devel, as I've changed the focus to consider adding new functions to R : >>>>> peter dalgaard >>>>> on Fri, 21 Feb 2020 10:46:16 +0100 writes: > It has isTRUE, but that is not vectorized, and in fact explicitly tests length==1, so >> isTRUE(c(TRUE,FALSE,NA)) > [1] FALSE >> isTRUE(c(TRUE,TRUE, TRUE)) # I thought I thaw a puddycat... ;-) > [1] FALSE >> Vectorize(isTRUE)(c(TRUE,FALSE,NA)) > [1] TRUE FALSE...
2018 Aug 31
2
compairing doubles
El vie., 31 ago. 2018 a las 16:00, Mark van der Loo (<mark.vanderloo at gmail.com>) escribi?: > > how about > > is_evenly_spaced <- function(x,...) all.equal(diff(sort(x)),...) This doesn't work, because 1. all.equal does *not* return FALSE. Use of isTRUE or identical(., TRUE) is required if you want a boolean. 2. all.equal compares two objects, not elements in a vector. I?aki > > (use ellipsis to set tolerance if necessary) > > > Op vr 31 aug. 2018 om 15:46 schreef Emil Bode <emil.bode at dans.knaw.nl>: >> >> Agr...
2018 Aug 31
3
compairing doubles
...equal would be the way to go. I wouldn't call it a bug, it's simply part of working with floating point numbers, any language has the same issue. And while we're at it, I think the function can be a lot shorter: .is_continous_evenly_spaced <- function(n){ length(n)>1 && isTRUE(all.equal(n[order(n)], seq(from=min(n), to=max(n), length.out = length(n)))) } Cheers, Emil El vie., 31 ago. 2018 a las 15:10, Felix Ernst (<felix.gm.ernst at outlook.com>) escribi?: > > Dear all, > > I a bit unsure, whether this qualifies as a bug, but...
2009 Jun 16
1
Testing if all elements are equal in a vector/matrix
...ng this? Regards Utkarsh From: Francisco J. Zagmutt <gerifalte28_at_hotmail.com <mailto:gerifalte28_at_hotmail.com?Subject=Re:%20%5BR%5D%20Testing%20if%20all%20elements%20are%20equal%20in%20a%20vector/matrix>> Date: Tue 30 Aug 2005 - 06:05:20 EST Hi Doran The documentation for isTRUE reads 'isTRUE(x)' is an abbreviation of 'identical(TRUE,x)' so actually Vincent's solutions is "cleaner" than using identical :) Cheers Francisco />From: "Doran, Harold" <HDoran@air.org> / />To: <vincent.goulet@act.ulaval.ca>, <r-he...
2006 Feb 03
2
all.equal() and which()
Please excuse the lack of a complete dataset here, if its needed I'll be happy to provide it. Can anyone show me how to rewrite this? Browse[1]> time(data)[24210:24220] [1] 24.209 24.210 24.211 24.212 24.213 24.214 24.215 24.216 24.217 [10] 24.218 24.219 Browse[1]> which(time(data)==24.211) numeric(0) I'm assuming its an eps fault but which(all.equal(time(data),24.211)) dosnt
2005 Jun 26
2
is.all.equal
...states "is.all.equal should be used for programming, typically in if expressions. It is a simple wrapper using identical as shown in the documentation there.", but is.all.equal is not explicitly defined there (although there is a hint in the comments that is.all.equal <- function(x,y) isTRUE(all.equal(x,y))). Could the documentation be corrected? (or even better, how about defining is.all.equal by default) Thanks, Hadley
2018 Mar 13
2
Possible Improvement to sapply
...identical(c(a = FALSE), FALSE) [1] FALSE Assuming the latter is not an issue, there are 69 places in base R where isFALSE() could be used: $ grep -E "identical[(][^,]+,[ ]*FALSE[)]" -r --include="*.R" | grep -F "/R/" | wc 69 326 5472 and another 59 where isTRUE() can be used: $ grep -E "identical[(][^,]+,[ ]*TRUE[)]" -r --include="*.R" | grep -F "/R/" | wc 59 307 5021 /Henrik On Tue, Mar 13, 2018 at 9:21 AM, Doran, Harold <HDoran at air.org> wrote: > Quite possibly, and I?ll look into that. Aside from...
2013 May 30
2
RFC: a "safe" uniroot() function for future R
...;, lower, upper, if(trace >= 2)"\n" else " ... ")) Delta <- function(u) 0.01* pmax(1e-7, abs(u)) ## Two cases: if(is.null(Sig)) { ## case 1) 'Sig' unspecified --> extend (lower, upper) at the same time delta <- Delta(c(lower,upper)) while(isTRUE(f.lower*f.upper > 0) && any(iF <- is.finite(c(lower,upper)))) { if(iF[1]) f.lower <- f(lower <- lower - delta[1]) if(iF[2]) f.upper <- f(upper <- upper + delta[2]) if(trace >= 2) cat(sprintf(" .. modified lower,upper: (%15g,%15g)\n", lower,upp...