similar to: Puzzled about a new method for "[".

Displaying 20 results from an estimated 10000 matches similar to: "Puzzled about a new method for "["."

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
2019 Nov 03
2
Puzzled about a new method for "[".
On 4/11/19 10:31 AM, Duncan Murdoch wrote: > On 03/11/2019 4:11 p.m., Rolf Turner wrote: >> >> I recently tried to write a new method for "[", to be applied to data >> frames, so that the object returned would retain (all) attributes of the >> columns, including attributes that my code had created. >> >> I thrashed around for quite a while, and
2019 Nov 04
0
Puzzled about a new method for "[".
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 class simply by restoring its attributes after subsetting. Hadley
2019 Nov 04
0
Puzzled about a new method for "[".
On 03/11/2019 6:43 p.m., Rolf Turner wrote: > > On 4/11/19 10:31 AM, Duncan Murdoch wrote: > >> On 03/11/2019 4:11 p.m., Rolf Turner wrote: >>> >>> I recently tried to write a new method for "[", to be applied to data >>> frames, so that the object returned would retain (all) attributes of the >>> columns, including attributes that my
2019 Nov 04
3
Puzzled about a new method for "[".
On 04/11/2019 4:40 p.m., Pages, Herve wrote: > Hi Rolf, > > On 11/4/19 12:28, Rolf Turner wrote: >> >> 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. >>>
2019 Nov 03
0
Puzzled about a new method for "[".
On 03/11/2019 4:11 p.m., Rolf Turner wrote: > > I recently tried to write a new method for "[", to be applied to data > frames, so that the object returned would retain (all) attributes of the > columns, including attributes that my code had created. > > I thrashed around for quite a while, and then got some help from Rui > Barradas who showed me how to do it, in
2019 Nov 05
1
Puzzled about a new method for "[".
You can try for testing with a column of class errors, from the package 'errors'. The attributes depend on the content in the way Hadley pointed out. I?aki El lun., 4 nov. 2019 23:19, Rolf Turner <r.turner at auckland.ac.nz> escribi?: > On 5/11/19 10:54 AM, Duncan Murdoch wrote: > > On 04/11/2019 4:40 p.m., Pages, Herve wrote: > >> Hi Rolf, > >> >
2002 Apr 11
2
Obtaining names of ``...'' arguments.
This may be an FAQ, but a (perfunctory) search failed to turn it up. Suppose I have a function foo(...){<something>} and I want to obtain, inside foo, the names of items comprising the ``...''. E.g. if I call foo(melvin,clyde,irving) I want to be able to loop through the ``...'' and successively obtain the text strings "melvin", "clyde", and
2019 Nov 04
0
Puzzled about a new method for "[".
On 5/11/19 10:54 AM, Duncan Murdoch wrote: > On 04/11/2019 4:40 p.m., Pages, Herve wrote: >> Hi Rolf, >> >> On 11/4/19 12:28, Rolf Turner wrote: >>> >>> 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
2019 Jul 07
3
Possible bug in `class<-` when a class-specific '[[.' method is defined
Hi all ! I noticed a strange behaviour of the function `class<-` when a class-specific '[[.' method is defined. Here below a reproducible example : #-------------------------------------------------------------------. counttt <- 0 `[[.MYCLASS` = function(x, ...) { counttt <<- counttt + 1 # browser() x = NextMethod() return(x) } df <- as.data.frame(matrix(1:20,
2008 Aug 07
3
how to save an R object selectively?
Hi, How to save an R object for example a matrix or vector and not all objects created in a session (which is usually performed by save.image or q("yes"))? Best, Carol [[alternative HTML version deleted]]
2007 Feb 19
1
Documenting options specific to a package.
If one specifies new options in a package, using the options() function, where does/should one document these new options? E.g. suppose that I put the line options(melvin=42) in a file zzz.R in the R directory of the package source, where the package contains functions foo(), bar(), clyde(), and irving() which all query options("melvin") and take some action based on the value of
2007 Oct 04
5
A rebel boxplot question
Dear R list members I am trying to improve a boxplot with 2 data sets. I run somethinkg like boxplot(data1 ~ month, add=F, col = "red", ...) boxplot(data2 ~ month, add=T, col = "blue", ...) The problem is that the data from February are missing for data2, so R think that must take little more space between the data classes in data 2 and then both data gropus are not aligned.
2019 Jul 15
4
Possible bug in `class<-` when a class-specific '[[.' method is defined
Hello, Clean R 3.6.1 session on Ubuntu 19.04, RStudio 1.1.453. sessionInfo() at the end. I can reproduce this. counttt <- 0 `[[.MYCLASS` = function(x, ...) { counttt <<- counttt + 1 # browser() x = NextMethod() return(x) } df <- as.data.frame(matrix(1:20, nrow=5)) class(df) <- c("MYCLASS","data.frame") counttt #[1] 9 But there's more. I
2011 Jul 19
1
"may be used in an incorrect context"
R CMD check tells me * checking R code for possible problems ... NOTE agexact.fit.rds: ... may be used in an incorrect context: ?optim(init, agfitfn, ...)? Warning: <anonymous>: ... may be used in an incorrect context: ?optim(init, agfitfn, ...)? Can anyone tell me what this message means? My searches haven't turned up anything useful. This is with R 2.7 and 2.9. The message
2007 Dec 17
1
polygon class in splancs package
Dear forum, I would like to use the kernel2d or spkernel2d in the Splancs-package, but it does not recognize my polygon data. "Error in kernel2d(as.points(ptsbin), polygonprov, h0 = 2, nx = 100, : " is the error message. Invalid poly argument The data are defined as follows: polgonprov<-list(x=polyprov$X, y=polyprov$Y) with X and Y coordinates in the Lambert1972
2004 Jul 16
4
Stumped on methods
I have been trying to write a "proper" print method for a package, and have almost gotten what I want. From a reading of the relevant section in R Extensions and the introduction to methods, I've stuck the whole business into a character object and used: NextMethod("print") However, instead of not printing quotes and displaying the usual representation of the string,
2003 Oct 02
1
"[[<-","[[" default?
Hi! I have implemented class specific behaviour of "[[<-.myclass"<-function(). How it is posible to call the "[[.default" on an object of myclass? Eryk Dipl. bio-chem. Eryk Witold Wolski @ MPI-MG Dep. Vertebrate Genomics Ihnestrasse 73 14195 Berlin 'v' tel: 0049-30-84131285 / \ mail: wolski@molgen.mpg.de ---W-W----
2006 Apr 13
4
Creating an environment for a function.
I am trying to build a function in a context where the environment concept would appear to be useful. But I'm a bit foggy about this concept and would appreciate some pointers and advice. Basically the function I'm building, say foo(x,t), is a function of two variables). Depending on the value of t, foo will return one of the values f1(x), f2(x), ..., fk(x), where each of f1, ..., fk is
2004 Jul 12
1
Nested source()s
I had an error message while running a macro from Yudi Pawitan's web site: > source("ex2-13.r") Error in parse(file, n, text, prompt) : syntax error on line 2 Inspecting ex2-13.r I found that the error was generated by another source() command. Clearly R does not like nested source()s, which is fair enough when you think about it. Still it's something that you might want