Re: [R] Writing to a file

2013-05-21 Thread arun
Hi, Try this:  lst1<-lapply(1:5,function(i) {pdf(paste0(i,".pdf"));  hist(rnorm(100),main=paste0("Histogram_",i));dev.off()}) #you can change the numbers A.K. >I'm trying to generate a pdf called 1.pdf, 2.pdf, 3.pdf etc and it isn't >working. My code is: >x <- 0 >for(i in 1:1000){ >x <- x +

Re: [R] Writing to a file

2012-02-07 Thread Petr PIKAL
Hi now you omitted data, but never mind :-) > My loop is the following > counter = 0 > for (i in 1:nrow(y)) > { > > > for (j in 1:ncol(y)) > { > if (y[i,j]=="Func_0005634") { > counter = counter + 1 } > if(y[i,j]=="Func_0005737"){ > counter = counter + 1 } > if(y[i,j]

Re: [R] Writing to a file

2012-02-07 Thread R. Michael Weylandt
As I said to you a while back, use append = TRUE. Michael On Tue, Feb 7, 2012 at 4:18 AM, Felicity wrote: > Thanks a lot for the interest :) > > My loop is the following > counter = 0 >  for (i in 1:nrow(y)) >  { > > >  for (j in 1:ncol(y)) >  { >  if (y[i,j]=="Func_0005634") { >         counter

Re: [R] Writing to a file

2012-02-07 Thread Felicity
Thanks a lot for the interest :) My loop is the following counter = 0 for (i in 1:nrow(y)) { for (j in 1:ncol(y)) { if (y[i,j]=="Func_0005634") { counter = counter + 1 } if(y[i,j]=="Func_0005737"){ counter = counter + 1 } if(y[i,j]=="Func_0005515"){ counter = c

Re: [R] Writing to a file

2012-02-07 Thread Petr PIKAL
Hi > > Thank you a lot for answering so fast! > but..what do you mean by example? > I 've mentioned above the loop I used and I also show how the file looks > like I do not see any loop. I do not archive all posts from R help, only those with interesting answers :-) and if you do not keep the co

Re: [R] Writing to a file

2012-02-07 Thread Felicity
Thank you a lot for answering so fast! but..what do you mean by example? I 've mentioned above the loop I used and I also show how the file looks like 'cause its huge. the way i read the file is x=read.table("filename.txt",header=FALSE,sep="\t",fill=TRUE) y=x[1:45,] (i use only some rows in order

Re: [R] Writing to a file

2012-02-06 Thread Petr PIKAL
Hi > > Honestly thank you for the prompt responding > and you are right I will tellyou what I want to do > and not the way ..since I dont know much from R > > > I have a txt with Proteins > > "Prot_10035" "Func_0005874" "Func_0016787" "Func_0003774" "Func_0006898" > "Func_0005856" "Fu

Re: [R] Writing to a file

2012-02-06 Thread Felicity
Honestly thank you for the prompt responding and you are right I will tellyou what I want to do and not the way ..since I dont know much from R I have a txt with Proteins "Prot_10035""Func_0005874" "Func_0016787" "Func_0003774" "Func_0006898" "Func_0005856" "Func_0005525" "Func_0005737

Re: [R] Writing to a file

2012-02-06 Thread jim holtman
You can easily do that, but the question is what is the problem you are trying to solve? What do you want to do with the lines you are writing out? Are you going to read them back in or process them with some other program? So save them in a character vector and then write them out with 'cat'.

Re: [R] Writing to a file

2012-02-06 Thread Felicity
maybe I could keep each line (having the strings) in a file or somewhere and then call a print function that prints them all together from where I saved them? Please let me know as soon as Possible!! thank you! -- View this message in context: http://r.789695.n4.nabble.com/Writing-to-a-file-tp3

Re: [R] Writing to a file

2012-02-06 Thread R. Michael Weylandt
You don't say how you are writing to a file, but some methods have an append = TRUE option that might be helpful. Your code looks really inefficient as well: I don't have time to look at it fully now, but it seems to me that you can vectorize the inner loops quite directly: for(j in ncol(y)){

Re: [R] Writing to a file

2012-02-06 Thread Felicity
Dear All!! I am also new in R and trying to write my results into a file I post here..hopefully is the proper place To be more secific I have this loop counter = 0 for (i in 1:nrow(y)) { for (j in 1:ncol(y)) { if (y[i,j]=="Func_0005634") { counter = counter + 1 } if(y[i,j]=="Fu

Re: [R] Writing to a file

2010-12-02 Thread Jorge Ivan Velez
Hi Thomas, If "x" contains your current results, one way to do what you want is the following: # data x <- read.table(textConnection("X2403,0.006049271 X2403,0.000118622 X2403,50.99600705 X2403,7.62E-150 X2419,0.012464215 X2419,9.07E-05 X2419,137.4022573 X2419,6.45E-273"), sep = ",") closeAllConn

[R] Writing to a file

2010-12-02 Thread Thomas Parr
From: Thomas Parr [mailto:thomas.p...@maine.edu] Sent: Thursday, December 02, 2010 10:52 PM To: r-help-requ...@stat.math.ethz.ch Subject: Writing to a file I am trying to get my script to write to a file from the for loop. It is "working", but the problem is at it is outputting to two columns an

Re: [R] writing to a file

2010-11-13 Thread jim holtman
The HELP page for 'sink' is pretty clear about this: sink() or sink(file=NULL) ends the last diversion (of the specified type). There is a stack of diversions for normal output, so output reverts to the previous diversion (if there was one). The stack is of up to 21 connections (20 diversions).

[R] writing to a file

2010-11-13 Thread Gregory Ryslik
Hi, I have a fairly complex object that I have written a print function for. Thus when I do print(results), the R console shows me a whole bunch of stuff already formatted. What I want to do is to take whatever print(results) shows to console and then put that in a file. I am doing this using t