[R] printing with bothe print and cat...
akshay kulkarni
@k@h@y_e4 @end|ng |rom hotm@||@com
Sun Jul 10 11:27:44 CEST 2022
Dear Rui,
Many thanks...
Yours
Akshay M Kulkarni
________________________________
From: Rui Barradas <ruipbarradas using sapo.pt>
Sent: Sunday, July 10, 2022 12:39 AM
To: akshay kulkarni <akshay_e4 using hotmail.com>; R help Mailing list <r-help using r-project.org>
Subject: Re: [R] printing with bothe print and cat...
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/2022, akshay kulkarni escreveu:
> 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 give spaces in the cat output? The desired output is:
>
> 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
> Many thanks in advance.....
>
> THanking you,
> Yours sincreely,
> AKSHAY M KULKARNI
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.
[[alternative HTML version deleted]]
More information about the R-help
mailing list