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
> 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
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
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.
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
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
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
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
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
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
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>
>
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
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
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
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
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)){ #
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
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
> 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
, 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
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
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?
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
> -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,
>
>
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
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
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
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)
> -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:
>
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
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
> -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:
> >
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
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
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
;
> 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
Yes works,
Thank you Henrique.
Im 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
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
>
> _
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
39 matches
Mail list logo