Re: [R] Sprintf to call data frame from environment

2016-05-24 Thread Jim Lemon
Hi Beatriz, I'll guess that you have a number of files with names like this: Samples_1.txt Samples_2.txt ... Each one can be read with a function like read.table and will return a data frame with default names (V1, V2, ...). You then want to extract the first element (column) of the data frame. I

Re: [R] Sprintf to call data frame from environment

2016-05-24 Thread David Winsemius
> On May 24, 2016, at 2:01 PM, Beatriz wrote: > > > In my environment I have a data frame called Samples_1.txt. > From this data frame I need to get variable V1. My code doesn't work. Thanks! > > $V1 > > Note: I need to do it in this way because I have the code into a for loop. You ar

Re: [R] Sprintf to call data frame from environment

2016-05-24 Thread Nordlund, Dan (DSHS/RDA)
uesday, May 24, 2016 2:01 PM > To: r-help@r-project.org > Subject: [R] Sprintf to call data frame from environment > > > In my environment I have a data frame called Samples_1.txt. > From this data frame I need to get variable V1. My code doesn't work. > Thanks! > &g

[R] Sprintf to call data frame from environment

2016-05-24 Thread Beatriz
In my environment I have a data frame called Samples_1.txt. From this data frame I need to get variable V1. My code doesn't work. Thanks! sprintf("Samples_%s.txt", 1)$V1 Note: I need to do it in this way because I have the code into a for loop.

[R] Sprintf to call data frame from environment

2016-05-24 Thread Beatriz
In my environment I have a data frame called Samples_1.txt. From this data frame I need to get variable V1. My code doesn't work. Note: I need to do it in this way because I have the code into a for loop. sprintf("Samples_%s.txt", 1)$V1 __ R-help@r-pr

Re: [R] sprintf in system command

2013-02-15 Thread Rui Barradas
Hello, In what follows I've used print(), not system(). The trick is to use paste0() to form the command. for (i in 1:10) { cmd <- paste0('C:/Users/.../dssp-2.0.4-win32.exe -i ', sprintf("data_%s.txt",i), ' -o ', sprintf("data_%s.dssp",i)) print(cmd) } Hope this helps, Rui Barrada

Re: [R] sprintf in system command

2013-02-15 Thread jim holtman
I think what you want is something like this system(sprintf('C:/Users/.../dssp-2.0.4-win32.exe -i data%d.txt -o data%d.dssp', i, i)) On Fri, Feb 15, 2013 at 12:33 PM, Esam Tolba wrote: > hi all > I am using r (2.15.2) in windows 7 32bit > I want to execute an external program from r console. th

[R] sprintf in system command

2013-02-15 Thread Esam Tolba
hi all I am using r (2.15.2) in windows 7 32bit I want to execute an external program from r console. the program is a command line program which needs the following format to start C:/Users/.../dssp-2.0.4-win32.exe -i data_1.txt -o data_1.dssp I used the system co

Re: [R] sprintf doesn't care of escape characters

2012-07-30 Thread Edwin Helbert Aponte Angarita
Thank you very much. I didn't know about this difference, I thought it just behaved as in C/C++. Thanks. On Mon, 2012-07-30 at 14:15 -0400, jim holtman wrote: > sprintf is working just fine. Your problem is the interpretation of > what the results are. Displaying the object will show the escape

Re: [R] sprintf doesn't care of escape characters

2012-07-30 Thread Jeff Newmiller
I am unable to determine what you think the problem is from your description. A wild guess is that you just don't know what you are looking at in the output. Do you understand the difference between the output of the "print" function and of the "cat" function? Try cat( sprintf("a\"bc\"d") ) an

Re: [R] sprintf doesn't care of escape characters

2012-07-30 Thread jim holtman
sprintf is working just fine. Your problem is the interpretation of what the results are. Displaying the object will show the escape characters, but if you use "cat", or output to a file, you will see that the result is correct: > cat( sprintf("a\nb")) a b> > cat(sprintf("a\"bc\"d")) a"bc"d> >

[R] sprintf doesn't care of escape characters

2012-07-30 Thread Edwin Helbert Aponte Angarita
Hi. I am having trouble with something that should be simple. I am unable to get sprintf using escape sequences: > sprintf("a\nb") [1] "a\nb" > sprintf("a\"bc\"d") [1] "a\"bc\"d" But it seems to need them any way: > sprintf("a\"bc"d") Error: unexpected symbol in "sprintf("a\"bc"d" Any suggest

Re: [R] sprintf does not print

2011-02-16 Thread Alaios
Thank you very much both. You made it clear :) Regards Alex --- On Wed, 2/16/11, ted.hard...@wlandres.net wrote: > From: ted.hard...@wlandres.net > Subject: Re: [R] sprintf does not print > To: "R help" > Cc: "Alaios" > Date: Wednesday, February 16, 20

Re: [R] sprintf does not print

2011-02-16 Thread Ted Harding
ith the C function of the same name. Hoping this helps, Ted. On 16-Feb-11 10:25:31, Mario Valle wrote: > Use > cat(sprintf('I did the the %d,%d \n',k,l)) > The functions do not print in non interactive mode > Hope it helps > mario > On

Re: [R] sprintf does not print

2011-02-16 Thread Mario Valle
tement works if I copy and paste it inside R sprintf('I did the the %d,%d \n',k,l) but when this is inside a loop I get no message. listcounter<-1 for (k in c(1:mmax)){ # for (l in c(1:nmax)){ lst[[listcounter]]<-fun(estimatedsr) listcounter<-listcounter+1 sp

[R] sprintf does not print

2011-02-16 Thread Alaios
Dear all I have an sprintf inside a loop to track changes in variable's value. This sprintf statement works if I copy and paste it inside R sprintf('I did the the %d,%d \n',k,l) but when this is inside a loop I get no message. listcounter<-1 for (k in c(1:mmax)){ #

Re: [R] sprintf funny behavior

2010-05-11 Thread Mario Valle
Not always the result of a function is printed on screen. Use: for(i in 1:4) print(sprintf("%d",4)) ciao! mario Matt Young wrote: >> sprintf("%d",4) > [1] "4" >> for(i in 1:4) sprintf("%d",4) >> for(i in 1:4) print(4) > [1] 4 > [1] 4 > [1] 4 > [1] 4 > > Why doesn't sprintf like the for l

Re: [R] sprintf funny behavior

2010-05-11 Thread Ted Harding
On 11-May-10 16:53:56, Matt Young wrote: >> sprintf("%d",4) > [1] "4" >> for(i in 1:4) sprintf("%d",4) >> for(i in 1:4) print(4) > [1] 4 > [1] 4 > [1] 4 > [1] 4 > > Why doesn't sprintf like the for loop here Because, as a general rule, output generated inside loops, and within execution of functi

[R] sprintf funny behavior

2010-05-11 Thread Matt Young
> sprintf("%d",4) [1] "4" > for(i in 1:4) sprintf("%d",4) > for(i in 1:4) print(4) [1] 4 [1] 4 [1] 4 [1] 4 > Why doesn't sprintf like the for loop here __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the

Re: [R] sprintf() and return() oddity

2010-04-27 Thread Albert-Jan Roskam
, wine, public order, irrigation, roads, a fresh water system, and public health, what have the Romans ever done for us? ~~ --- On Tue, 4/27/10, Raw, Jeremy, P.E. wrote: From: Raw, Jeremy, P.E. Subject: RE: [R] sprintf() and

Re: [R] sprintf() and return() oddity

2010-04-27 Thread Raw, Jeremy, P.E.
f Of Albert-Jan Roskam Sent: Tuesday, April 27, 2010 09:29 AM To: R Mailing List Subject: [R] sprintf() and return() oddity Hi,   If I use sprintf and return inside a function, sprintf doesn't print anything anymore. See the non-sense example below.   > x <- function() { a <- 888

[R] sprintf() and return() oddity

2010-04-27 Thread Albert-Jan Roskam
Hi,   If I use sprintf and return inside a function, sprintf doesn't print anything anymore. See the non-sense example below.   > x <- function() { a <- 888 + sprintf("xxx %s", a) } > x() [1] "xxx 888" > x <- function() { a <- 888 + sprintf("xxx %s", a) + return(a) } > x() [1] 888 Is this a bug?

Re: [R] sprintf + integer(0) problem

2010-02-24 Thread Esmail
On 24-Feb-10 20:03, Henrique Dallazuanna wrote: You can use tryCatch also: cat(tryCatch(sprintf('found %s in col %d\n', s, c), error = function(x)cat('Not Found\n'))) Ah .. one more way .. thanks, I've saved it away in my set of R tricks! Best, Esmail

Re: [R] sprintf + integer(0) problem

2010-02-24 Thread William Dunlap
> -Original Message- > From: r-help-boun...@r-project.org > [mailto:r-help-boun...@r-project.org] On Behalf Of Esmail > Sent: Wednesday, February 24, 2010 10:07 AM > To: r-help@r-project.org > Subject: [R] sprintf + integer(0) problem > > Hello all, > >

Re: [R] sprintf + integer(0) problem

2010-02-24 Thread Henrique Dallazuanna
You can use tryCatch also: cat(tryCatch(sprintf('found %s in col %d\n', s, c), error = function(x)cat('Not Found\n'))) On Wed, Feb 24, 2010 at 9:49 PM, esmail wrote: > > > Henrique Dallazuanna wrote: >> >> You can try this: >> >> cat(sprintf(ifelse(any(grepl(s, nn)), 'found %s in col %d\n', 'Col

Re: [R] sprintf + integer(0) problem

2010-02-24 Thread esmail
Henrique Dallazuanna wrote: > > You can try this: > > cat(sprintf(ifelse(any(grepl(s, nn)), 'found %s in col %d\n', 'Column > %s not found'), s, match(s, nn))) > > Wow .. one can always learn something new .. that looks pretty complex, I have a bunch of print statements. I was hoping for a s

Re: [R] sprintf + integer(0) problem

2010-02-24 Thread Henrique Dallazuanna
You can try this: cat(sprintf(ifelse(any(grepl(s, nn)), 'found %s in col %d\n', 'Column %s not found'), s, match(s, nn))) On Wed, Feb 24, 2010 at 3:06 PM, Esmail wrote: > Hello all, > > I am stuck with R v2.8.0 under Linux for the time being and I am > running into a small problem that doesn't e

[R] sprintf + integer(0) problem

2010-02-24 Thread Esmail
Hello all, I am stuck with R v2.8.0 under Linux for the time being and I am running into a small problem that doesn't exist under 2.9.x and 2.10.x with sprintf. If I have the following code segment to help me determine the column number for a specific column header/label: nn = names(Dataset)

Re: [R] sprintf() question

2009-05-18 Thread Daniel Nordlund
> -Original Message- > From: Peter Dalgaard [mailto:p.dalga...@biostat.ku.dk] > Sent: Monday, May 18, 2009 12:15 AM > To: Daniel Nordlund > Cc: ted.hard...@manchester.ac.uk; r-help@r-project.org > Subject: Re: [R] sprintf() question > > Daniel Nordlund wrote: >

Re: [R] sprintf() question

2009-05-18 Thread Peter Dalgaard
Daniel Nordlund wrote: Enlightenment is what I asked for, and it is what I got. I was having a senior moment I guess. I was picturing 8 as binary 0100, when obviously it is binary 1000. So yes, the required power of 2 is 1, and it is fine with me that Windows implementation does not display i

Re: [R] sprintf() question

2009-05-17 Thread Ei-ji Nakama
iel Nordlund : >> -Original Message- >> From: Ted Harding [mailto:ted.hard...@manchester.ac.uk] >> Sent: Sunday, May 17, 2009 3:32 PM >> To: Daniel Nordlund >> Cc: r-help@r-project.org >> Subject: RE: [R] sprintf() question >> >> On 17-May-09 22:03:1

Re: [R] sprintf() question

2009-05-17 Thread Daniel Nordlund
> -Original Message- > From: Ted Harding [mailto:ted.hard...@manchester.ac.uk] > Sent: Sunday, May 17, 2009 3:32 PM > To: Daniel Nordlund > Cc: r-help@r-project.org > Subject: RE: [R] sprintf() question > > On 17-May-09 22:03:19, Daniel Nordlund wrote: > >

Re: [R] sprintf() question

2009-05-17 Thread Ted Harding
On 17-May-09 22:03:19, Daniel Nordlund wrote: > When I type the following, I get results different from what I > expected. > >> sprintf('%a',3) > [1] "0x1.8" > > Shouldn't the result be > > [1] "0x1.8p+2" Well, not "p+2" but "p+1" (0x1.8 = 1.1000[2] ; *2 = 11.000[2] = 3[10]) ; however, I get

[R] sprintf() question

2009-05-17 Thread Daniel Nordlund
When I type the following, I get results different from what I expected. > sprintf('%a',3) [1] "0x1.8" Shouldn't the result be [1] "0x1.8p+2" I read through the help ?sprintf and didn't find anything that changed my expectation. What am I misunderstanding? I am using R-2.9.0 binary from CRA

Re: [R] sprintf()

2008-06-09 Thread jim holtman
03" > > > On Mon, Jun 9, 2008 at 12:42 PM, Paulo Cardoso <[EMAIL PROTECTED]> > wrote: > >> Yes works, >> >> Thank you Henrique. >> >> I'm so basic with R! >> >> Paulo >> >> >> >> From: Henrique Dallazuann

Re: [R] sprintf()

2008-06-09 Thread jim holtman
; > Thank you Henrique. > > I'm so basic with R! > > Paulo > > > > From: Henrique Dallazuanna [mailto:[EMAIL PROTECTED] > Sent: segunda-feira, 9 de Junho de 2008 17:37 > To: Paulo Cardoso > Cc: r-help@r-project.org > Subject: Re: [R] sprintf() > > &g

Re: [R] sprintf()

2008-06-09 Thread Paulo Cardoso
Yes works, Thank you Henrique. I’m so basic with R! Paulo From: Henrique Dallazuanna [mailto:[EMAIL PROTECTED] Sent: segunda-feira, 9 de Junho de 2008 17:37 To: Paulo Cardoso Cc: r-help@r-project.org Subject: Re: [R] sprintf() Try: sprintf("%E00", pi) On Mon, Jun 9, 2008

Re: [R] sprintf()

2008-06-09 Thread Henrique Dallazuanna
Try: sprintf("%E00", pi) On Mon, Jun 9, 2008 at 1:28 PM, Paulo Cardoso <[EMAIL PROTECTED]> wrote: > Hi, > > I'm not being able to represent the result of sprintf("%E", pi) > [1] "3.141593E+00" > > Into this: > "3.141593E+" > > Thanks in advance > > Paulo > > _

[R] sprintf()

2008-06-09 Thread Paulo Cardoso
Hi, I'm not being able to represent the result of sprintf("%E", pi) [1] "3.141593E+00" Into this: "3.141593E+" Thanks in advance Paulo __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting gu