Yes, thank you Eric, that's got it, sheesh, I knew it was simple.

Many thanks.

WHP

From: Eric Berger <ericjber...@gmail.com>
Sent: Thursday, April 18, 2019 8:47 AM
To: Bill Poling <bill.pol...@zelis.com>
Cc: r-help (r-help@r-project.org) <r-help@r-project.org>
Subject: Re: [R] Help with a setting some values of a df vector to 0 but not 
all values

df$ClaimManagerID[ !(df$ClaimManagerID %in% c(1565,1569,1674,415,1564))] <- 0


On Thu, Apr 18, 2019 at 3:39 PM Bill Poling <mailto:bill.pol...@zelis.com> 
wrote:
Good morning.

#RStudio Version 1.1.456
sessionInfo()
#R version 3.5.3 (2019-03-11)
#Platform: x86_64-w64-mingw32/x64 (64-bit)
#Running under: Windows >= 8 x64 (build 9200)

I have a df column that looks like the below.

#68 ID's including the 0 value

I want to set all the values to 0 with the exception of 5 which are c(1565, 
1569, 1674, 415, 1564))

I realize its basic but the routine eludes me, I have googled and there are 
plenty of
urls for setting to NA, etc.. but nothing I found, yet, where it is a subset 
routine excluding a few values.

I expect the routine would be something like --

set df1$ClaimManagerID = 0 where df$ClaimManagerID NOT IN 
c(1565,1569,1674,415,1564)

str(df$ClaimManagerID)
 int [1:18015] 1558 0 1565 1565 1565 1565 1565 0 1565 1565 ...

|ClaimManagerID |       cnt|       pct|   cum_pct|
|:--------------           |--------:|--------       -:|--------       -:|
|1565                      | 11412| 0.6334721| 0.6334721|
|0                            |  6120| 0.3397169| 0.9731890|
|1569                     |    162| 0.0089925| 0.9821815|
|1674                     |      25| 0.0013877| 0.9835692|
|415                       |      21| 0.0011657| 0.9847349|
|1564                     |      20| 0.0011102| 0.9858451|
|234                       |      19| 0.0010547| 0.9868998|
|521                       |      17| 0.0009437| 0.9878435|

etc....= 68 ID's

Thank you for any help.

WHP



Confidentiality Notice This message is sent from Zelis. ...{{dropped:13}}

______________________________________________
mailto:R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Confidentiality Notice This message is sent from Zelis. This transmission may 
contain information which is privileged and confidential and is intended for 
the personal and confidential use of the named recipient only. Such information 
may be protected by applicable State and Federal laws from this disclosure or 
unauthorized use. If the reader of this message is not the intended recipient, 
or the employee or agent responsible for delivering the message to the intended 
recipient, you are hereby notified that any disclosure, review, discussion, 
copying, or taking any action in reliance on the contents of this transmission 
is strictly prohibited. If you have received this transmission in error, please 
contact the sender immediately. Zelis, 2018.
______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to