Re: Adding columns and rows to a table

• To: mathgroup at smc.vnet.net
• Subject: [mg33461] Re: Adding columns and rows to a table
• From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
• Date: Fri, 22 Mar 2002 04:06:37 -0500 (EST)
• Organization: Universitaet Leipzig
• References: <a7crth\$hug\$1@smc.vnet.net>
• Sender: owner-wri-mathgroup at wolfram.com

```Hi,

is

mm = {{1, 2, 3, 4}, {5, 6, 7, 8}, {9, 10, 11, 12}};

PadRight[#, 6, Last[#]] & /@ mm

elegant ??

Regards
Jens

"Philip M. Howe" wrote:
>
> Hello,
>
> I want to add to a table two columns that match the last column, and
> two rows that match the last row.
>
> Thus, if my table is
>
> {{1,2,3,4},{5,6,7,8},{9,10,11,12}};  I want to modify it such that I
> end up with
>
> {{1,2,3,4,4,4},  {5,6,7,8,8,8}, {9,10,11,12,12,12}, {
> 9,10,11,12,12,12}, {9,10,11,12,12,12}};
>
> This works:
>
> tab1 = {{1, 2, 3, 4}, {5, 6, 7, 8}, {9, 10, 11, 12}};
>
> tab1c = Transpose[
>        Append[Append[Transpose[tab1], Transpose[tab1][[-1]]],
>          Transpose[tab1][[-1]]]];
> tab1d = Append[Append[tab1c, tab1c[[-1]]], tab1c[[-1]]] // TableForm
>
> However, I bet there are much more efficient and elegant ways of
> doing this.  Any suggestions?
>
> Thanks in advance for the help.  The ideas I obtain from you folks
>
> Regards,
>
> Phil
> --
> Philip M. Howe
> Program Manager, Stockpile Surety
> Los Alamos National Laboratory
>
> (505) 665-5332
> (505) 667-9498
> Fax: 505-665-5249
> email pmhowe at lanl.gov
> Mail Stop P945

```

• Prev by Date: RE: ListPlot with multiple (related) series.
• Next by Date: Re: Interpolation problem
• Previous by thread: Re: Adding columns and rows to a table
• Next by thread: Re: Adding columns and rows to a table