Skip to content
Prev 392158 / 398502 Next

printing with bothe print and cat...

Here is an alternative without for loops

n_rows <- 5
n_cols <- 5
p_df <- data.frame(matrix( rep(1:n_rows, n_cols), nrow=n_rows, byrow=TRUE), line_n=1:n_rows)
print(p_df)


If n_rows always equals n_cols then you could combine the first two lines

n_rows <- n_cols <- 5
p_df <- data.frame(matrix( rep(1:n_rows, n_cols), nrow=n_rows, byrow=TRUE), line_n=1:n_rows)
n_cols <- n_cols+1
print(p_df)

You might also notice that as.numeric(rownames(p_df)) returns the same values as line_n.


Tim
From: akshay kulkarni <akshay_e4 at hotmail.com>
Sent: Saturday, July 9, 2022 1:41 PM
To: Ebert,Timothy Aaron <tebert at ufl.edu>; David Winsemius <dwinsemius at comcast.net>
Cc: R help Mailing list <r-help at r-project.org>
Subject: Re: [R] printing with bothe print and cat...

[External Email]
Dear Tim,
                   Many thanks...

Yours sincerely
AKSHAYM KULKARNI
Message-ID: <BN6PR2201MB1553C647A64AB9E0ECAD418DCF859@BN6PR2201MB1553.namprd22.prod.outlook.com>
In-Reply-To: <PU4P216MB1568A309F94B33EC574B43BCC8859@PU4P216MB1568.KORP216.PROD.OUTLOOK.COM>