similar to: ifelse drops classes

Displaying 20 results from an estimated 10000 matches similar to: "ifelse drops classes"

2007 Jun 05
4
Refactor all factors in a data frame
Hi all, Assume I have a data frame with numerical and factor variables that I got through merging various other data frames and subsetting the resulting data frame afterwards. The number levels of the factors seem to be the same as in the original data frames, probably because subset() calls [.factor without drop = TRUE (that's what I gather from scanning the mailing lists). I wonder if
2006 Jan 17
1
Font size of axis labels
Hi all, In R, it is not possible to set the font size of axis labels directly (AFAIK). Instead, scaling factors for the font chosen by the graphics device can be supplied. It appears that there is no constant font size for axis labels. My impression is that the axis label font size is scaled internally by R depending on the number of labels given for an axis. In addition to the R-internal
2008 Jan 27
1
tapply on empty data.frames (PR#10644)
Full_Name: Hilmar Berger Version: 2.4.1/2.6.2alpha OS: WinXP Submission from: (NULL) (84.185.128.110) Hi all, If I use tapply on an empty data.frame I get an error. I'm not quite sure if one can actually expect the function to return with a result. However, the error message suggests that this case does not get handled well. This happens both in R-2.4.1 and 2.6.2alpha (version 2008-01-26).
2008 Jan 02
2
strange behavior of cor() with pairwise.complete.obs
Hi all, I'm not quite sure if this is a feature or a bug or if I just fail to understand the documentation: If I use cor() with pairwise.complete.obs and method=pearson, the result is a scalar: ->cor(c(1,2,3),c(3,4,6),use="pairwise.complete.obs",method="pearson") [1] 0.9819805 The documentation says that " '"pairwise.complete.obs"' only
2006 Jun 04
2
evaluation of the alternative expression in ifelse
Dear all, I am trying to avoid the warnings produced by: > x <- -2:2 > log(x) [1] NaN NaN -Inf 0.0000000 0.6931472 Warning message: production de NaN in: log(x) I thought that using ifelse would be a solution, but it is not the case: > ifelse(test = x < 0, yes = NaN, no = log(x)) [1] NaN NaN -Inf 0.0000000 0.6931472 Warning message: production
2016 Nov 27
1
ifelse() woes ... can we agree on a ifelse2() ?
Related to the length of 'ifelse' result, I want to say that "example of different return modes" in ?ifelse led me to perceive a wrong thing in the past. ## example of different return modes: yes <- 1:3 no <- pi^(0:3) typeof(ifelse(NA, yes, no)) # logical typeof(ifelse(TRUE, yes, no)) # integer typeof(ifelse(FALSE, yes, no)) # double As
2010 Mar 10
1
ifelse logic and multiple assignments
I'm a fairly new R user and while I have a solution to my problem I'm wondering if there is a better one. In SAS it's common to use if/then logic along with a "do" statement to make several things happen. While I could do the same thing in R using a "for" loop, and "if" and {}, I've read that loops are less common in R and I wonder if I'm doing
2005 Jun 01
2
A suggestion to improve ifelse behaviour with vector yes/noarguments
> Thomas Lumley wrote: > > On Tue, 31 May 2005, Duncan Murdoch wrote: > > > > > >>M??kinen Jussi wrote: > >> > >>>Dear All, > >>> > >>>I luckily found the following feature (or problem) when tried to > >>>apply > >>>ifelse-function to an ordered data. > >>> > >>> >
2016 Nov 27
0
ifelse() woes ... can we agree on a ifelse2() ?
For S Ellison, just clarifying, I am Suharto Anggono, not Martin Maechler. "Martin et al.," from my previous E-mail was the beginning of message from Gabriel Becker, that I quoted. The quoted "still a bit disappointed that nobody has taken a look" is from Martin Maechler. In all of the proposed 'ifelse'-like functions so far, including from me (that I labeled as
2018 May 04
0
Proposed speedup of ifelse
Thanks Radford. I concur with all your points. I've attempted to address the issues you raised through the github.io post. The new method appears to be slower for test lengths < 100 and possibly longer lengths (not just < 10). Of course length(test) < 100 is very quick, so I simply added this to the conditions that cause the old ifelse method to be invoked. I'll leave it to
2016 Aug 06
0
ifelse() woes ... can we agree on a ifelse2() ?
On 06/08/2016 10:18 AM, Martin Maechler wrote: > Dear R-devel readers, > ( = people interested in the improvement and development of R). > > This is not the first time that this topic is raised. > and I am in now state to promise that anything will result from > this thread ... > > Still, I think the majority among us has agreed that > > 1) you should never use
2007 Dec 20
1
ifelse problem
Could someone help me with the following code snippet. The results are not what I expect: > Sheet1$Claims[1:10] [1] NA 1 2 NA NA NA NA NA NA NA > Sheet1[1:10,"SubmissionStatus"] [1] Declined Bound Bound Bound Bound Bound Declined Dead Declined [10] Not Taken Levels: Bound Dead Declined Not Taken > Sheet1$Claimsnum <- NA >
2009 Feb 13
0
Odp: Odp: extracting parts of words or extraxting letter to use in ifelse-func.
Hi johannes at dsr.life.ku.dk napsal dne 13.02.2009 13:17:06: > Hi > > I tried what you said, but i gives FALSE all the way down! And I think its > because there are other words in phrases as well. So if there is 'San' > in the phrase it has to be TRUE even thoug there are other words before and > after 'San' in the phrase. I do not understand. >
2017 Nov 04
1
ans[nas] <- NA in 'ifelse' (was: ifelse() woes ... can we agree on a ifelse2() ?)
Removal of ans[nas] <- NA from the code of function 'ifelse' in R is not committed (yet). Why? -------------------------------------------- On Mon, 28/11/16, Martin Maechler <maechler at stat.math.ethz.ch> wrote: Subject: Re: [Rd] ifelse() woes ... can we agree on a ifelse2() ? Cc: R-devel at r-project.org, maechler at stat.math.ethz.ch Date: Monday, 28 November, 2016, 10:00
2011 Jul 11
1
Ifelse statement
Hello everyone, I have a (small) issue. I already googled a lot, so I decided to use ifelse instead of if (){} else{} All the elements seem to work seperately, but combined in the ifelse statement, it doesn't seem to work. #The price function is a function which is normally distributed with only positive answers price<-function() {abs(rnorm(1,10,25))} #Before I use pieceprice in the
2010 May 26
1
More efficient way to use ifelse()? - A follow up
# Thanks again to everyone who provided suggestions. # I was curious about which approaches would be the fastest... so a little benchmarking # My approach was by far the worst :) # The approach suggested by Duncan Murdoch and Peter Langfelder, based on indexing , was by far the fastest (~ 66times faster than using nested ifelse() ). All the details can be found below for those who are
2005 Jun 22
2
Trouble with ifelse and if statement (PR#7962)
Full_Name: Woolton Lee Version: 2.1 OS: windows Submission from: (NULL) (128.118.224.46) I did the following ('g' and 'h' are both numeric vectors) > i <- abs(g-h) creating a vector 'i' with values, > i [1] 0.08 0.00 0.33 0.00 0.00 0.00 0.00 0.33 0.00 0.00 0.08 0.08 0.20 0.00 0.13 Now, I want to create a new vector =1 whenever 'i' = 0.33 and =0
2009 Oct 24
2
ifelse
When I run this code from an R-script: ddd = 360 + round ( atan2(-u,-v) / d2r ) print(class(ddd)) print(ddd) ifelse ( ddd>360, ddd-360, ddd ) print(ddd) I get this output: [1] "numeric" [1] 461 213 238 249 251 [1] 461 213 238 249 251 Why does ifelse not change the 461 to 101? I recreated the vector ddd and ran the same ifelse code
2008 Aug 27
1
ifelse() fill order and recycling rules [Sec=Unclassified]
Hi all, Using R v2.7.1, platform i386-pc-mingw32 Can someone please shed some light on the behaviour of ifelse() for me? My intent is to calc relative proportions of z$b, at the same time subsetting z$b based on z$a. I could attack the problem other ways (suggestions welcome) but I am also intrigued by the _order_ in which ifelse seems to assign values, and how recycling works. For instance,
2009 Feb 13
2
extracting parts of words or extraxting letter to use in ifelse-func.
Hello I want to make some variables with the ifelse-function, but i don't know how to do it. I want to make these five variables; b2$PRRSvac <- ifelse(b2$status=='A' | b2$status=='Aa',1,0) b2$PRRSdk <- ifelse(b2$status=='B' | b2$status=='Bb',1,0) b2$sanVac <- ifelse(b2$status=='C' | b2$status=='sanAa',1,0) b2$sanDk <-