Hello, I have output that I want to print out. I am having a few issues. 1] output u to power is really nothing more than a 2 x 11 set of values formed using cbind function and printed out as a data frame How can I get it to output over several lines such as seen here? 2] Critical Z etc. were added by hand. I need an example of how I can mix alphanumeric and numeric data on output. Can you assist? R is proving to be a really fine computational language that is easy to use. Thank you. Sincerely, Mary A. Marion u xbar alpha zcrit zcrit2 zstat pvalue 140 150 .05 1.6449 1.96 4 6.334248e-05 LB95 UB95 LB90 UB90 145.1 154.9 145.888 154.112 Beta Power 0.021 0.979 Critical Z = 1.645 Zstatistic = 4 Empirical Mean 150 [ 135.1, 144.9 ) = Ao(?o) Population Mean 140 [ 145.1, 154.9 ] = C(x) Pvalue < .0001
I'm not really clear on what you want here. First I guess, is the question of where those results are coming from? To 'print' or output to another format depends on what you have and how you want to print it. At the very simplest is ?sink, after that is ?write.table and after that you might want to have a look at Sweave, xtables or hwrite. Given your example, I think I'd just use write.table to output things to a text file and mess about with the output in a spreadsheet or word processor. Sorry I cannot be more specific. --- On Tue, 7/28/09, Mary A. Marion <mmstat at comcast.net> wrote:> From: Mary A. Marion <mmstat at comcast.net> > Subject: [R] formatting in r > To: r-help at r-project.org > Received: Tuesday, July 28, 2009, 1:36 PM > Hello, > > I have output that I want to print out.? I am having a > few issues. > > 1] output u to power is really nothing more than a 2 x 11 > set of values formed using cbind function > ???and printed out as a data frame > ???How can I get it to output over several > lines such as seen here? > > 2] Critical Z etc. were added by hand.? I need an > example of how I can mix alphanumeric > ???and numeric data on output. > > Can you assist?? R is proving to be a really fine > computational language that is easy to use. > > Thank you. > Sincerely, > Mary A. Marion > > ? u? xbar? alpha? zcrit? > zcrit2? zstat? ? ? ? pvalue? > 140???150? ? .05 1.6449? > ? 1.96? ? ? 4? 6.334248e-05 > > ? LB95? UB95? ? LB90? ? UB90 > 145.1 154.9 145.888 154.112 > > ? ? Beta Power > 0.021 0.979 > > ? ? Critical Z = 1.645 > ? ? Zstatistic = 4 > ? ? Empirical Mean???150? > ? [ 135.1, 144.9 ) = Ao(?o) > ? ? Population Mean? 140? ? [ > 145.1, 154.9 ] = C(x) > ? ? Pvalue? < .0001 > > ______________________________________________ > 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. >__________________________________________________________________ Make your browsing faster, safer, and easier with the new Internet Explorer? 8. Optimized for Yahoo! Get
If you want to "mix" alphanumeric and numerics, the 'sprintf' is one way of doing it:> u <- 140 > xbar <- 150 > alpha <- .05 > zcrit <- 1.6449 > zcrit2 <- 1.96 > zstat <- 4 > pvalue <- 6.334348e-05 > > cat(sprintf("u xbar alpha zcrit zcrit2 zstat pvalue %.0f %.0f %.2f %.4f %.2f %.0f %e\n",+ u, xbar, alpha, zcrit, zcrit2, zstat, pvalue)) u xbar alpha zcrit zcrit2 zstat pvalue 140 150 0.05 1.6449 1.96 4 6.334348e-05> > cat(sprintf("Critical Z = %.3f\n", zcrit))Critical Z = 1.645> >On Tue, Jul 28, 2009 at 1:36 PM, Mary A. Marion<mmstat at comcast.net> wrote:> Hello, > > I have output that I want to print out. ?I am having a few issues. > > 1] output u to power is really nothing more than a 2 x 11 set of values > formed using cbind function > ? and printed out as a data frame > ? How can I get it to output over several lines such as seen here? > > 2] Critical Z etc. were added by hand. ?I need an example of how I can mix > alphanumeric > ? and numeric data on output. > > Can you assist? ?R is proving to be a really fine computational language > that is easy to use. > > Thank you. > Sincerely, > Mary A. Marion > > ?u ?xbar ?alpha ?zcrit ?zcrit2 ?zstat ? ? ? ?pvalue ?140 ? 150 ? ?.05 1.6449 > ? ?1.96 ? ? ?4 ?6.334248e-05 > > ?LB95 ?UB95 ? ?LB90 ? ?UB90 > ?145.1 154.9 145.888 154.112 > > ? ?Beta Power > ?0.021 0.979 > > ? ?Critical Z = 1.645 > ? ?Zstatistic = 4 > ? ?Empirical Mean ? 150 ? ?[ 135.1, 144.9 ) = Ao(?o) > ? ?Population Mean ?140 ? ?[ 145.1, 154.9 ] = C(x) > ? ?Pvalue ?< .0001 > > ______________________________________________ > 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. >-- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve?