Displaying 20 results from an estimated 40000 matches similar to: "cut() on NA gives 0 when labels=F"
2002 Feb 20
1
Bug in "[<-.matrix"? (Was: Feature Request: "matrix[1:10,1:10, block=F] <- 1:10")
Thanks to David Meyer [david.meyer@ci.tuwien.ac.at] and David Brahm
[brahm@alum.mit.edu] who suggested:
m[ cbind(index.i, index.j) ] <- vals
This works fine for the example I gave.
Unfortunately, this approach doesn't extend to using the row and column
names to make assignments:
> m <- matrix("",ncol=3,nrow=3)
> dimnames(m) <-
2002 Aug 13
2
Misalignment of <NA> in rownames (PR#1905)
An NA in the rownames of a matrix (or dataframe) causes misalignment when the
matrix is printed:
R> x <- matrix(1:12, 3,4, dimnames=list(letters[1:3], LETTERS[1:4]))
R> rownames(x)[2] <- NA
R> x
A B C D
a 1 4 7 10
<NA> 2 5 8 11
c 3 6 9 12
The bug is in function Rstrlen, in src/main/printutils.c. MatrixRowLabel and
MatrixColumnLabel (same file) rely on Rstrlen
2006 Apr 28
1
as.character.factor when the factor contains "NA"
as.character.factor contains this line (where cx=levels(x)[x]):
if ("NA" %in% levels(x)) cx[is.na(x)] <- "<NA>"
Is it possible that this is no longer the desired behavior? These
two results don't seem very consistent:
> as.character(as.factor(c("AB", "CD", NA)))
[1] "AB" "CD" NA
> is.na(.Last.value)[3]
[1] TRUE
2002 Aug 15
1
order(1, na.last=NA) fails (PR#1913)
R> order(1, na.last=NA)
Error in apply(sapply(z, is.na), 1, any) :
dim(X) must have a positive length
This bug appears unrelated to PR#1906, and so the fix of 8/15 doesn't help.
It comes from the line inside order():
ok <- !apply(sapply(z, is.na), 1, any)
where z=list(1) in my example. sapply() returns a single-element vector, not a
matrix, making apply() unhappy. This might
2001 Oct 04
2
Characters subsetted with NA (was: Several R vs S-Plus issues)
Hello, R-devel!
I posted to R-help, and (inappropriately) to R-bugs, this R/S-Plus difference:
> LETTERS[c(NA,2)] in S is c("","B"), but in R is c("NA","B")
Kurt Hornik <Kurt.Hornik@ci.tuwien.ac.at> wrote:
> I think we do not want to change this. ...
> R> is.na(LETTERS[c(NA,2)])
[1] TRUE FALSE
> so we really have NA but it is
2002 Aug 01
4
What does persp() return?
I want to plot some 3D points on top of the grid produced by persp().
On 2/22/01, Paul Murrell <paul at stat.auckland.ac.nz> wrote in R-help:
> In S-Plus, persp() returns a value that can be used to transform 3D
> locations to 2D, but this sort of thing is not (yet) available in R.
But persp() does return something (in R-1.5.1): a 4x4 matrix which in the C
code is called the
2002 May 13
1
prettyNum inserts leading commas (PR#1548)
Under R-1.5.0 on Solaris 2.6:
R> prettyNum(123456789, big.mark=",")
[1] ",123,456,789"
and that bad behavior (leading comma) spills into formatC as well:
R> formatC(123456789, digits=0, format="f", big.mark=",")
[1] ",123,456,789"
Looks to me like a bug in src/library/base/R/format.R, in function prettyNum:
B.[i.big] <-
2006 Jan 06
2
sudoku
Any doubts about R's big-league status should be put to rest, now that
we have a
Sudoku Puzzle Solver. Take that, SAS! See package "sudoku" on CRAN.
The package could really use a puzzle generator -- contributors are
welcome!
-- David Brahm (brahm at alum.mit.edu)
[[alternative HTML version deleted]]
_______________________________________________
R-packages mailing list
2006 Jan 06
2
sudoku
Any doubts about R's big-league status should be put to rest, now that
we have a
Sudoku Puzzle Solver. Take that, SAS! See package "sudoku" on CRAN.
The package could really use a puzzle generator -- contributors are
welcome!
-- David Brahm (brahm at alum.mit.edu)
[[alternative HTML version deleted]]
_______________________________________________
R-packages mailing list
2005 Jul 06
2
Graphics: calling par(mar) after frame()
The following code produces 6 plots on a page, but the first is
distorted and different from the others:
par(mfrow=c(3,2), las=2)
for (i in 1:6) {
frame()
par(mar=c(7, 7, 1, 1))
axis(2); box(); abline(h=seq(0,1,.5), col=2:4)
}
The first plot's axes are mis-aligned with the plotting area implied
by the box. It seems to be a result of calling par(mar) after frame().
Is this expected
2002 Jan 07
1
Is r-announce alive?
I sent a message to <r-announce at stat.math.ethz.ch> last Thursday ("New package:
colSums"), and still haven't seen it echoed on r-help or on the web archive (in
fact there is no r-announce web archive for 2002). Is something broken? Did I
need to use <r-announce at lists.R-project.org> instead?
--
-- David Brahm (brahm at alum.mit.edu)
2004 Dec 22
2
outer(-x, x, pmin) cannot allocate
R> x <- 0. + 1:8000
R> y <- outer(-x, x, pmin)
Error: cannot allocate vector of size 1000000 Kb
Why does R need to allocate a gigabyte to create an 8000 x 8000 matrix?
It doesn't have any trouble with outer(-x, x, "+"). Thanks.
-- David Brahm (brahm at alum.mit.edu)
Version:
platform = i686-pc-linux-gnu
arch = i686
os = linux-gnu
system = i686, linux-gnu
status =
2006 Aug 18
2
Floating point imprecision in sum() under R-2.3.1?
After upgrading to R-2.3.1 on Linux Redhat, I was suprised by this:
R> x <- c(721.077, 592.291, 372.208, 381.182)
R> sum(x) - 2066.758
[1] 4.547474e-13
Now I understand that floating point arithmetic is not precise, but
1) the result is exactly 0 in R-2.2.1 (patched) on the same machine,
2) .Machine$double.eps = 2.2e-16, so the error seems quite large.
Also note I get the same
2005 Sep 02
2
Superassignment (<<-) and indexing
In a clean environment under R-2.1.0 on Linux:
> x <- 1:5
> x[3] <<- 9
Error: Object "x" not found
Isn't that odd? (Note x <<- 9 works just fine.)
Why am I doing this? Because I'm stepping through code that
normally lives inside a function, where "<<-" is appropriate.
-- David Brahm (brahm at alum.mit.edu)
2003 Oct 22
3
Subsetted 1-D arrays (PR#4110)
In R-patched_2003-10-20, subsetted 1-D arrays no longer get converted to
vectors. The NEWS file documents this change, as an indirect result of bug
report 4110. I just wanted to mention this can break code in some rather
obscure ways, such as this toy example:
R> x <- sort(tapply(1:8, rep(1:4,2), sum)) # Was vector, now is 1D array
R> y <- matrix(1:4, 1,4) #
2006 Jan 06
1
Daylight Savings Time unknown in R-2.2.1
Under R-2.2.1, a POSIXlt date created with "strptime" has an unknown
Daylight Savings Time flag:
> strptime(20051208, "%Y%m%d")$isdst
[1] -1
This is true on both Linux (details below) and Windows. It did not
occur under R-2.1.0. Any ideas? TIA!
> Sys.getenv("TZ")
TZ
""
Version:
platform = i686-pc-linux-gnu
arch = i686
os = linux-gnu
2001 Dec 10
1
Documentation of .Last.lib in library() (PR#1209)
help(library) says: "`.Last.lib' is called when a package is loaded." Probably
should be "...is detached."
-- David Brahm (brahm@alum.mit.edu)
--please do not edit the information below--
Version:
platform = sparc-sun-solaris2.6
arch = sparc
os = solaris2.6
system = sparc, solaris2.6
status =
major = 1
minor = 3.1
year = 2001
2003 Aug 13
2
rowsum() may return a vector instead of a matrix (PR#3737)
If all rows are in the same "group", rowsum() returns a vector instead of a
(1xN) matrix, contrary to documentation:
R> print(z <- rowsum(matrix(1:12, 3,4), rep("x",3)))
[1] 6 15 24 33
R> dim(z)
NULL
It worked correctly in version 1.4.0 but was broken by version 1.6.1. I'm
currently using 1.7.1 under Solaris 2.8.
--please do not edit the information
2002 Apr 03
1
predict.Arima fails when x is not a time-series
I'm playing with predict.Arima in the 3/19/02 development snapshot of R-devel.
The following produces an error message because x is not of class "ts":
R> x <- rnorm(20)
R> obj <- arima(x, c(2,0,0))
R> predict(obj)
Error in round(x, digits) : Non-numeric argument to mathematical function
Granted the documentation for arima says x should be a time-series, but
2005 May 19
2
Larger X11 fonts under R-2.1.0
I view plots on my screen with X11(width=.455*11, height=.455*8.5),
which creates a small window with the American standard aspect ratio.
Under R-2.0.1 and earlier, the default fonts were a reasonable size,
but under R-2.1.0 they are too big and fat. I now have to either set
pointsize=10 in X11(), or par(cex=.7) afterwards.
The NEWS file has this to say about X11 fonts:
The changes to font