Re: [R] Printing

2024-08-11 Thread Rui Barradas
Às 15:36 de 11/08/2024, Steven Yen escreveu: Thanks. Will try it. Have not tried it but I think the following may work: out$results<-NULL out$results$ei<-ap out$results$vi<-vap All I need is printing by returning out (unless I turn it off). And, retrieve ap and vap as needed as shown above.

Re: [R] Printing

2024-08-11 Thread Bert Gunter
Just for reference, R's "preferred" way to handle printing is to create "classed" objects from a function that produces all the necessary information and have an appropriate "print" method, i.e. function, for that class to print it. R has several class object systems that can do this, including the

Re: [R] Printing

2024-08-11 Thread Ivan Krylov via R-help
В Sun, 11 Aug 2024 22:36:08 +0800 Steven Yen пишет: > All I need is printing by returning out (unless I turn it off). And, > retrieve ap and vap as needed as shown above. Guess I need to read > more about invisible. Perhaps you could print(out) instead of returning it in the if (printing) branc

Re: [R] Printing

2024-08-11 Thread Steven Yen
Thanks. Will try it. Have not tried it but I think the following may work: out$results<-NULL out$results$ei<-ap out$results$vi<-vap All I need is printing by returning out (unless I turn it off). And, retrieve ap and vap as needed as shown above. Guess I need to read more about invisible.

Re: [R] Printing

2024-08-11 Thread Rui Barradas
Às 09:51 de 11/08/2024, Steven Yen escreveu: Hi In the following codes, I had to choose between printing (= TRUE) or deliver something for grab (ei, vi). Is there a way to get both--that is, to print and also have ei and vi for grab? Thanks. Steven ... out<-round(as.data.frame(cbind(ap,se,

[R] Printing

2024-08-11 Thread Steven Yen
Hi In the following codes, I had to choose between printing (= TRUE) or deliver something for grab (ei, vi). Is there a way to get both--that is, to print and also have ei and vi for grab? Thanks. Steven ... out<-round(as.data.frame(cbind(ap,se,t,p)),digits) out<-cbind(out,sig) out<-out[!gr

Re: [R] printing a data.frame without row numbers

2023-03-27 Thread Jeff Newmiller
Read ?print.data.frame. There is an argument for that. On March 27, 2023 10:05:10 AM PDT, Dennis Fisher wrote: >R 4.2.3 >OS X > >Colleagues, > >I am printing a large number of tables using the print command. A simple >example is: > print(data.frame(COL1=1:5, COL2=10:6)) > >The result in t

Re: [R] printing a data.frame without row numbers

2023-03-27 Thread avi.e.gross
Try: print(data.frame(COL1=1:5, COL2=10:6), row.names=FALSE) -Original Message- From: R-help On Behalf Of Dennis Fisher Sent: Monday, March 27, 2023 1:05 PM To: r-help@r-project.org Subject: [R] printing a data.frame without row numbers R 4.2.3 OS X Colleagues, I am printing a

Re: [R] printing a data.frame without row numbers

2023-03-27 Thread Duncan Murdoch
print(data.frame(COL1=1:5, COL2=10:6), row.names=FALSE) On 27/03/2023 1:05 p.m., Dennis Fisher wrote: R 4.2.3 OS X Colleagues, I am printing a large number of tables using the print command. A simple example is: print(data.frame(COL1=1:5, COL2=10:6)) The result in this case is:

[R] printing a data.frame without row numbers

2023-03-27 Thread Dennis Fisher
R 4.2.3 OS X Colleagues, I am printing a large number of tables using the print command. A simple example is: print(data.frame(COL1=1:5, COL2=10:6)) The result in this case is: COL1 COL2 11 10 229 338 447 556 I would like to print the table WITH

Re: [R] Printing special characters

2023-01-16 Thread Rui Barradas
Às 10:15 de 16/01/2023, Martin Maechler escreveu: Rui Barradas on Mon, 16 Jan 2023 08:46:43 + writes: > Às 08:31 de 16/01/2023, Jeff Newmiller escreveu: >> Use the Cairo PDF device? >> >> On January 16, 2023 12:18:48 AM PST, Dennis Fisher >> wrote: >>> R

Re: [R] Printing special characters

2023-01-16 Thread Martin Maechler
> Rui Barradas > on Mon, 16 Jan 2023 08:46:43 + writes: > Às 08:31 de 16/01/2023, Jeff Newmiller escreveu: >> Use the Cairo PDF device? >> >> On January 16, 2023 12:18:48 AM PST, Dennis Fisher >> wrote: >>> R 4.2.2 OS X >>> >>> Colleagues >>>

Re: [R] Printing special characters

2023-01-16 Thread PIKAL Petr
-project.org > Subject: [R] Printing special characters > > R 4.2.2 > OS X > > Colleagues > > A file that I have read includes strings like this: > "EVENT ≥ 30 sec" > When I include the string in a graphic using: > mtext(STRING, …) >

Re: [R] Printing special characters

2023-01-16 Thread Rui Barradas
Às 08:31 de 16/01/2023, Jeff Newmiller escreveu: Use the Cairo PDF device? On January 16, 2023 12:18:48 AM PST, Dennis Fisher wrote: R 4.2.2 OS X Colleagues A file that I have read includes strings like this: "EVENT ≥ 30 sec" When I include the string in a graphic using: mtex

Re: [R] Printing special characters

2023-01-16 Thread Eric Berger
How about just 'EVENT > 30 sec' or 'EVENT > 29 sec' ? On Mon, Jan 16, 2023 at 10:19 AM Dennis Fisher wrote: > R 4.2.2 > OS X > > Colleagues > > A file that I have read includes strings like this: > "EVENT ≥ 30 sec" > When I include the string in a graphic using: > mtext(STRING,

Re: [R] Printing special characters

2023-01-16 Thread Jeff Newmiller
Use the Cairo PDF device? On January 16, 2023 12:18:48 AM PST, Dennis Fisher wrote: >R 4.2.2 >OS X > >Colleagues > >A file that I have read includes strings like this: > "EVENT ≥ 30 sec" >When I include the string in a graphic using: > mtext(STRING, …) >it appears as: > "EVENT .

[R] Printing special characters

2023-01-16 Thread Dennis Fisher
R 4.2.2 OS X Colleagues A file that I have read includes strings like this: "EVENT ≥ 30 sec" When I include the string in a graphic using: mtext(STRING, …) it appears as: "EVENT ... 30 sec" Is there a simple work-around (short of reformatting all the strings, then using

Re: [R] printing with bothe print and cat...

2022-07-10 Thread akshay kulkarni
Dear Rui, Many thanks... Yours Akshay M Kulkarni From: Rui Barradas Sent: Sunday, July 10, 2022 12:39 AM To: akshay kulkarni ; R help Mailing list Subject: Re: [R] printing with bothe print and cat... Hello, Like this? testprint <- function() { for(i

Re: [R] printing with bothe print and cat...

2022-07-09 Thread Rui Barradas
Hello, Like this? testprint <- function() { for(i in 1:5) { for(j in 1:5) { cat(j, "") } cat("\t", i, "\n") } } testprint() #> 1 2 3 4 5 1 #> 1 2 3 4 5 2 #> 1 2 3 4 5 3 #> 1 2 3 4 5 4 #> 1 2 3 4 5 5 Hope this helps, Rui Barradas Às 17:46 de 09/07/2

Re: [R] printing with bothe print and cat...

2022-07-09 Thread akshay kulkarni
Dear Tim, Many thanks... Yours sincerely AKSHAYM KULKARNI From: Ebert,Timothy Aaron Sent: Saturday, July 9, 2022 11:03 PM To: akshay kulkarni ; David Winsemius Cc: R help Mailing list Subject: RE: [R] printing with bothe print and cat

Re: [R] printing with bothe print and cat...

2022-07-09 Thread akshay kulkarni
Dear David, Thanks ... Yours sinecrely, AKSHAY M KULKARNI From: David Winsemius Sent: Saturday, July 9, 2022 10:30 PM To: akshay kulkarni Cc: R help Mailing list Subject: Re: [R] printing with bothe print and cat... If spaces needed. In

Re: [R] printing with bothe print and cat...

2022-07-09 Thread David Winsemius
If spaces needed. In first sequences then paste( 1:5, collapse=“ “) Sent from my iPhone > On Jul 9, 2022, at 9:59 AM, David Winsemius wrote: > > Skip the for loops: > > cat(paste( seq(1:5), ““, 1:5) ) > > — > David > > Sent from my iPhone > >> On Jul 9, 2022, at 9:47 AM, akshay kulk

Re: [R] printing with bothe print and cat...

2022-07-09 Thread David Winsemius
Skip the for loops: cat(paste( seq(1:5), ““, 1:5) ) — David Sent from my iPhone > On Jul 9, 2022, at 9:47 AM, akshay kulkarni wrote: > > Dear members, > I have the following code: > > testprint <- function() { > > for(i in 1:5) {for(j in 1:5) > {cat(j)} >

[R] printing with bothe print and cat...

2022-07-09 Thread akshay kulkarni
Dear members, I have the following code: testprint <- function() { for(i in 1:5) {for(j in 1:5) {cat(j)} print(i)} } And the output is: > testprint() 12345[1] 1 12345[1] 2 12345[1] 3 12345[1] 4 12345[1] 5 Any idea on how to remove the [1] from the output, and g

Re: [R] Printing upon calling a function

2020-11-30 Thread Avi Gross via R-help
M To: Stefan Evert Cc: R-help Mailing List Subject: Re: [R] Printing upon calling a function No. I wrote the function so I am sure no "invisible" command was used. Strangely enough, compiling the function isto part of a package, results were NOT printed. Yes if I call the function d

Re: [R] Printing upon calling a function

2020-11-30 Thread Duncan Murdoch
On 30/11/2020 11:51 a.m., Steven Yen wrote: Thanks to all. Presenting a large-scale, replicable example can be a burden to the READERs which was why I was reluctant. You shouldn't post a large scale reproducible example, you should simplify it to just the essentials. Often in doing that you w

Re: [R] Printing upon calling a function

2020-11-30 Thread Avi Gross via R-help
t Subject: Re: [R] Printing upon calling a function Thanks. I know, my point was on why I get something printed by simply doing line 1 below and at other occasions had to do line 2. me.probit(obj) v<-me.probit(obj); v On 2020/11/30 下午 05:33, Jim Lemon wrote: > Hi Steven, > You seem

Re: [R] Printing upon calling a function

2020-11-30 Thread Steven Yen
Thanks to all. Presenting a large-scale, replicable example can be a burden to the READERs which was why I was reluctant. I am embarrassed to report that after having to restart Windows after the system hang on something unrelated, the issue was resolved and printing was normal. I bet it had n

Re: [R] Printing upon calling a function

2020-11-30 Thread Duncan Murdoch
By not posting a reproducible example, you're wasting everyone's time. Duncan Murdoch On 30/11/2020 6:06 a.m., Steven Yen wrote: No, sorry. Line 1 below did not print for me and I had to go around and do line 2 to print: me.probit(obj) v<-me.probit(obj); v A puzzle. On 2020/11/30 下午 07:0

Re: [R] Printing upon calling a function

2020-11-30 Thread Steven Yen
No, sorry. Line 1 below did not print for me and I had to go around and do line 2 to print: me.probit(obj) v<-me.probit(obj); v A puzzle. On 2020/11/30 下午 07:00, Duncan Murdoch wrote: On 30/11/2020 5:41 a.m., Stefan Evert wrote: On 30 Nov 2020, at 10:41, Steven Yen wrote: Thanks. I kno

Re: [R] Printing upon calling a function

2020-11-30 Thread Duncan Murdoch
On 30/11/2020 5:41 a.m., Stefan Evert wrote: On 30 Nov 2020, at 10:41, Steven Yen wrote: Thanks. I know, my point was on why I get something printed by simply doing line 1 below and at other occasions had to do line 2. me.probit(obj) That means the return value of me.probit() has been mar

Re: [R] Printing upon calling a function

2020-11-30 Thread Steven Yen
No. I wrote the function so I am sure no "invisible" command was used. Strangely enough, compiling the function isto part of a package, results were NOT printed. Yes if I call the function during run, by preceding the call with a line that attach the source code: source("A:/.../R/oprobit.R")

Re: [R] Printing upon calling a function

2020-11-30 Thread Stefan Evert
> On 30 Nov 2020, at 10:41, Steven Yen wrote: > > Thanks. I know, my point was on why I get something printed by simply doing > line 1 below and at other occasions had to do line 2. > > me.probit(obj) That means the return value of me.probit() has been marked as invisible, so it won't auto-

Re: [R] Printing upon calling a function

2020-11-30 Thread Steven Yen
Thanks. I know, my point was on why I get something printed by simply doing line 1 below and at other occasions had to do line 2. me.probit(obj) v<-me.probit(obj); v On 2020/11/30 下午 05:33, Jim Lemon wrote: Hi Steven, You seem to be assigning the result of me.oprobit(obj) to v instead of prin

Re: [R] Printing upon calling a function

2020-11-30 Thread Jim Lemon
Hi Steven, You seem to be assigning the result of me.oprobit(obj) to v instead of printing it. By appending ";v" tp that command line, you implicitly call "print". Jim On Mon, Nov 30, 2020 at 7:15 PM Steven Yen wrote: > > I hope I can get away without presenting a replicable set of codes > becau

Re: [R] Printing upon calling a function

2020-11-30 Thread Jeff Newmiller
Answering you is also a burden without the reprodicible code. I'll pass on that. But I will say that mixing analysis with output in the same function is a terrible habit. Come to the functional side of coding... it is much more re-usable here. On November 30, 2020 12:14:35 AM PST, Steven Yen w

[R] Printing upon calling a function

2020-11-30 Thread Steven Yen
I hope I can get away without presenting a replicable set of codes because doing so would impose burdens. I call a function which return a data frame, with the final line return(out) In one case the data frame gets printed (similar to a regression printout), with simply a call me.probit(obj

Re: [R] Printing vector

2019-07-23 Thread Steven
Thank you Lei. I incorporate Bill Dunlap's idea of flagging with FORTRAN stars when field width is short. It works great and serves what I need. Thank you all. I love R! Steven Linus Chen 於 2019/7/23 下午 05:46 寫道: Dear Steven, The function "write()" has a parameter "columns". And sprint() ca

Re: [R] Printing vector

2019-07-23 Thread Steven
Very nice indeed. Thank you gentlemen. Steven Michael Friendly 於 2019/7/24 上午 01:23 寫道: Nice to see William Dunlap take the trouble to mimic the classic Fortran behavior of printing for numbers that don't fit in the given width :) -Michael On 7/22/19 6:33 p.m., William Dunlap via R-hel

Re: [R] Printing vector

2019-07-23 Thread Michael Friendly
Nice to see William Dunlap take the trouble to mimic the classic Fortran behavior of printing for numbers that don't fit in the given width :) -Michael On 7/22/19 6:33 p.m., William Dunlap via R-help wrote: The following mimics Fortran printing with format F.. print1 <- function (x, perL

Re: [R] Printing vector

2019-07-23 Thread Steven
Thank you, Gentlemen. That serves my need. Bill's routine is great. Also, Rui: Is there a way to get rid of the filled "NA" and use space instead. Using fill = "" does not help either; it causes all numbers to be embraced with quotations. Finally, I have no idea why Rui's message did not reach

Re: [R] Printing vector

2019-07-23 Thread Linus Chen
Dear Steven, The function "write()" has a parameter "columns". And sprint() can do do some formatting in C style. x <- rnorm(100) s <- sprintf( fmt="%8.2f" ,x ) write(s, file="", ncolumns=7L) Cheers, Lei On Mon, 22 Jul 2019 at 07:37, Steven wrote: > > Is there a convenient way to print a vect

Re: [R] Printing vector

2019-07-22 Thread Rui Barradas
Hello, How could I forgot na.print? Thanks, Bill. This version c no longer has an argument fill and it's the one that behaves more like the OP asks for so far. print0c <- function(x, len = 10, digits = 2){ n <- length(x) x <- round(x, digits = digits) fill <- NA m <- n %/% len remai

Re: [R] Printing vector

2019-07-22 Thread William Dunlap via R-help
By the way, the default print method has the argument 'na.print' that can speciify how to print an NA value. E.g., > print(c(1234/, NA, 1), na.print="n/a") [1] 0.1234123 n/a 1.000 > print(c(1234/, NA, 1), na.print="") [1] 0.1234123 1.000 > print(c(1234/, NA, 1)

Re: [R] Printing vector

2019-07-22 Thread William Dunlap via R-help
The following mimics Fortran printing with format F.. print1 <- function (x, perLine = 10, fWidth = 8, fPrecision = 2, fortranStars = TRUE) { format <- paste0("%", fWidth, ".", fPrecision, "f") oldWidth <- getOption("width") on.exit(options(width = oldWidth)) options(width = perLin

Re: [R] Printing vector

2019-07-22 Thread Rui Barradas
Simpler, no loops: print0b <- function(x, len = 10, digits = 2, fill = ""){ n <- length(x) x <- round(x, digits = digits) m <- n %/% len remainder <- n %% len A <- matrix(x[seq_len(len*m)], ncol = len) if(remainder > 0){ A <- rbind(A, c(x[(len*m + 1):n], rep(fill, len*(m + 1) - n

Re: [R] Printing vector

2019-07-21 Thread Rui Barradas
Hello, Maybe something like the following is what you want. I have added an extra argument 'fill' to allow to choose what to print in the end. It's default value is "" making the entire matrix elements characters but it can be NA or 0. print0 <- function(x, len = 10, digits = 2, fill = ""){

Re: [R] Printing vector

2019-07-21 Thread Steven
Dear All: Below is what I meant. Procedure print0 allows me to print a vector of length 53 in four rows of 10 plus 1 row of 3 (Ido not like the NA). This is silly. I am hoping that there is a candid way to print the matrix. Thank you. Steven Yen === n<-53; x<-runif(n); # x<-round(x,2) print0

[R] Printing vector

2019-07-21 Thread Steven
Is there a convenient way to print a vector into rows of a specified column length? What I need is to print in the old FORTRAN format, viz., format(10F8.2) which would print, for instance, a vector of 25 into two rows of 10 plus an incomplete row of 5. I managed to write a procedure for that ta

Re: [R] Printing matrix/table in a procedure

2019-05-15 Thread Steven Yen
Great! Thanks. On 5/15/2019 7:00 PM, Rui Barradas wrote: > Hello, > > What's wrong with > > test <- function(x){ >   table <- matrix(x, nrow = 4) >   cat("\nTable:\n") >   print(table) >   invisible(list(table = table)) > } > > > Hope this helps, > > Rui Barradas > > Às 10:33 de 15/05/19, Steven Y

Re: [R] Printing matrix/table in a procedure

2019-05-15 Thread Rui Barradas
Hello, What's wrong with test <- function(x){ table <- matrix(x, nrow = 4) cat("\nTable:\n") print(table) invisible(list(table = table)) } Hope this helps, Rui Barradas Às 10:33 de 15/05/19, Steven Yen escreveu: Dear All, I would like to get a matrix (table) printed in a procedure,

[R] Printing matrix/table in a procedure

2019-05-15 Thread Steven Yen
Dear All, I would like to get a matrix (table) printed in a procedure, as attempted below. Please help. Thanks. test<-function(x){   table<-matrix(x,nrow=4)   cat("\nTable:\n",table) invisible(list(table=table)) } x<-1:20 test(x) -- st...@ntu.edu.tw (S.T. Yen) [[alternative HTML v

Re: [R] Printing vectrix

2019-03-25 Thread David L Carlson
2 13 14 15 16 17 18 1920 [3,] 21 22 23 24 25 David L Carlson Department of Anthropology Texas A&M University College Station, TX 77843-4352 -Original Message- From: R-help On Behalf Of K. Elo Sent: Monday, March 25, 2019 2:26 AM To: r

Re: [R] Printing vectrix

2019-03-25 Thread K. Elo
Hi! 2019-03-25 kello 09:30 +0800, Steven Yen wrote: > The second command is ugly. How can I print the 25 numbers into 2 > rows > of ten plus a helf row of 5? Thanks. Something like this? x<-1:25; for (i in seq(1,length(x),10)) print(x[i:ifelse((i+9)>length(x),length(x),i+9)]) HTH, Kimmo _

[R] Printing vectrix

2019-03-24 Thread Steven Yen
I like to print a vector, wrapped by rows of 10. Below the first command below works for 20 numbers. The second command is ugly. How can I print the 25 numbers into 2 rows of ten plus a helf row of 5? Thanks. > x<-1:20; matrix(x,nrow=2,byrow=T) [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9]

Re: [R] Printing a list of simultaneous equations

2019-01-21 Thread S Ellison
> -Original Message- > From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Michael > Friendly > Check out the `matlib` package on CRAN and devel on github: Very nice! Thanks for the pointer. Steve E *** This

Re: [R] Printing a list of simultaneous equations

2019-01-19 Thread Michael Friendly
John- Don't try to forge a new wheel, when you can get one ready made and it might fit your wagon. Check out the `matlib` package on CRAN and devel on github: https://github.com/friendly/matlib install.packages("matlib") library(matlib) A <- matrix(c(1,2,3, -1, 2, 1), 3, 2) b <- c(2,1,3) show

Re: [R] Printing a list of simultaneous equations

2019-01-18 Thread Sorkin, John
Steve, Thank you, John John David Sorkin M.D., Ph.D. Professor of Medicine Chief, Biostatistics and Informatics University of Maryland School of Medicine Division of Gerontology and Geriatric Medicine Baltimore VA Medical Center 10 North Greene Street GRECC (BT/18/GR) Baltimore, MD 21201-1524

Re: [R] Printing a list of simultaneous equations

2019-01-18 Thread Jeff Newmiller
Don't use the default print method then. When you type an expression alone at the console it uses a print function to convert the result to characters for output. The default print method for matrices of character uses quotes to show the exact contents of each character string. Convert the matr

Re: [R] Printing a list of simultaneous equations

2019-01-18 Thread S Ellison
You can drop the quote marks by calling print() explicitly with quote=FALSE, by using as.data.frame round your cbind, or - perhaps best - by constructing your output matrix as a data frame in the first place. (print.data.frame defaults to quote=FALSE). And if you suppress name checking in a dat

[R] Printing a list of simultaneous equations

2019-01-18 Thread Sorkin, John
I am trying to print a list of equations in an easily readable form. At this time all I can get is a series of characters enclosed in quotation marks rather than equations with numbers and equal signs. What I get is y equalsigns x z eq1 "0.5" "=""1" "2" eq2 "4" "=""

Re: [R] Printing with cat in a procedure

2018-12-22 Thread Steven Yen
Thank you all - print works wonders. On 12/22/2018 10:36 PM, Eric Berger wrote: > Hi Steven, > Here's one way, using print > > try5<-function(A,B){ > C<-A+B > #cat("\nA =",A,"\nC = ",C) > cat("\nA = ") > print(A) > cat("\nC = ") > print(C) > structure(list(A=A,B=B,C=C)) > } > > HTH,

Re: [R] Printing with cat in a procedure

2018-12-22 Thread Jeff Newmiller
Try using print instead of cat [1], and please read about what the arguments are in the help file [2][3] for any function you are using before posting a question. [1] https://stackoverflow.com/questions/31843662/what-is-the-difference-between-cat-and-print [2] ?cat [3] ?print On December 22, 2

Re: [R] Printing with cat in a procedure

2018-12-22 Thread Rui Barradas
Hello, Use print(A) and print(C). cat is meant for simpler objects. Hope this helps, Rui Barradas Às 14:31 de 22/12/2018, Steven Yen escreveu: How do I print a matrix running a procedure? In the code below, I print with the cat command and get a vector (from A and C). A<-matrix(rpois(16,lamb

Re: [R] Printing with cat in a procedure

2018-12-22 Thread Eric Berger
Hi Steven, Here's one way, using print try5<-function(A,B){ C<-A+B #cat("\nA =",A,"\nC = ",C) cat("\nA = ") print(A) cat("\nC = ") print(C) structure(list(A=A,B=B,C=C)) } HTH, Eric On Sat, Dec 22, 2018 at 4:32 PM Steven Yen wrote: > How do I print a matrix running a procedure? I

[R] Printing with cat in a procedure

2018-12-22 Thread Steven Yen
How do I print a matrix running a procedure? In the code below, I print with the cat command and get a vector (from A and C). A<-matrix(rpois(16,lambda=5),nrow=4,byrow=T) B<-diag(4) try5<-function(A,B){ C<-A+B cat("\nA =",A,"\nC = ",C) structure(list(A=A,B=B,C=C)) } v<-try5(A,B) v$C -- st

Re: [R] Printing standard notation and scientific notation in the same column of a dataframe

2018-09-27 Thread Duncan Mackay
University of New England Armidale NSW 2350 -Original Message- From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of David Winsemius Sent: Friday, 28 September 2018 04:53 To: David Disabato Cc: r-help@r-project.org Subject: Re: [R] Printing standard notation and scientific notation in

Re: [R] Printing standard notation and scientific notation in the same column of a dataframe

2018-09-27 Thread MacQueen, Don via R-help
First compare > format(c(0.52, 0.17, 0.03, 1e-20)) [1] "5.2e-01" "1.7e-01" "3.0e-02" "1.0e-20" > prettyNum(c(0.52, 0.17, 0.03, 1e-20)) [1] "0.52" "0.17" "0.03" "1e-20" > If you want to print one column at a time, that will do what you ask. If you want to print the entire data frame, with num

Re: [R] Printing standard notation and scientific notation in the same column of a dataframe

2018-09-27 Thread David Winsemius
> On Sep 27, 2018, at 9:35 AM, David Disabato wrote: > > Hi R-help, > > I was wondering if it was possible for a column of a dataframe to print > some numbers in standard notation and some in scientific notation. Say my > column of data (i.e., dat$x) has numbers between 0 and 1 with a few numb

[R] Printing standard notation and scientific notation in the same column of a dataframe

2018-09-27 Thread David Disabato
Hi R-help, I was wondering if it was possible for a column of a dataframe to print some numbers in standard notation and some in scientific notation. Say my column of data (i.e., dat$x) has numbers between 0 and 1 with a few numbers very close to 0. When using the "scipen" argument in "options," R

Re: [R] Printing left-justified character strings

2018-06-06 Thread zListserv
Duncan Many thanks. I removed the (re-)definitions for print and print.default, and I redefined print.data.frame using 'x' instead of 'df'. Your point about possible issues downstream with row names is well taken. I'll keep a lookout for any untoward side effects. In the meantime, all is wel

Re: [R] Printing left-justified character strings

2018-06-06 Thread Duncan Murdoch
On 06/06/2018 6:28 AM, zListserv wrote: Sorry. Here's how I re-defined print, print.default, and print.data.frame: print = function(df, ..., right=FALSE, row.names=FALSE) base::print(df, ..., right=right, row.names=row.names) base::print doesn't have those arguments. It only has arguments

Re: [R] Printing left-justified character strings

2018-06-06 Thread zListserv
Sorry. Here's how I re-defined print, print.default, and print.data.frame: print = function(df, ..., right=FALSE, row.names=FALSE) base::print(df, ..., right=right, row.names=row.names) print.default = function(df, ..., right=FALSE, row.names=FALSE) base::print.default(df, ..., right=right, ro

Re: [R] printing an arbitrary-length character vector in columns on a page of a pdf report

2018-06-05 Thread Richard M. Heiberger
yes, thank you for catching that slip. On Tue, Jun 5, 2018 at 11:29 PM, Christopher W. Ryan wrote: > Richard-- > > Nice. If I understand your code correctly, in the line > > ddm <- matrix("", (n+2) %/% nc, nc) > > I could instead use > > ddm <- matrix("", (n + nc - 1) %/% nc, nc) > > for generali

Re: [R] printing an arbitrary-length character vector in columns on a page of a pdf report

2018-06-05 Thread Christopher W. Ryan
Richard-- Nice. If I understand your code correctly, in the line ddm <- matrix("", (n+2) %/% nc, nc) I could instead use ddm <- matrix("", (n + nc - 1) %/% nc, nc) for generalizability, as I may have to increase nc as the list of words grows ever longer. Thanks everyone. Several good suggesti

Re: [R] printing an arbitrary-length character vector in columns on a page of a pdf report

2018-06-05 Thread Richard M. Heiberger
I think this is cuter, and it is a hair faster. n <- length(dd) ddm <- matrix("", (n+2) %/% nc, nc) ddm[1:n] <- dd Rich > system.time(for (i in 1:1) { + add <- nc - (length(dd) %% nc) + dd2 <- c(dd, rep("", add)) + ddm <- matrix(dd2, ncol = nc) + }) user system elapsed 0.064 0.100

Re: [R] printing an arbitrary-length character vector in columns on a page of a pdf report

2018-06-05 Thread Berry, Charles
> On Jun 5, 2018, at 9:45 AM, Christopher W Ryan wrote: > > I'm writing code for a recurring report, using an R --> Sweave --> pdflatex > workflow. It includes a character vector of short words that I would like > to display compactly, in columns on a page, rather than one word per line, > whi

Re: [R] Printing left-justified character strings

2018-06-05 Thread Duncan Murdoch
On 05/06/2018 7:49 PM, zListserv wrote: p.s. It seems to work for print command, but not for head, tail, or printing a data frame, per below. Any way fix the others so they all left-justify? You haven't shown us what you did. Duncan Murdoch __ R-

Re: [R] Printing left-justified character strings

2018-06-05 Thread zListserv
p.s. It seems to work for print command, but not for head, tail, or printing a data frame, per below. Any way fix the others so they all left-justify? R> x <- as.data.frame(rep(c("a", "ab", "abc"), 7)) R> print(x) rep(c("a", "ab", "abc"), 7) a ab

Re: [R] Printing left-justified character strings

2018-06-05 Thread zListserv
Duncan et al I tried to redefine print.data.frame the way you suggested, but I misplaced the ellipsis by putting it at the end of the function definition instead of immediately following the name of the data frame. Works now. Thanks! > On 2018-06-05, at 12:39, Duncan Murdoch wrote: > > On

Re: [R] Printing left-justified character strings

2018-06-05 Thread David L Carlson
Anthropology Texas A&M University -Original Message- From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Duncan Murdoch Sent: Tuesday, June 5, 2018 11:40 AM To: zListserv ; r-help@r-project.org Subject: Re: [R] Printing left-justified character strings On 05/06/2018 10:2

[R] printing an arbitrary-length character vector in columns on a page of a pdf report

2018-06-05 Thread Christopher W Ryan
I'm writing code for a recurring report, using an R --> Sweave --> pdflatex workflow. It includes a character vector of short words that I would like to display compactly, in columns on a page, rather than one word per line, which would waste a lot of space. The vector of words will increase unpred

Re: [R] Printing left-justified character strings

2018-06-05 Thread Duncan Murdoch
On 05/06/2018 10:24 AM, zListserv wrote: Many (most?) R functions print character strings and factor labels right-justified. Could you be more specific? I see character strings left justified, e.g. x <- rep(c("a", "ab", "abc"), 7) prints as [1] "a" "ab" "abc" "a" "ab" "abc" "a" [

[R] Printing left-justified character strings

2018-06-05 Thread zListserv
Many (most?) R functions print character strings and factor labels right-justified. print accepts right=FALSE to print character strings left-justified, but neither head nor tail seem to do so, and even print is a little inconsistent depending on whether it's done while knitting. Is there a wa

Re: [R] printing a data.frame that contains a list-column of S4 objects

2016-01-14 Thread boB Rudis
Martin, I'm pretty sure the use of Matrix here (actually by someone else than Dr Bryan) was to make an easy, inline, reproducible example. The actual "ugh" column comes from using git2r. I'm assuming there's an API call returning some pretty gnarly structures that are getting shoehorned into a data

Re: [R] printing a data.frame that contains a list-column of S4 objects

2016-01-14 Thread Martin Maechler
> boB Rudis > on Tue, 12 Jan 2016 13:51:50 -0500 writes: > I wonder if something like: > format.list <- function(x, ...) { > rep(class(x[[1]]), length(x)) > } > would be sufficient? (prbly needs more 'if's though) Dear Jenny, for a different perspective (and a lo

Re: [R] printing a data.frame that contains a list-column of S4 objects

2016-01-12 Thread boB Rudis
I wonder if something like: format.list <- function(x, ...) { rep(class(x[[1]]), length(x)) } would be sufficient? (prbly needs more 'if's though) On Tue, Jan 12, 2016 at 12:15 PM, Jenny Bryan wrote: > Is there a general problem with printing a data.frame when it has a > list-column of S4 obj

[R] printing a data.frame that contains a list-column of S4 objects

2016-01-12 Thread Jenny Bryan
Is there a general problem with printing a data.frame when it has a list-column of S4 objects? Or am I just unlucky in my life choices? I ran across this with objects from the git2r package but maintainer Stefan Widgren points out this example below from Matrix as well. I note that the offending o

Re: [R] Printing row and column names of cells with specific value in a big matrix

2015-07-20 Thread gaurav kandoi
Thanks a lot Sarah. I think I've got what I wanted. On Mon, Jul 20, 2015 at 2:55 PM, Sarah Goslee wrote: > Subsetting error. See below. > > On Mon, Jul 20, 2015 at 3:29 PM, gaurav kandoi wrote: >> Hi Sarah, sorry for posting in HTML. >> >> I've two big matrices (5k*4k) with the same structure, i

Re: [R] Printing row and column names of cells with specific value in a big matrix

2015-07-20 Thread Sarah Goslee
Subsetting error. See below. On Mon, Jul 20, 2015 at 3:29 PM, gaurav kandoi wrote: > Hi Sarah, sorry for posting in HTML. > > I've two big matrices (5k*4k) with the same structure, i.e. : > > ,mRNA1,mRNA2,mRNA3 > lncRNA1,0.395646498,0.949950035,0.761770206 > lncRNA2,0.037909944,0.661258022,0.5586

Re: [R] Printing row and column names of cells with specific value in a big matrix

2015-07-20 Thread gaurav kandoi
Hi Sarah, sorry for posting in HTML. I've two big matrices (5k*4k) with the same structure, i.e. : ,mRNA1,mRNA2,mRNA3 lncRNA1,0.395646498,0.949950035,0.761770206 lncRNA2,0.037909944,0.661258022,0.558657799 lncRNA3,0.678459646,0.652364052,0.359053653 Now, I would like to extract the names of the

Re: [R] Printing row and column names of cells with specific value in a big matrix

2015-07-20 Thread Sarah Goslee
Without a reproducible example, or at least a non-mangled one (please don't post in HTML), I'm not inclined to try it, but why not use sig_values to index row.names() and col.names() if you're after the names? Sarah On Mon, Jul 20, 2015 at 1:44 PM, gaurav kandoi wrote: > Hi All > > I've two big

[R] Printing row and column names of cells with specific value in a big matrix

2015-07-20 Thread gaurav kandoi
Hi All I've two big matrices (5k*4k) with the same structure, i.e. : mRNA1 mRNA2 mRNA3 lncRNA1 0.395646 0.94995 0.76177 lncRNA2 0.03791 0.661258 0.558658 lncRNA3 0.67846 0.652364 0.359054 lncRNA4 0.57769 0.003 0.459127 Now, I would like to extract the names of the row,col pairs whose value

Re: [R] Printing with Header & no of observations

2015-05-27 Thread John Kane
ingston ON Canada > -Original Message- > From: shivibha...@ymail.com > Sent: Wed, 27 May 2015 04:32:30 -0700 (PDT) > To: r-help@r-project.org > Subject: [R] Printing with Header & no of observations > > HI Team, > A quick question. > > When I used t

[R] Printing with Header & no of observations

2015-05-27 Thread Shivi82
HI Team, A quick question. When I used the print option in R to see the output of my syntax I do not see the headers or column names. Is there a way to see the headers in the print. Also as most of the datasets we work today have huge number of observations but when I print it only shows a portion

Re: [R] Printing/Generating/Outputting a Table (Not Latex)

2014-12-10 Thread Henrik Bengtsson
On Tue, Dec 9, 2014 at 3:11 PM, Henrik Bengtsson wrote: > I'm surprised no one mentioned alternatives to LaTeX, which is not > necessarily installed on all systems and it's also quite a > heavy-weight setup (100's-1000's MBs). An alternative is to output a > table in Markdown or HTML and convert

Re: [R] Printing/Generating/Outputting a Table (Not Latex)

2014-12-09 Thread Richard M. Heiberger
?latex answers a lot of these questions. The design intent of the latex() function is to construct one table at a time in its own .tex flle. The user then collects these and inserts them into a full document, either manually or with Sweave. The individual table has no context and no caption. It i

Re: [R] Printing/Generating/Outputting a Table (Not Latex)

2014-12-09 Thread Ted Harding
The program 'gv' is installed on just about any linux system. It has many available options (one, which might be useful, being "-watch", whose effect is that if the file being displayed is changed, e.g. by being over-written by a new file with the same name, then 'gv' automatically updates what it

Re: [R] Printing/Generating/Outputting a Table (Not Latex)

2014-12-09 Thread Kate Ignatius
Okay, all. I have it to work using this: library(Hmisc) options(latexcmd='pdflatex') options(dviExtension='pdf') options(xdvicmd='gnome-open') Running your simple code from above... by question is this: the pdf is saved in a tmp directory... where do I change the directory path? I thought it wa

Re: [R] Printing/Generating/Outputting a Table (Not Latex)

2014-12-09 Thread Henrik Bengtsson
I'm surprised no one mentioned alternatives to LaTeX, which is not necessarily installed on all systems and it's also quite a heavy-weight setup (100's-1000's MBs). An alternative is to output a table in Markdown or HTML and convert that to PDF. The poor man's HTML-to-PDF is to manually open the

  1   2   3   >