similar to: Odd outcome of attr with environments (PR#2148)

Displaying 20 results from an estimated 20000 matches similar to: "Odd outcome of attr with environments (PR#2148)"

2001 Apr 11
5
replicating lists
Hi Everyone, At the moment it is not possible to replicate complex lists, but only simple ones: > rep(list(fred = 1:10), 10) # works fine > rep(list(fred = 1:10, happy = "squash"), 10) Error in rep(list(fred = 1:10, happy = "squash"), 10) : Unimplemented feature in rep There is nothing in ?rep that suggests that the latter should not work, and I think it would
2000 Mar 22
3
segmentation fault with 1D array (PR#500)
Here's a nasty one. The following has caused a segmentation fault and possibly also a bus error. fred <- 1:6 dim(fred) <- 6 dimnames(fred) <- list(LETTERS[1:6]) mm <- matrix(1:12, 2, 6) mm %*% fred # segmentation fault here In the case without the dimnames assignment the result is OK. Cheers, Jonathan. --please do not edit the information below-- Version: platform =
2002 Jan 04
2
Problem with "missing" in "local" (PR#1241)
Hi everyone, I encountered unexpected behaviour when calling "missing" within a "local" environment, namely fred <- function(x, y) { x <- as.vector(x) local({ dontwantme <- 1:100 if (missing(y)) print("No \"y\" today") }) x } whereupon I get > fred(1:10) Error in eval(expr, envir, enclos) : "missing" illegal use of
2002 Nov 22
4
Small change to plot.xy
Hi everyone, Is there any reason why we should not automatically coerce a factor supplied as an argument to col in a plotting function? The following modification (to R-1.6.1) seems pretty harmless > plot.xy function (xy, type, pch = 1, lty = "solid", col = par("fg"), bg = NA, cex = 1, ...) { if (is.factor(col)) col <- codes(col)
2000 Feb 01
2
Segmentation fault in recursion, 0.90.1 (PR#409)
The following gives an immediate segmentation fault, v 0.90.1 "fred" <- function(x) { print(x); Recall(x-1)} fred(0) # segmentation fault at recursion 831 Obviously this recursion is non-terminating, but shouldn't it be caught and reported at some limit? In 0.64.1 we had Error: protect(): stack overflow at recursion 831. Cheers, Jonathan. Jonathan Rougier
2000 May 19
7
variance of a scalar (PR#546)
I was surprised to find that the variance of a scalar, using var(), is NA. Surely this should be zero? Cheers, Jonathan. --please do not edit the information below-- Version: platform = sparc-sun-solaris2.7 arch = sparc os = solaris2.7 system = sparc, solaris2.7 status = Patched major = 0 minor = 99.0 year = 2000 month = February day = 9 language = R Search Path: .GlobalEnv,
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 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 +
2002 Aug 20
1
NA and help page for "&" and "|"
Hi everyone, Can I suggest an addition to the help page for logical AND and OR, indicating the behaviour of NA (which is currently not mentioned at all). I think something simple like an extra paragraph in Details, eg \code{NA} is a valid logical object. Where a component of \code{x} or \code{y} is \code{NA}, the result will be \code{NA} if the outcome is ambiguous. In other words \code{NA
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)
2001 Jan 09
3
Inconsistent behaviour in solve (PR#805)
I find this a bit puzzling ... > solve(matrix(c(5, 2, 3, 1), 2, 2), c(Inf, 3)) [1] NaN Inf > solve(matrix(c(5, 2, 3, 1), 2, 2)) %*% c(Inf, 3) [,1] [1,] -Inf [2,] Inf I would expect the answer to be c(-Inf, Inf), so why has the -Inf been replaced by NaN in solve? Cheers, Jonathan. --please do not edit the information below-- Version: platform = sparc-sun-solaris2.7 arch = sparc
2000 Oct 16
2
print problem with data frames (PR#698)
Another one from the student computer practicals: it is possible to create a dataframe that cannot be printed. Thus > fred <- data.frame(happy=c(TRUE, FALSE, TRUE), sad=7:9) > tmp <- fred[c(FALSE, FALSE, TRUE, TRUE)] # no error message! > tmp Error in as.matrix.data.frame(x) : dim<- length of dims do not match the length of object > print.default(tmp) $"NA" NULL
2002 Oct 08
3
hash argument of new.env()
Hi everyone, There is no mention in ?new.env (R-1.6.0) of what the effect of setting the hash argument of new.env() actually does. What does it mean in performance terms to say that "the environment will be hashed"? Thanks, Jonathan. -- Jonathan Rougier Science Laboratories Department of Mathematical Sciences South Road University of Durham
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 Feb 10
1
Function parsing (PR#118)
Is anyone else concerned with the way in which the R function parser relocates comments that occur after condional expressions in functions to before, i.e. fred <- function(x) { # wonder what x is like if (x>0) stop("Sorry non-positive x only") # that showed x big-time! x } but then fred is parsed and stored as "fred" <- function (x) { # wonder what x is
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
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
2000 Apr 06
2
Strange behaviour of image (PR#510)
The following commands z <- matrix(seq(0, 1, len=1000)) image(z, 1, z, zlim=c(0, 1), col=gray(1:10/10)) appear to violate the image functionality as described on the help page. As I understand it, by specifying a zlim of c(0, 1) and a colour vector of length 10, the colours should correspond to the intervals (0, 0.1), (0.1, 0.2), ..., (0.9, 1.0), this being 10 equally-spaced intervals on (0,
1999 Mar 10
2
.Alias and memory
In an effort to encapsulate my dependence on class in order to deal with oldclass/class in Splus I defined the functions tfclass <- class "tfclass<-" <- function(x, value){ class(x) <- value ; x } and also the function classed <- function(x, cls) {class(x) <- cls; x} This last allows me to end a function definition with ... classed(somecalc,