Re: [R] which() function help page precision

2018-11-16 Thread Martin Maechler
> peter dalgaard > on Fri, 16 Nov 2018 13:39:27 +0100 writes: > Well, "Basically, " is an excuse for not being > accurate. Making the code more complex doesn't really help > the explanation. It could be better to just add "(except > for NA handling)" or so. > -pd

[R] Help with factor column replacement value issue-SOLVED

2018-11-16 Thread Bill Poling
Thanks again Michael, simple enough! r1z <- r1 str(r1z$B1) #Factor w/ 14 levels "Z","A","C","D",..: 2 2 3 3 2 2 2 2 2 2 ... # When you do your step of replacing lower case l with upper case L the # level still stays in the factor even though it is empty. If that is a nuisance r1z$B1 <- factor(r1z

Re: [R] Help with factor column replacement value issue

2018-11-16 Thread Bill Poling
Hi Jeff and Michael, thank you for your quick responses and suggestions I will try them out. Appreciate everyone's time! WHP My suggestion is to avoid converting the column to a factor until it is cleaned up the way you want it. There is also the forcats package, but I still prefer to work

Re: [R] Help with factor column replacement value issue

2018-11-16 Thread Bill Poling
Thank you Bert. WHP As usual, careful reading of the relevant Help page would resolve the confusion. from ?factor: "factor(x, exclude = NULL) applied to a factor without NAs is a no-operation unless there are unused levels: in that case, a factor with the reduced level set is returned. If excl

Re: [R] Help with factor column replacement value issue

2018-11-16 Thread Jeff Newmiller
My suggestion is to avoid converting the column to a factor until it is cleaned up the way you want it. There is also the forcats package, but I still prefer to work with character data for cleaning. The stringsAsFactors=FALSE argument to read.table and friends helps with this. On November 16,

Re: [R] Help with factor column replacement value issue

2018-11-16 Thread Michael Dewey
Dear Bill When you do your step of replacing lower case l with upper case L the level still stays in the factor even though it is empty. If that is a nuisance x <- factor(x) will drop the unused levels. There are other ways of doing this. Michael On 16/11/2018 15:38, Bill Poling wrote: Hel

Re: [R] Help with factor column replacement value issue

2018-11-16 Thread Bert Gunter
As usual, careful reading of the relevant Help page would resolve the confusion. from ?factor: "factor(x, exclude = NULL) applied to a factor without NAs is a no-operation unless there are unused levels: in that case, a factor with the reduced level set is returned. If exclude is used, since R ve

[R] Help with factor column replacement value issue

2018-11-16 Thread Bill Poling
Hello: I am running windows 10 -- R3.5.1 -- RStudio Version 1.1.456 I would like to know why when I replace a column value it still appears in subsequent routines: My example: r1$B1 is a Factor: It is created from the first character of a list of CPT codes, r1$CPT. head(r1$CPT, N= 25) [1] A4

[R] Revolutions blog roundup: October 2018

2018-11-16 Thread David Smith (CDA) via R-help
For almost 10 years, Microsoft staff and guests have written about R at the Revolutions blog (http://blog.revolutionanalytics.com) and every month I post a summary of articles from the previous month of particular interest to readers of r-help. In case you missed them, here are some articles relat

Re: [R] which() function help page precision

2018-11-16 Thread peter dalgaard
Well, "Basically, " is an excuse for not being accurate. Making the code more complex doesn't really help the explanation. It could be better to just add "(except for NA handling)" or so. -pd > On 16 Nov 2018, at 11:08 , buzon informatica, ige > wrote: > > The which() function help page s

[R] which() function help page precision

2018-11-16 Thread buzon informatica, ige
The which() function help page states that, in the default case, what the function returns is: " Basically, the result is (1:length(x))[x]." That would only be true if there are not any NA values in x. I think it would be more accurate to say: "Basically, the result is (1:length(x))[!is.na(x) &