Re: [R] cannot print a list with cat

2022-10-26 Thread Richard O'Keefe
\n is for TERMINATING lines. Just like in C, C++, Java, C#, Python, Ruby, Erlang, pretty much everything that uses \n in strings at all. sprintf("gradtol = %e\n", mycontrol$gradtol) makes sense. More generally, sprintf() takes as many arguments as you care to give it, so cat(sprintf("tol =

Re: [R] cannot print a list with cat

2022-10-24 Thread Steven T. Yen
Thanks to all, who have helped greatly. I essentially followed Rui to do:   fmt_string<-paste0("\ntol = %.1e","\nreltol  = %.1e","\nsteptol = %.1e","\ngradtol = %.1e") #msg<-sprintf(fmt_string,mycontrol$tol,mycontrol$reltol,mycontrol$steptol,mycontrol$gradtol) #works

Re: [R] cannot print a list with cat

2022-10-24 Thread Rui Barradas
Às 16:21 de 24/10/2022, Steven T. Yen escreveu: Thanks to everyone. I read ? sprint and the following is best I came up with. If there are ways to collapse the lines I'd be glad to know. Otherwise, I will live with this. Thanks again. cat(sprintf("\ntol = %e",mycontrol$tol),    

Re: [R] cannot print a list with cat

2022-10-24 Thread Bert Gunter
"collapse the lines" means ?? If you mean that you want to control the precision (# of decimals places to show) then that is exactly what sprintf does. ?sprintf tells you how. If you mean something else, please specify more clearly -- or await a reply from someone with greater insight than I. --

Re: [R] cannot print a list with cat

2022-10-24 Thread Steven T. Yen
Thanks to everyone. I read ? sprint and the following is best I came up with. If there are ways to collapse the lines I'd be glad to know. Otherwise, I will live with this. Thanks again. cat(sprintf("\ntol = %e",mycontrol$tol),     sprintf("\nreltol  = %e",mycontrol$reltol),    

Re: [R] cannot print a list with cat

2022-10-24 Thread Rui Barradas
Hello, There's also ?message. msg <- sprintf("(tol,reltol,steptol,gradtol): %E %E %E %E", mycontrol$tol,mycontrol$reltol,mycontrol$steptol,mycontrol$gradtol) message(msg) Hope this helps, Rui Barradas Às 14:25 de 24/10/2022, Steven T. Yen escreveu: Thank, Boris and Ivan. The simple

Re: [R] cannot print a list with cat

2022-10-24 Thread Spencer Graves
On 10/24/22 7:39 AM, Steven T. Yen wrote: I have a "list" containing four elements, as shown below: > t(mycontrol) tol reltol steptol gradtol [1,] 0   0  1e-08   1e-12 Printing this in a main program causes no problem (as shown above). But, using the command t(mycontrol) the

Re: [R] cannot print a list with cat

2022-10-24 Thread Steven T. Yen
Thank, Boris and Ivan. The simple command suggested by Ivan ( print(t(mycontrol)) ) worked. I went along with Boris' suggestion and do/get the following: cat(sprintf("(tol,reltol,steptol,gradtol): %E %E %E %E",mycontrol$tol, mycontrol$reltol,mycontrol$steptol,mycontrol$gradtol))

Re: [R] cannot print a list with cat

2022-10-24 Thread Boris Steipe
??? t() is the transpose function. It just happens to return your list unchanged. The return value is then printed to console if it is not assigned, or returned invisibly. Transposing your list is probably not what you wanted to do. Returned values do not get printed from within a loop or

Re: [R] cannot print a list with cat

2022-10-24 Thread Ivan Krylov
В Mon, 24 Oct 2022 20:39:33 +0800 "Steven T. Yen" пишет: > Printing this in a main program causes no problem (as shown above). > But, using the command t(mycontrol) the line gets ignored. t() doesn't print, it returns a value. In R, there's auto-printing in the toplevel context (see

[R] cannot print a list with cat

2022-10-24 Thread Steven T. Yen
I have a "list" containing four elements, as shown below: > t(mycontrol) tol reltol steptol gradtol [1,] 0   0  1e-08   1e-12 Printing this in a main program causes no problem (as shown above). But, using the command t(mycontrol) the line gets ignored. Any idea? Thanks. Steven Yen