Re: [R] Beginner needs help with R

2017-02-07 Thread Bert Gunter
Yes, I was replying to the OP's query **as stated.** I try to avoid guessing what the OP really *meant*, although I grant that sometimes this may be necessary. But do note that the leading 0's in seq() *are* unnecessary: > sprintf("%02d",1:3) [1] "01" "02" "03" Cheers, Bert Bert Gunter "The

Re: [R] Beginner needs help with R

2017-02-07 Thread Ted Harding
Bert, your solution seems to presuppose that the programmer knows beforehand that the leading digit in the number is "0" (which in fact is clearly the case in Nabila Arbi's original query). However, the sequence might arise from some process outside of the progammer's contgrol, and may then either

Re: [R] Beginner needs help with R

2017-02-07 Thread Bert Gunter
No need for sprintf(). Simply: > paste0("DQ0",seq.int(60054,60060)) [1] "DQ060054" "DQ060055" "DQ060056" "DQ060057" "DQ060058" "DQ060059" [7] "DQ060060" Cheers, Bert Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus (aka

Re: [R] Beginner needs help with R

2017-02-06 Thread David Winsemius
> On Feb 6, 2017, at 9:08 AM, Jeff Newmiller wrote: > > I think it is important to point out that whenever R treats a number as a > numeric (integer or double) it loses any base 10 concept of "leading zero" in > that internal representation, so in this expression >

Re: [R] Beginner needs help with R

2017-02-06 Thread Jeff Newmiller
I think it is important to point out that whenever R treats a number as a numeric (integer or double) it loses any base 10 concept of "leading zero" in that internal representation, so in this expression seq2 <- paste0("DQ", sprintf("%06d", seq(060054, 060060))) the arguments to seq have

Re: [R] Beginner needs help with R

2017-02-06 Thread Adrian Dușa
Two methods, among others: seq1 <- paste("DQ", sprintf("%0*d", 6, seq(060054, 060060)), sep = "") or seq1 <- paste("DQ", formatC(seq(060054, 060060), dig = 5, flag = 0), sep = "") Hth, Adrian On Mon, Feb 6, 2017 at 3:50 AM, Nabila Arbi wrote: > Dear R-Help Team!

Re: [R] Beginner needs help with R

2017-02-06 Thread jim holtman
You need the leading zeros, and 'numerics' just give the number without leading zeros. You can use 'sprintf' for create a character string with the leading zeros: > # this is using 'numeric' and drops leading zeros > > seq1 <- paste("DQ", seq(060054, 060060), sep = "") > seq1 [1] "DQ60054"

Re: [R] Beginner needs help with R

2017-02-06 Thread Ivan Calandra
Hi Nabila, This is because you ask to create a sequence with seq(), which does not make much sense with non numeric data. That's why R trims the 0. One alternative would be: seq2 <- paste("DQ0", seq(60054, 60060), sep = "") Would that work for you? HTH, Ivan -- Ivan Calandra, PhD MONREPOS

Re: [R] Beginner needs help with R

2017-02-06 Thread Adams, Jean
Try this: seq1 <- paste("DQ0", seq(60054, 60060), sep = "") Jean On Sun, Feb 5, 2017 at 7:50 PM, Nabila Arbi wrote: > Dear R-Help Team! > > I have some trouble with R. It's probably nothing big, but I can't find a > solution. > My problem is the following: > I am

[R] Beginner needs help with R

2017-02-06 Thread Nabila Arbi
Dear R-Help Team! I have some trouble with R. It's probably nothing big, but I can't find a solution. My problem is the following: I am trying to download some sequences from ncbi using the ape package. seq1 <- paste("DQ", seq(060054, 060060), sep = "") sequences <- read.GenBank(seq1, seq.names