If you want to create that output in a file, then create one long string and
use 'cat' to output; here is an example with the output to the console:

> t <- c(
+ "00000000000000000000000000000000",
+ "00000000010010010110111111101100",
+ "00000000100100101101000001011111",
+ "00000000110111000001000111100011",
+ "00000001001001010010010100001001",
+ "00000001011011011111101001101001")
> # create one long string and then use 'cat' to write it out
> long <- paste('"', paste(t, collapse='",\n"'), '"', sep='')
>
>
> cat(long)
"00000000000000000000000000000000",
"00000000010010010110111111101100",
"00000000100100101101000001011111",
"00000000110111000001000111100011",
"00000001001001010010010100001001",
"00000001011011011111101001101001">

On Tue, May 26, 2009 at 9:33 AM, peng chen <rogerchan2...@gmail.com> wrote:

> Thanks.
>
> I am sorry that I did not clearly put my question.
>
> I need to output the array like
>  t <- c(
> + "00000000000000000000000000000000",
> + "00000000010010010110111111101100",
> + "00000000100100101101000001011111",
> + "00000000110111000001000111100011",
> + "00000001001001010010010100001001",
> + "00000001011011011111101001101001")
>
> to a datafile(e.g., .txt file) where each line is for a binary number in
> this format:
> "00000000000000000000000000000000",
> "00000000010010010110111111101100",
> ....
>
> I was trying to use R-function write.table, however, I wasn't able to get
> the trailing comma for each line(although I can get the double quotation
> marks).
>
> Thanks.
>
>
>
>
>
> On Tue, May 26, 2009 at 12:46 AM, Linlin Yan <yanlinli...@gmail.com>
> wrote:
>
> > > t <- c(
> > + "00000000000000000000000000000000",
> > + "00000000010010010110111111101100",
> > + "00000000100100101101000001011111",
> > + "00000000110111000001000111100011",
> > + "00000001001001010010010100001001",
> > + "00000001011011011111101001101001")
> > > {
> > + cat ('rom_array := (\n');
> > + for (i in 1:length(t)) {
> > +   cat('"', t[i], '"',
> > +     ifelse(i == length(t), '', ',\n'), sep='')
> > + };
> > + cat(')\n');
> > + }
> > rom_array := (
> > "00000000000000000000000000000000",
> > "00000000010010010110111111101100",
> > "00000000100100101101000001011111",
> > "00000000110111000001000111100011",
> > "00000001001001010010010100001001",
> > "00000001011011011111101001101001")
> > >
> >
> >  On Tue, May 26, 2009 at 12:30 PM, peng chen <rogerchan2...@gmail.com>
> > wrote:
> > > Hi, R experts:
> > >
> > > I am trying to generate data output in the following format:
> > >
> > > rom_array := (
> > > "00000000000000000000000000000000",
> > > "00000000010010010110111111101100",
> > > "00000000100100101101000001011111",
> > > "00000000110111000001000111100011",
> > > "00000001001001010010010100001001",
> > > "00000001011011011111101001101001")
> > >
> > > I have all the necessary data line, however, I am having trouble
> > generating
> > > the double quotation marks along with the trailing comma for each line.
> > >
> > > Anyone can help?
> > >
> > > Thanks.
> > >
> > >        [[alternative HTML version deleted]]
> > >
> > > ______________________________________________
> > > R-help@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<http://www.r-project.org/posting-guide.html>
> <http://www.r-project.org/posting-guide.html>
>  > > and provide commented, minimal, self-contained, reproducible code.
> > >
> >
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help@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<http://www.r-project.org/posting-guide.html>
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem that you are trying to solve?

        [[alternative HTML version deleted]]

______________________________________________
R-help@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.

Reply via email to