Re: [R] avoid row/column indexing in capture.output

From: David Winsemius <dwinsemius_at_comcast.net>
Date: Mon, 14 Jun 2010 18:46:56 -0400

On Jun 14, 2010, at 6:19 PM, Subodh Acharya wrote:

> Hi everyone,
> This might be a very petty thing but Its not working for me.
> I want to export an output to a txt file but without indexing.

Unfortunately we cannot see the structure of "output" but from the result you are getting it looks like both "Time" and "output" might be numeric vectors of the same length, although the [,1] access looks wrong for a vector. Why don't you give us the result of str(output)?

> Here is what I have tried to do
>
> outfile<- function(Time, var.names, output) {
> var.names = c(names(para))
> for(i in 1: ncol(output)){
> cat(length(var.names), '\n')
> cat("A", "S", "C", "I", '\n')
> cat("time =", "yes", '\n')
> cat("RUN", i, '\n')
> cat(length(Time), '\n')
> # print(cbind(Time, output[,i]))

# Perhaps?

cat( paste(Time, inp[ ,1], "\n")) # since paste is "vectorized".

-- 
David.


> }
> }
> This works fine and
> I get the output like as follows
>
> 4
> A S C I
> time = yes
> RUN 1
> 111
> [,1] [,2]
> [1,] 0.00 1.7500000
> [2,] 0.05 0.3983540
> [3,] 0.10 0.6010150
> [4,] 0.15 0.6759570
> [5,] 0.20 0.7165215
> [6,] 0.25 0.7423391
> [7,] 0.30 0.7603594
> [8,] 0.35 0.7737155
> [9,] 0.40 0.7840432
> [10,] 0.45 0.7922850
> .
> .
> But I need need to have an output like this
> 4
> A S C I
> time = yes
> RUN 1
> 111
> 0.00 1.7500000
> 0.05 0.3983540
> 0.10 0.6010150
> ...
>
>
> Any kind of help will be highly appreciated.
>
> Thank you in advance
>
> --
> Acharya, Subodh
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help_at_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.
David Winsemius, MD West Hartford, CT ______________________________________________ R-help_at_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.
Received on Mon 14 Jun 2010 - 22:48:56 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 14 Jun 2010 - 23:20:32 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive