Displaying 20 results from an estimated 20000 matches similar to: "Testing for vectors"
2018 Jul 07
2
Testing for vectors
On Sat, Jul 7, 2018 at 12:54 PM, Duncan Murdoch
<murdoch.duncan at gmail.com> wrote:
> On 07/07/2018 1:20 PM, Hadley Wickham wrote:
>>
>> Hi all,
>>
>> Is there are base function that I've missed that tests if an object is
>> a vector in the dimensionality sense, rather than the data structure
>> sense? i.e. something that checks is.null(dim(x)) ?
2018 Jul 07
6
Testing for vectors
On Sat, Jul 7, 2018 at 1:50 PM, Gabe Becker <becker.gabe at gene.com> wrote:
> Hadley,
>
>>
>> I was thinking primarily of completing the set of is.matrix() and
>> is.array(), or generally, how do you say: is `x` a 1d dimensional
>> thing?
>
>
> Can you clarify what you mean by dimensionality sense and specifically 1d
> here?
What do we call a
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/
2018 Jun 08
6
Subsetting the "ROW"s of an object
Hi all,
Is there a better to way to subset the ROWs (in the sense of NROW) of
an vector, matrix, data frame or array than this?
subset_ROW <- function(x, i) {
nd <- length(dim(x))
if (nd <= 1L) {
x[i]
} else {
dims <- rep(list(quote(expr = )), nd - 1L)
do.call(`[`, c(list(quote(x), quote(i)), dims, list(drop = FALSE)))
}
}
subset_ROW(1:10, 4:6)
#> [1] 4 5 6
2018 Jun 08
2
Subsetting the "ROW"s of an object
I suspect this will have suboptimal performance since the TRUEs will
get recycled. (Maybe there is, or could be, ALTREP, support for
recycling)
Hadley
On Fri, Jun 8, 2018 at 10:16 AM, Berry, Charles <ccberry at ucsd.edu> wrote:
>
>
>> On Jun 8, 2018, at 8:45 AM, Hadley Wickham <h.wickham at gmail.com> wrote:
>>
>> Hi all,
>>
>> Is there a better to
2019 Mar 29
1
Discrepancy between is.list() and is(x, "list")
I know I said that I had no further comments on object oriented semantics.
However, I found a contradiction in the R documentation.
Gabriel Becker wrote:
> So, there are implicit classes, but *only when the data object is NOT an
"R object"
In the R Language Definition:
> The R specific function typeof returns the type of an R object.
> Lists have elements, each of which can
2018 Aug 25
4
Where does L come from?
Hi all,
Would someone mind pointing to me to the inspiration for the use of
the L suffix to mean "integer"? This is obviously hard to google for,
and the R language definition
(https://cran.r-project.org/doc/manuals/r-release/R-lang.html#Constants)
is silent.
Hadley
--
http://hadley.nz
2016 Aug 05
1
What happened to Ross Ihaka's proposal for a Common Lisp based R successor?
But you can easily fall back to R from within Julia; see
http://juliastats.github.io/RCall.jl/latest/
On Aug 5, 2016 1:27 PM, "Hadley Wickham" <h.wickham at gmail.com> wrote:
> No.
>
> Hadley
>
> On Fri, Aug 5, 2016 at 11:12 AM, Kenny Bell <kmbell56 at gmail.com> wrote:
> > Is it conceivable that Julia could be ported to use R syntax in a way
> that
2016 Aug 05
2
What happened to Ross Ihaka's proposal for a Common Lisp based R successor?
Is it conceivable that Julia could be ported to use R syntax in a way that
would allow the vastly larger numbers of R programmers to seamlessly
switch? Or equivalently, could an iteration of R itself do this?
On Fri, Aug 5, 2016, 9:00 AM Hadley Wickham <h.wickham at gmail.com> wrote:
> When it was being actively worked on, it had the advantage of existing.
>
> Hadley
>
> On
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
2016 Mar 01
2
Data frame printing buglet when multiple empty column names
This is admittedly minor, and you shouldn't have repeated names in a
data frame anyway, but:
df <- data.frame(1:3, 1:3, 1:3)
# Ok
setNames(df, c("x", "y", ""))
# Not ok
setNames(df, c("x", "", ""))
Hadley
--
http://hadley.nz
2015 Oct 13
1
A where() functions that does what exists() does but return the environment when object lives?
On Tue, Oct 13, 2015 at 4:43 PM, Hadley Wickham <h.wickham at gmail.com> wrote:
> Seems easy enough to write yourself:
>
> where <- function(x, env = parent.frame()) {
> if (identical(env, emptyenv()))
> return(NULL)
> if (exists(x, envir = env, inherits = FALSE))
> return(env)
> where(x, parent.env(env))
> }
>
> sample2 <-
2018 Jun 08
4
Subsetting the "ROW"s of an object
> On Jun 8, 2018, at 11:52 AM, Hadley Wickham <h.wickham at gmail.com> wrote:
>
> On Fri, Jun 8, 2018 at 11:38 AM, Berry, Charles <ccberry at ucsd.edu> wrote:
>>
>>
>>> On Jun 8, 2018, at 10:37 AM, Herv? Pag?s <hpages at fredhutch.org> wrote:
>>>
>>> Also the TRUEs cause problems if some dimensions are 0:
>>>
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
>
2015 Jun 12
3
RFC: Declaring "foo.bar" as nonS3method() ?!
On 12/06/2015 10:53 AM, Hadley Wickham wrote:
> To me, it seems like there's actually two problems here:
>
> 1) Preventing all() from dispatching to all.effects() for objects of
> class effects
> 2) Eliminating the NOTE in R CMD check
>
> My impression is that 1) actually causes few problems, particularly
> since people are mostly now aware of the problem and avoid
2015 Jun 30
2
Defining a `show` function breaks the print-ing of S4 object -- bug or expected?
Same thing happens with S3 if you redefine print(). I thought that
code was actually calculating the function to call rather than the
symbol to use, but apparently not. Shouldn't be too hard to fix.
luke
On Tue, 30 Jun 2015, Hadley Wickham wrote:
> On Tue, Jun 30, 2015 at 2:20 PM, Duncan Murdoch
> <murdoch.duncan at gmail.com> wrote:
>> On 30/06/2015 1:57 PM, Hadley
2007 Feb 25
8
Double-banger function names: preferences and suggestions
What do you prefer/recommend for double-banger function names:
1 scale.colour
2 scale_colour
3 scaleColour
1 is more R-like, but conflicts with S3. 2 is a modern version of
number 1, but not many packages use it. Number 3 is more java-like.
(I like number 2 best)
Any suggestions?
Thanks,
Hadley
2015 Jun 30
2
Defining a `show` function breaks the print-ing of S4 object -- bug or expected?
On 30/06/2015 1:57 PM, Hadley Wickham wrote:
> A slightly simpler formulation of the problem is:
>
> show <- function(...) stop("My show!")
> methods::setClass("Person", slots = list(name = "character"))
> methods::new("Person", name = "Tom")
> #> Error in (function (...) : My show!
Just to be clear: the complaint is
2018 Jun 08
3
Subsetting the "ROW"s of an object
> On Jun 8, 2018, at 10:37 AM, Herv? Pag?s <hpages at fredhutch.org> wrote:
>
> Also the TRUEs cause problems if some dimensions are 0:
>
> > matrix(raw(0), nrow=5, ncol=0)[1:3 , TRUE]
> Error in matrix(raw(0), nrow = 5, ncol = 0)[1:3, TRUE] :
> (subscript) logical subscript too long
OK. But this is easy enough to handle.
>
> H.
>
> On
2018 May 03
2
length of `...`
On Thu, May 3, 2018 at 9:50 AM, Duncan Murdoch <murdoch.duncan at gmail.com> wrote:
> On 03/05/2018 11:18 AM, Duncan Murdoch wrote:
>>
>> On 03/05/2018 11:01 AM, William Dunlap via R-devel wrote:
>>>
>>> In R-3.5.0 you can use ...length():
>>> > f <- function(..., n) ...length()
>>> > f(stop("one"),