Displaying 20 results from an estimated 10000 matches similar to: "bugs in head() and tail()"
2019 Mar 26
0
bugs in head() and tail()
Hi Abs,
This is because the class is "f", not c("f", "function") in your second
example. S3 method dispatch is doing what you (unintentionally, I presume)
asked it to do.
The S3 method which allows head to take functions is utils:::head.function.
S3 can only be expected to understand inheritance if the value of class(f)
is multivalued. It doesn't have any way
2019 Mar 27
0
bugs in head() and tail()
On Wed, Mar 27, 2019 at 1:52 AM Abs Spurdle <spurdle.a at gmail.com> wrote:
>
> In the case of head.default(), it assumes that the object is a vector, or
> something similar.
>
No it doesn't. It assumes (ultimately) that x[seq_len(n)] is the correct
way to generate a "head" of something. Which is reasonable. That's
dependent on the implementation of the `[`
2019 Mar 26
4
Discrepancy between is.list() and is(x, "list")
If I can merge this thread with the one I started yesterday...
> "If the object does not have a class attribute, it has an implicit
class..."
> which I take to mean that if an object does have a class attribute it
does not also have an implicit class.
> I think this is reasonable behavior. Consider the "Date" class, which
stores values as "numeric":
>
2019 Mar 26
4
Discrepancy between is.list() and is(x, "list")
> I have noticed a discrepancy between is.list() and is(x, ?list?)
There's a similar problem with inherits().
On R 3.5.3:
> f = function () 1
> class (f) = "f"
> is.function (f)
[1] TRUE
> inherits (f, "function")
[1] FALSE
I didn't check what happens with:
> class (f) = c ("f", "function")
However, they should have the same
2019 Jul 13
2
head.matrix can return 1000s of columns -- limit to n or add new argument?
Hi Michael and Abby,
So one thing that could happen that would be backwards compatible (with the
exception of something that was an error no longer being an error) is head
and tail could take vectors of length (dim(x)) rather than integers of
length for n, with the default being n=6 being equivalent to n = c(6,
dim(x)[2], <...>, dim(x)[k]), at least for the deprecation cycle, if not
2019 Jul 08
2
head.matrix can return 1000s of columns -- limit to n or add new argument?
I think of head() as a standard helper for "glancing" at objects, so I'm
sometimes surprised that head() produces massive output:
M = matrix(nrow = 10L, ncol = 100000L)
print(head(M)) # <- beware, could be a huge print
I assume there are lots of backwards-compatibility issues as well as valid
use cases for this behavior, so I guess defaulting to M[1:6, 1:6] is out of
the
2019 Sep 16
5
head.matrix can return 1000s of columns -- limit to n or add new argument?
>>>>> Michael Chirico
>>>>> on Sun, 15 Sep 2019 20:52:34 +0800 writes:
> Finally read in detail your response Gabe. Looks great,
> and I agree it's quite intuitive, as well as agree against
> non-recycling.
> Once the length(n) == length(dim(x)) behavior is enabled,
> I don't think there's any need/desire to have
2019 Nov 15
2
class(<matrix>) |--> c("matrix", "arrary") [was "head.matrix ..."]
> > And indeed I think you are right on spot and this would mean
> > that indeed the implicit class
> > "matrix" should rather become c("matrix", "array").
>
> I've made up my mind (and not been contradicted by my fellow R
> corers) to try go there for R 4.0.0 next April.
I'm not enthusiastic about matrices extending arrays.
If a
2019 Sep 17
2
head.matrix can return 1000s of columns -- limit to n or add new argument?
>>>>> Fox, John
>>>>> on Tue, 17 Sep 2019 12:32:13 +0000 writes:
> Dear Herve,
> Sorry, I should have said "matrices" rather than "data frames" -- brief() has methods for both.
> Best,
> John
> -----------------------------
> John Fox, Professor Emeritus
> McMaster University
>
2009 Dec 20
3
Object of type 'closure' not subsettable
Hi all,
How can I overcome the error "object of type 'closure' not subsettable"
I ran the following script
seq <- paste(seq(1914, 1916, by=1), "*.y", sep=".") # make sequence
c <- 3 # total number of files
d2 <- file # creates dummy file
# Input sequence in loop
for (i in 1:3){
list <- list.files("~/ukcp09/txt/x.djf", seq[[i]])
file
2020 Jan 28
4
matplot.Date & matplot.POSIXct
????? Thanks for the reply.
On 2020-01-27 19:56, Abby Spurdle wrote:
> Maybe I'm missing something really obvious here, but I was unable to
> create a matrix out of POSIXct object(s).
> Perhaps that deserves a separate discussion...?
????? Can you provide an example?
????? The standard matplot application that concerns me is with
matplot(x, y, ...) where x has class Date or
2011 Aug 18
3
Error message: object of type 'closure' is not subsettable
Dear R-users
I need to calibrate kappa, rho, eta, theta, v0 in the following code, see
below. However when I run it, I get:
y <- function(kappahat, rhohat, etahat, thetahat, v0hat) {sum(difference(k,
t, S0, X, r, implvol, q, kappahat, rhohat, etahat, thetahat, v0hat)^2)}
> nlminb(start=list(kappa, rho, eta, theta, v0), objective = y, lower =lb,
> upper =ub)
Error in dots[[1L]][[1L]] :
2010 Jan 14
1
Error: object of type 'closure' is not subsettable
Hi everyone,
Would somebody please explain (or point me to a reference that explains)
the following error:
"Error: object of type 'closure' is not subsettable"
I was trying to use rep() to replicate a function:
> example_function <- function() { return(TRUE) }
> rep(example_function, 3)
Error: object of type 'closure' is not subsettable
But I just cannot
2012 Feb 15
5
Abrir multiples archivos
Hola,
Alguien podría ayudarme en la siguiente cuestión:
Trato de abrir múltiples archivos ncDF para dejarlos disponibles para
trabajar luego con ellos. Intento hacerlo con un blucle pero no
consigo lo que quiero. El código es el siguiente:
setwd("/Users/jaime/Desktop/2008")
a<-list.files()
a
library(ncdf)
for (i in 1:length(a)) {
2019 Mar 02
1
stopifnot
A private reply by Martin made me realize that I was wrong about
stopifnot(exprs=TRUE) .
It actually works fine. I apologize. What I tried and was failed was
stopifnot(exprs=T) .
Error in exprs[[1]] : object of type 'symbol' is not subsettable
The shortcut
assert <- function(exprs) stopifnot(exprs = exprs)
mentioned in "Warning" section of the documentation similarly fails
2018 Aug 09
3
WishList: Remove Generic Arguments
I apologize if this issue has been raised before.
I really like object oriented S3 programming.
However, there's one feature of object oriented S3 programming that I don't
like.
Generic functions can have arguments other than dots.
Lets say you have an R package with something like:
print.myfunction (f, ...)
{ dosomething (f, ...)
}
Noting that I use function objects a lot.
R CMD
2012 Oct 16
3
Excluding all teh columns from a data frame if the standard deviation of that column is zero(0).
Hi All,
I have a data frame where nearly 10K columns of data, where most of them
have standard deviation( of all rows) as zero.
I want to exclude all the columns from the data frame and proceed to further
processing.
I tried like blow.
*data <- read.csv("data.CSV", header=T)
for(i in 2:ncol(data))
if(sd(data[,i])==0){
df[,i] <-NULL
}
*
where I have the data columns from
2019 Nov 12
2
class(<matrix>) |--> c("matrix", "arrary") [was "head.matrix ..."]
<polite mode>
> x %inherits% "data.frame"
IMHO, I think that user-defined binary operators are being over-used
within the R community.
I don't think that they're "cute" or stylish.
I think their use should be limited to cases, where they significantly
increase the readability of the code.
However, readability, is a (partly) subjective topic...
2019 Nov 12
1
class(<matrix>) |--> c("matrix", "arrary") [was "head.matrix ..."]
> You can have your own rant about "user-defined binary operators being
> over-used within the R community" without suggesting that my rant was
> rude.
I wasn't suggesting that you were rude.
I was questioning a trend.
2017 Jul 24
5
Ifelse statements and combining columns
Hi everyone,
I'm having some trouble with my ifelse statements.
I'm trying to put 12 conditions within 3 groups. Here is the code I have so
far:
dat$cond <- ifelse(test = dat$cond == "cond1" | dat$cond == "cond2" |
dat$cond == "cond3" dat$cond == "cond4"
yes = "Uniform"
no = ifelse(test =