similar to: is.na() can coerce character vectors to be factors within a dataframe

Displaying 20 results from an estimated 10000 matches similar to: "is.na() can coerce character vectors to be factors within a dataframe"

2002 May 29
1
merge.data.frame can coerce character vectors to factor in some circumstances (PR#1608)
If the following two conditions are met: 1) all.x is TRUE 2) at least 1 row in y does not have a match in x then any character vectors in y will be coerced to be factors. Here is a simple example (previously provided on r-devel): > x <- data.frame(a = 1:4) > y <- data.frame(b = LETTERS[1:3]) > y$b <- as.character(y$b) > z <- merge(x, y, by = 0, all.x = TRUE) > z
2002 May 20
1
(PR#1577) is.na<- coerces character vectors to be factors
The inconsistency is that you use $<- to set the column, then [[<- to change it. Had you tried to set the column by x[[1]] <- as.character(x[[1]]) you would have seen the problem immediately (it does not work as you would have intended). If you want to be sure to turn off conversion to factor, you need to set the column to class "AsIs". My belief is that will behave
2002 May 20
0
is.na<- coerces character vectors to be factors within dataframes (PR#1577)
I am not sure if this is a bug within is.na<- or if it lies deeper in the dataframe construction process. Indeed, perhaps it is not a bug at all (in which case I would suggest that the help page for NA be provided with a warning for unsuspecting users (like me)). When used on a character vector within a dataframe, is.na<- coerces the vector to factor. > x <- data.frame(var =
2012 Jan 15
0
patching ?merge to allow the user to keep the order of one of the two data.frame objects merged
Hello dear R-devel list members. Following an old (2002) thread from R-help (and having myself needing to solve the same question): https://stat.ethz.ch/pipermail/r-help/2002-October/026249.html I patched the {base} function "merge.data.frame" to have it work with a new parameter called "keep_order", and I hope you might consider including this patch (or some variation of it)
2002 May 14
0
FW: Summary of Suggestions for poor man's parallel processing
It turns out that my web host doesn't allow direct links. Try going to http://www.warnes.net/downloads or getting it from the sourceforge snippet library https://sourceforge.net/snippet/detail.php?type=snippet&id=101149. -Greg > -----Original Message----- > From: Warnes, Gregory R [mailto:gregory_r_warnes at groton.pfizer.com] > Sent: Monday, May 13, 2002 10:15 AM > To:
2001 Nov 13
1
modification time warning with R CMD check
I often get warnings like the following when running R CMD check [...] * checking for code/documentation mismatches ... OK * checking tests ... make: *** Warning: File `Makevars' has modification time in the future (2001-11-13 12:54:37.381546042 > 2001-11-13 12:54:37.314975985) [...] I am ready to believe that this is not a bug (i.e., that the timing on my various machines and file
2001 Oct 04
1
Strange behavior with saved character vectors containing a slash
I am seeing some strange behavior using save on a character vector containing a slash. If this is a bug, I will happily submit it (as a single entry! ;-) ) to r-bugs. Here is an example involving "VIA\B". > version _ platform sparc-sun-solaris2.6 arch sparc os solaris2.6 system sparc, solaris2.6 status
2002 Oct 18
0
Correct placement of .tex files in an R package
I have a package in which I would like to store a LaTeX .tex file. It is not documentation on any particular function, but is related to the package. In thought that I could just create a "doc" directory under the "inst" subdirectory and place it there. I thought that things in "inst" were just recursively copied when the package was installed. Alas, when I check the
2003 Jan 23
0
Summary: Warnings with no INDEX file in a package
Thanks to Henrik Bengtsson, Martin Maechler, Brian Ripley, Jeff Gentry and David Brahm for taking the time to answer my questions about INDEX files in R packages. My key take-aways were: 1) All of this will be changing a lot in R 1.7.0-to-be, so don't sweat the details. 2) Many people run R CMD build before they run R CMD check. I found this quite surprising. I did not realize that R
2002 Apr 08
2
subsetting with NA's
Hi, I often have large dataframes with many variables and many NA's, from which I would like to subset out some rows. Here is a toy example: > x <- data.frame(a = c("x", "y", "z"), b = c(1, NA, 5)) > x a b 1 x 1 2 y NA 3 z 5 I realize that, if I know the values in x$b that I want to subset, things are easy: > x[x$b %in% c(1),] a b 1 x 1
2003 Jan 09
2
Warnings with no INDEX file in a package.
In previous versions of R (at least in 1.5.1, I think), my practice was not to include an INDEX file in the package. R CMD check did not complain and an INDEX was created for me when I use R CMD build. At least, this is how I remember it. I thought that this was a good way to behave since it ensured that my INDEX was automatically kept up to date by R, without me having to worry about what
2001 Sep 28
1
Summary of Characters vectors, NA's and "" in merges
Thanks to Brian Ripley, Gregory Warnes, and Dennis Murphy for considering my problem about "NA" in character strings. The nub of the issue seems to be that you can not have a string with "NA" in it in a character vector in R without it being intrepreted as meaning NA (i.e., not available). The only work-arounds involve renames of various sorts. Perhaps this is more appropriate
2007 Apr 20
0
Fwd: Re: Character coerced to factor and I cannot get it back
--- John Kane <jrkrideau at yahoo.ca> wrote: > Date: Fri, 20 Apr 2007 10:47:45 -0400 (EDT) > From: John Kane <jrkrideau at yahoo.ca> > Subject: Re: [R] Character coerced to factor and I > cannot get it back > To: jim holtman <jholtman at gmail.com> > > Thanks Jim, > > I can live with it as a factor or I will do as you > suggest. What is bothering
2002 Apr 30
2
display of character NA's in a dataframe in 1.5.0
I understand that NA's in character vectors are displayed differently than NA's in factor vectors. > c("x", NA, "y") [1] "x" NA "y" > as.factor(c("x", NA, "y")) [1] x <NA> y Levels: x y That seems sensible enough. But shouldn't I see the same behavior in a dataframe? > test <- data.frame(a =
2002 Apr 30
3
rbind'ing empty rows in dataframes in 1.4.1 versus 1.5.0
Hi, In 1.4.1, I was able to create extra "empty" rows in a dataframe as so: > x <- data.frame(a = letters[1:3], b = 1:3) > x a b 1 a 1 2 b 2 3 c 3 > x[4,] a b NA NA NA > rbind(x, x[4,]) a b 1 a 1 2 b 2 3 c 3 NA NA NA > R.version _ platform sparc-sun-solaris2.6 arch sparc os solaris2.6
2007 Apr 19
0
Fwd: RE: Character coerced to factor and I cannot get it back
--- John Kane <jrkrideau at yahoo.ca> wrote: > Date: Thu, 19 Apr 2007 15:50:36 -0400 (EDT) > From: John Kane <jrkrideau at yahoo.ca> > Subject: RE: [R] Character coerced to factor and I > cannot get it back > To: Jorge Cornejo-Donoso <jorgecornejo at uach.cl> > > > --- Jorge Cornejo-Donoso <jorgecornejo at uach.cl> > wrote: > > >
2001 Nov 29
3
package argument to library as string
The help page for library says that: package, help: name or character string giving the name of a package. Yet, I don't seem to be able to use a string variable here. > version _ platform sparc-sun-solaris2.6 arch sparc os solaris2.6 system sparc, solaris2.6 status major 1
2001 Jul 11
1
Summary of Forcing variables types when using read.table
Thanks to Martyn Plummer and Vele Samak for taking the time to answer my problem. scan certainly will do the trick. However, having taken a look at the code for read.table, it seems to me that I might be able to add in a "what" argument and then just pass it down to the call to scan. But that won't be today's project . . . Dave Kane
2002 Jan 15
2
1.4.1 release date
Has the likely release date for R 1.4.1 been set? Apologies if there is some obvious place on the web site that I could have looked this up at. We are eager to upgrade to 1.4, but some of the bugs matter to us. We have played around with the patched code, but have mainly succeeded in demonstrating that we need to learn more about UNIX code development . . . Thanks to all for a most excellent
2004 Sep 15
5
replacing NA's with 0 in a dataframe for specified columns
I know that there must be a cool way of doing this, but I can't think of it. Let's say I have an dataframe with NA's. > x <- data.frame(a = c(0,1,2,NA), b = c(0,NA,1,2), c = c(NA, 0, 1, 2)) > x a b c 1 0 0 NA 2 1 NA 0 3 2 1 1 4 NA 2 2 > I know it is easy to replace all the NA's with zeroes. > x[is.na(x)] <- 0 > x a b c 1 0 0 0 2 1 0 0 3 2 1