Dear group, I am trying to prepare a NONMEM friendly dataset for population PK analysis. My patient IDs are 10 digit long and NONMEM is losing precison and rouding the last couple of digits. I need to generate unique Patient IDs fromt he current 10-digit IDs. Ihave total 250 subjects so I appreciate if anybody can suggest me a way to code this in R. Regards, Ayyappa [[alternative HTML version deleted]]
Hi> > Dear group, > > I am trying to prepare a NONMEM friendly dataset for population PK > analysis. My patient IDs are 10 digit long and NONMEM is losing precison > and rouding the last couple of digits. I need to generate uniquePatient> IDs fromt he current 10-digit IDs. Ihave total 250 subjects so I > appreciate if anybody can suggest me a way to code this in R.I would start with ?abbreviate and check uniqueness with ?unique or ?duplicated Regards Petr> > Regards, > Ayyappa > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guidehttp://www.R-project.org/posting-guide.html> and provide commented, minimal, self-contained, reproducible code.
Does this do it for you:> sprintf("%010.0f", seq(1000000000.0, length = 250, by = 1.0))[1] "1000000000" "1000000001" "1000000002" "1000000003" "1000000004" "1000000005" "1000000006" [8] "1000000007" "1000000008" "1000000009" "1000000010" "1000000011" "1000000012" "1000000013" [15] "1000000014" "1000000015" "1000000016" "1000000017" "1000000018" "1000000019" "1000000020" [22] "1000000021" "1000000022" "1000000023" "1000000024" "1000000025" "1000000026" "1000000027" [29] "1000000028" "1000000029" "1000000030" "1000000031" "1000000032" "1000000033" "1000000034" [36] "1000000035" "1000000036" "1000000037" "1000000038" "1000000039" "1000000040" "1000000041" [43] "1000000042" "1000000043" "1000000044" "1000000045" "1000000046" "1000000047" "1000000048" [50] "1000000049" "1000000050" "1000000051" "1000000052" "1000000053" "1000000054" "1000000055" [57] "1000000056" "1000000057" "1000000058" "1000000059" "1000000060" "1000000061" "1000000062" [64] "1000000063" "1000000064" "1000000065" "1000000066" "1000000067" "1000000068" "1000000069" [71] "1000000070" "1000000071" "1000000072" "1000000073" "1000000074" "1000000075" "1000000076" [78] "1000000077" "1000000078" "1000000079" "1000000080" "1000000081" "1000000082" "1000000083" [85] "1000000084" "1000000085" "1000000086" "1000000087" "1000000088" "1000000089" "1000000090" [92] "1000000091" "1000000092" "1000000093" "1000000094" "1000000095" "1000000096" "1000000097" On Wed, Jan 11, 2012 at 11:32 AM, Petr PIKAL <petr.pikal at precheza.cz> wrote:> Hi >> >> Dear group, >> >> I am trying to prepare a NONMEM friendly dataset for population PK >> analysis. My patient IDs are 10 digit long and NONMEM is losing precison >> and rouding the last couple of digits. ?I need to generate unique > Patient >> IDs fromt he current 10-digit IDs. ?Ihave total 250 subjects so I >> appreciate if anybody can suggest me a way to code this in R. > > I would start with > > ?abbreviate > and check uniqueness with > ?unique or ?duplicated > > Regards > Petr > > >> >> Regards, >> Ayyappa >> >> ? ?[[alternative HTML version deleted]] >> >> ______________________________________________ >> R-help at r-project.org mailing list >> 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. > > ______________________________________________ > R-help at r-project.org mailing list > 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.-- Jim Holtman Data Munger Guru What is the problem that you are trying to solve? Tell me what you want to do, not how you want to do it.
On Jan 11, 2012, at 11:12 AM, Ayyappa Chaturvedula wrote:> Dear group, > > I am trying to prepare a NONMEM friendly dataset for population PK > analysis. My patient IDs are 10 digit long and NONMEM is losing > precison > and rouding the last couple of digits.Are you sure?> I need to generate unique Patient > IDs fromt he current 10-digit IDs. Ihave total 250 subjects so I > appreciate if anybody can suggest me a way to code this in R.They should not be input or managed as numbers but rather as character variables. If you want them output without quotes, then fine, R can do that when specified. -- David Winsemius, MD West Hartford, CT
Unfortunately the "rounding effect" (which I assumed was related to the automatic conversion from integer to numeric) is only going to show up above 2147483647L, so I question whether you really demonstrated a solution to what I understood was the fundamental problem. -- David. On Jan 11, 2012, at 11:50 AM, jim holtman wrote:> Does this do it for you: > >> sprintf("%010.0f", seq(1000000000.0, length = 250, by = 1.0)) > [1] "1000000000" "1000000001" "1000000002" "1000000003" "1000000004" > "1000000005" "1000000006" > [8] "1000000007" "1000000008" "1000000009" "1000000010" "1000000011" > "1000000012" "1000000013" > [15] "1000000014" "1000000015" "1000000016" "1000000017" "1000000018" > "1000000019" "1000000020" > [22] "1000000021" "1000000022" "1000000023" "1000000024" "1000000025" > "1000000026" "1000000027" > [29] "1000000028" "1000000029" "1000000030" "1000000031" "1000000032" > "1000000033" "1000000034" > [36] "1000000035" "1000000036" "1000000037" "1000000038" "1000000039" > "1000000040" "1000000041" > [43] "1000000042" "1000000043" "1000000044" "1000000045" "1000000046" > "1000000047" "1000000048" > [50] "1000000049" "1000000050" "1000000051" "1000000052" "1000000053" > "1000000054" "1000000055" > [57] "1000000056" "1000000057" "1000000058" "1000000059" "1000000060" > "1000000061" "1000000062" > [64] "1000000063" "1000000064" "1000000065" "1000000066" "1000000067" > "1000000068" "1000000069" > [71] "1000000070" "1000000071" "1000000072" "1000000073" "1000000074" > "1000000075" "1000000076" > [78] "1000000077" "1000000078" "1000000079" "1000000080" "1000000081" > "1000000082" "1000000083" > [85] "1000000084" "1000000085" "1000000086" "1000000087" "1000000088" > "1000000089" "1000000090" > [92] "1000000091" "1000000092" "1000000093" "1000000094" "1000000095" > "1000000096" "1000000097" > > On Wed, Jan 11, 2012 at 11:32 AM, Petr PIKAL > <petr.pikal at precheza.cz> wrote: >> Hi >>> >>> Dear group, >>> >>> I am trying to prepare a NONMEM friendly dataset for population PK >>> analysis. My patient IDs are 10 digit long and NONMEM is losing >>> precison >>> and rouding the last couple of digits. I need to generate unique >> Patient >>> IDs fromt he current 10-digit IDs. Ihave total 250 subjects so I >>> appreciate if anybody can suggest me a way to code this in R. >> >> I would start with >> >> ?abbreviate >> and check uniqueness with >> ?unique or ?duplicated >> >> Regards >> Petr >> >> >>> >>> Regards, >>> Ayyappa >>> >>> [[alternative HTML version deleted]] >>> >>> ______________________________________________ >>> R-help at r-project.org mailing list >>> 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. >> >> ______________________________________________ >> R-help at r-project.org mailing list >> 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. > > > > -- > Jim Holtman > Data Munger Guru > > What is the problem that you are trying to solve? > Tell me what you want to do, not how you want to do it. > > ______________________________________________ > R-help at r-project.org mailing list > 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.David Winsemius, MD West Hartford, CT
Dear Ayyappa Unique identifiers can be created from numbers using factor. These are coded as integers in R which you could use to relabel your dataset.> x <- rep(1000000006:1000000008, each = 2) > x[1] 1000000006 1000000006 1000000007 1000000007 1000000008 1000000008> y <- factor(x) > levels(y)[1] "1000000006" "1000000007" "1000000008"> z <- as.numeric(y) > z[1] 1 1 2 2 3 3 Regards, Chris Campbell MANGO SOLUTIONS Data Analysis that Delivers +44 1249 767700 -----Original Message----- From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of Ayyappa Chaturvedula Sent: 11 January 2012 16:12 To: r-help at r-project.org Subject: [R] Generating unque patient IDs Dear group, I am trying to prepare a NONMEM friendly dataset for population PK analysis. My patient IDs are 10 digit long and NONMEM is losing precison and rouding the last couple of digits. I need to generate unique Patient IDs fromt he current 10-digit IDs. Ihave total 250 subjects so I appreciate if anybody can suggest me a way to code this in R. Regards, Ayyappa [[alternative HTML version deleted]] ______________________________________________ R-help at r-project.org mailing list 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. LEGAL NOTICE This message is intended for the use o...{{dropped:10}}
Dear all, I am sorry if I misstated the problem. The roundig issue is with NONMEM software not with R. But the suggestions are helpful. Regards,Ayyappa Chaturvedula On Jan 11, 2012, at 12:14 PM, David Winsemius <dwinsemius at comcast.net> wrote:> Unfortunately the "rounding effect" (which I assumed was related to > the automatic conversion from integer to numeric) is only going to > show up above 2147483647L, so I question whether you really > demonstrated a solution to what I understood was the fundamental > problem. > > -- > David. > > On Jan 11, 2012, at 11:50 AM, jim holtman wrote: > >> Does this do it for you: >> >>> sprintf("%010.0f", seq(1000000000.0, length = 250, by = 1.0)) >> [1] "1000000000" "1000000001" "1000000002" "1000000003" "1000000004" >> "1000000005" "1000000006" >> [8] "1000000007" "1000000008" "1000000009" "1000000010" "1000000011" >> "1000000012" "1000000013" >> [15] "1000000014" "1000000015" "1000000016" "1000000017" "1000000018" >> "1000000019" "1000000020" >> [22] "1000000021" "1000000022" "1000000023" "1000000024" "1000000025" >> "1000000026" "1000000027" >> [29] "1000000028" "1000000029" "1000000030" "1000000031" "1000000032" >> "1000000033" "1000000034" >> [36] "1000000035" "1000000036" "1000000037" "1000000038" "1000000039" >> "1000000040" "1000000041" >> [43] "1000000042" "1000000043" "1000000044" "1000000045" "1000000046" >> "1000000047" "1000000048" >> [50] "1000000049" "1000000050" "1000000051" "1000000052" "1000000053" >> "1000000054" "1000000055" >> [57] "1000000056" "1000000057" "1000000058" "1000000059" "1000000060" >> "1000000061" "1000000062" >> [64] "1000000063" "1000000064" "1000000065" "1000000066" "1000000067" >> "1000000068" "1000000069" >> [71] "1000000070" "1000000071" "1000000072" "1000000073" "1000000074" >> "1000000075" "1000000076" >> [78] "1000000077" "1000000078" "1000000079" "1000000080" "1000000081" >> "1000000082" "1000000083" >> [85] "1000000084" "1000000085" "1000000086" "1000000087" "1000000088" >> "1000000089" "1000000090" >> [92] "1000000091" "1000000092" "1000000093" "1000000094" "1000000095" >> "1000000096" "1000000097" >> >> On Wed, Jan 11, 2012 at 11:32 AM, Petr PIKAL >> <petr.pikal at precheza.cz> wrote: >>> Hi >>>> >>>> Dear group, >>>> >>>> I am trying to prepare a NONMEM friendly dataset for population PK >>>> analysis. My patient IDs are 10 digit long and NONMEM is losing >>>> precison >>>> and rouding the last couple of digits. I need to generate unique >>> Patient >>>> IDs fromt he current 10-digit IDs. Ihave total 250 subjects so I >>>> appreciate if anybody can suggest me a way to code this in R. >>> >>> I would start with >>> >>> ?abbreviate >>> and check uniqueness with >>> ?unique or ?duplicated >>> >>> Regards >>> Petr >>> >>> >>>> >>>> Regards, >>>> Ayyappa >>>> >>>> [[alternative HTML version deleted]] >>>> >>>> ______________________________________________ >>>> R-help at r-project.org mailing list >>>> 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. >>> >>> ______________________________________________ >>> R-help at r-project.org mailing list >>> 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. >> >> >> >> -- >> Jim Holtman >> Data Munger Guru >> >> What is the problem that you are trying to solve? >> Tell me what you want to do, not how you want to do it. >> >> ______________________________________________ >> R-help at r-project.org mailing list >> 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. > > David Winsemius, MD > West Hartford, CT >