similar to: Function parsing (PR#118)

Displaying 20 results from an estimated 2000 matches similar to: "Function parsing (PR#118)"

1999 Aug 18
2
diag()
I would like to suggest a slight modification to diag(). In the case where x is a matrix with both row names and column names the same, it would be reasonable if the resulting vector also had those names. I often use diag() on variance matrices, where this modification is helpful. The modification requires replacing if (is.matrix(x) && nargs() == 1) return(c(x)[1 +
1999 Nov 04
2
New codes() methods
Hi Everyone, Can I suggest a couple of new `codes' methods. I know codes is a bit dodgy (at least, according to the comments in codes.factor), but for what it's worth I like to extract codes from data frames of factors, for which the following two functions (which operate recursively) are helpful: "codes.default" <- function(x) { if (is.list(x)) lapply(x, codes)
1999 Feb 17
1
dim enquiry
This is a minor question, but is there any difference between the two objects fred <- structure(1:10, dim = c(2,5)) and fred <- structure(1:10, .Dim = c(2,5)) Should I be using one rather than the other? Thanks, Jonathan. Jonathan Rougier Science Laboratories Department of Mathematical Sciences South Road University of Durham Durham DH1 3LE
1999 Jan 14
1
libraries
Am I right in thinking that there a discrepancy between the ?library documentation and the library() function? If I have a library called "patches", then according to the documentation (0.62.4) patches/R should contain source files like fred.R and george.R, but in practice the library only loads if both fred.R and george.R are given in a file called patches in the R subdirectory of
1999 Oct 08
1
dimnames and subscripting (PR#293)
I am not sure that this is a bug, but it was unexpected -- of course my expectations are fallible, eg column ordering in model.matrix()! When an array is subscripted the names of the dimnames list are lost (v 64.1). fred <- array(1:12, 2:4, list(A = letters[1:2], B = letters[3:5], C = letters[6:9])) dimnames(fred) dimnames(fred[1, , ]) dimnames(fred[1, , , drop=FALSE]) In the first
1999 Oct 26
1
dodgy list operation (PR#298)
I can generate a segmentation fault as follows, where I would expect a syntax error: fred <- as.list(1:10) lapply(fred, "[[") platform sparc-sun-solaris2.5.1 arch sparc os solaris2.5.1 system sparc, solaris2.5.1 status status.rev 0 major 0 minor 64.1
2000 Jan 04
2
set functions
I wonder if we might also include an "equiv" function along with the other set functions (ie "union", "intersect", etc), perhaps along the lines of "equiv" <- function(x, y) all(c(match(x, y, 0)>0, match(y, x, 0)>0)) (which I think might be the quickest implementation). I use this type of function quite frequently: is there some reason why it is
2000 Jan 04
2
set functions
I wonder if we might also include an "equiv" function along with the other set functions (ie "union", "intersect", etc), perhaps along the lines of "equiv" <- function(x, y) all(c(match(x, y, 0)>0, match(y, x, 0)>0)) (which I think might be the quickest implementation). I use this type of function quite frequently: is there some reason why it is
1999 Apr 30
1
legend()
In legend() is it possibly to mix lines and boxes? I would like to do something like legend(locator(1), legend = c("al", "ben", "chris", "dave"), lty = c(1, 2, 3, NA), fill = c(NA, NA, NA, "gray")) to indicate that "al", "ben" and "chris" have lines, and "dave" has a gray shading. Many thanks,
1999 Aug 25
2
Error in ?text (PR#256)
Just a minor point, but the adj argument in ?text is described wrongly (0.64.1). Perhaps the following might be added to the details. Values of 0, 0.5, and 1 specify left/top, middle and right/bottom, respectively. The default is for centred text, ie \code{adj = c(0.5, 0.5)}. Cheers, Jonathan. Jonathan Rougier Science Laboratories Department of
1999 Sep 27
2
chol() dimnames
Hi Everyone, Just a minor point, but could chol() be changed to include the dimnames of the original matrix? This will ensure that x and t(R) %*% R have the same dimnames, where R <- chol(x). So we just need to insert if (!is.null(dx <- dimnames(x))) dimnames(z$v) <- dx ahead of the return. Cheers, Jonathan. Jonathan Rougier Science Laboratories
1999 Jan 08
0
Function suggestion
I hope this is the right forum (it'll be second time lucky if it is!). I note in the current distribution that functions passed as arguments (eg to outer, sweep and the applys) are not handled consistently. As I often pass functions myself, I find the following simple function useful ... match.fun <- function (FUN, descend = F) { if (is.character(FUN)) get(FUN,
1999 Mar 22
0
Extension to outer()
This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. Send mail to mime@docserver.cac.washington.edu for more info. ---559023410-1804928587-922106403=:691 Content-Type: TEXT/PLAIN; charset=US-ASCII A couple of weeks ago I asked if anyone had generalised outer to include bound extents -- effectively
1999 Jun 17
0
save.image()
Would it be reasonable to suggest adding an `all' flag to save.image(), i.e. "save.image" <- function (f = ".RData", all.names = F) eval(substitute(save(list = ls(all.names = all.names), file = f)), .GlobalEnv) I only ask because I keep losing my .First() function. I would like to start R in a particular directory and have it configure according to the First()
1999 Dec 22
0
Apply dimnames (PR#385)
This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. Send mail to mime@docserver.cac.washington.edu for more info. ---559023410-1251336619-945861747=:5357 Content-Type: TEXT/PLAIN; charset=US-ASCII While fiddling with apply I noticed that there appears to be an error in the dimnames, which actually
1999 Jan 20
2
dist function suggestion
This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. Send mail to mime@docserver.cac.washington.edu for more info. ---559023410-162216788-916833047=:29339 Content-Type: TEXT/PLAIN; charset=US-ASCII On my R installation (0.62.4) there is no dist() function, so I attach one possibility. It provides
1999 Nov 13
1
image()
May I raise the issue of the behaviour of image()? In image() dim(z) is supposed to be c(length(x), length(y)). This suggests that the user is supplying the midpoints of the rectangles. For all but the outer rectangles this is true. The outer rectangles, however, are only displayed in half width. So it is not possible to show correctly an image plot of equally-spaced abscissa. I would hazard
1999 Jan 15
1
Some outer() suggestions
This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. Send mail to mime@docserver.cac.washington.edu for more info. ---559023410-342241519-916419809=:25543 Content-Type: TEXT/PLAIN; CHARSET=US-ASCII Content-ID: <Pine.GSO.3.96.990115171305.25543M@laplace> I attach outer.tar.gz which contains
1999 Sep 22
1
model.matrix() (PR#285)
I was alarmed to discover that model.matrix.default() can permute columns with respect to the formula. This seems to happen with user-defined components of the formula. Thus X <- matrix(1:4, 1, 4, dimnames = list(NULL, LETTERS[1:4])) Q <- function(x) x^2 # because model.matrix() does not like, eg, A:A model.matrix(~ -1 + A + A:B + Q(C), data.frame(X)) has columns ordered A, Q(C), and
1999 Mar 02
1
zero-offset matrices
Has anyone written subscripting methods for matrices which are indexed from zero? i.e. functions such as "[.zoffset" and "[<-.zoffset" which would allow, given an appropriate function "zmatrix" "zmatrix" <- function(...) { robj <- matrix(...) class(robj) <- "zoffset" robj } fred <- zmatrix(1:20, 4, 5) fred[0, 4] # would be 17