similar to: as.character.factor when the factor contains "NA"

Displaying 20 results from an estimated 10000 matches similar to: "as.character.factor when the factor contains "NA""

2006 Jul 11
2
Dropping unused levels of a factor that has "NA" as a level
Is this a bug? > f1 <- factor(c("a", NA), levels = c("a", "NA") ) > f2 <- f1[, drop = TRUE] > f2 [1] a <NA> Levels: a <NA> I would have expected f2 to have only one level, "a". It seems to me that the code in [.factor does not follow the advice in help("factor") on how to set factor codes to be
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
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 =
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
2006 Apr 14
5
vector-factor operation
I found myself wanting to average a vector [vec] within each level of a factor [Fac], returning a vector of the same length as vec. After a while I realised that lm1 <- lm(vec ~ Fac) fitted(lm1) did what I want. But there must be another way to do this, and it would be good to be able to apply other functions than mean() in this way. Cheers, Murray -- Dr Murray Jorgensen
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
2006 Oct 17
1
Error: STRING_ELT() can only be applied to a 'character vector', not a 'builtin'
I have a daily job that attaches hundreds of pseudo-packages containing data as promise objects (DDP's, ref: g.data package), and plots the results to a multi-page pdf device. Sometimes it fails. Under R-2.2.1 it just gave segfaults. Under R-2.3.1 it gave this error message: *** caught segfault *** address (nil), cause 'memory not mapped' Traceback: 1:
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
2002 Mar 15
0
NA in character vectors
Hi all, While R-1.5.0 is still unfrozen, I'd like to try again to generate interest in my favorite pet peeve: NA's in character vectors. Last October I wrote: > LETTERS[c(NA,2)] in S is c("","B"), but in R is c("NA","B"). We had an interesting discussion then, and I learned (from Duncan Murdoch and Thomas Lumley) that R does have an internal
2002 Oct 15
1
cut() on NA gives 0 when labels=F
Hi all, I just noticed this odd behavior in R 1.5.1 (on Solaris 2.6): R> cut(c(2,NA), 1:5, labels=F) [1] 1 0 Is it a bug? I would have expected "1 NA" (better for indexing), and also the S-Plus analog is: S-Plus> as.integer(cut(c(2,NA), 1:5)) [1] 1 NA Apologies ahead of time if it's already fixed in R 1.6.0 and/or already known (perhaps related to
2006 Feb 13
2
?bug? strange factors produced by chron
Hallo all Please help me. I am lost and do not know what is the problem. I have a factor called kvartaly. > attributes(kvartaly) $levels [1] "1Q.04" "2Q.04" "3Q.04" "4Q.04" "1Q.05" "2Q.05" "3Q.05" "4Q.05" $class [1] "factor" > mode(kvartaly) [1] "numeric" > str(kvartaly) Factor w/ 8
2006 Aug 24
2
my error with augPred
Dear all I try to refine my nlme models and with partial success. The model is refined and fitted (using Pinheiro/Bates book as a tutorial) but when I try to plot plot(augPred(fit4)) I obtain Error in predict.nlme(object, value[1:(nrow(value)/nL), , drop = FALSE], : Levels (0,3.5],(3.5,5],(5,7],(7,Inf] not allowed for vykon.fac > Is it due to the fact that I have unbalanced
2004 Feb 03
5
creating a factor
Hi list, I'd like to make a factor with seven 1s and three 2s using the factor() function. That is, 1 1 1 1 1 1 1 2 2 2 I will then bind this factor to the matrix below using cbind.data.frame(). 0.56 0.48 0.22 0.59 0.32 0.64 0.26 0.60 0.25 0.38 0.24 0.45 0.56 0.67 0.78 0.97 0.87 0.79 0.82 0.85 I am new to R and have been using various manuals and have made many attempts without
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 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) <-
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
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)
2002 Apr 10
5
Funny characters in x11 window title (PR#1451)
In R-1.5.0pre (2002-04-08) on Solaris 2.6, the window that X11() creates has a title like: R Graphics: Device 2 (ACTIVE) o iyeP )( y except the funny characters at the end have umlauts and other accents (i.e. extended ASCII characters), and they may be different each time X11() is invoked. There is no loss of functionality; it just looks a little ugly. I saw this behavior in R-1.3.?, it
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)