[R] matrix with additional upper, botton, left and right cells

jim holtman jholtman at gmail.com
Wed Sep 27 05:28:02 CEST 2006


How about something like this:
> x <- matrix(1:100,10)
> x.1 <- array(-3, dim=c(12,12))
> x.1[2:11, 2:11] <- x
> x.1
      [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12]
 [1,]   -3   -3   -3   -3   -3   -3   -3   -3   -3    -3    -3    -3
 [2,]   -3    1   11   21   31   41   51   61   71    81    91    -3
 [3,]   -3    2   12   22   32   42   52   62   72    82    92    -3
 [4,]   -3    3   13   23   33   43   53   63   73    83    93    -3
 [5,]   -3    4   14   24   34   44   54   64   74    84    94    -3
 [6,]   -3    5   15   25   35   45   55   65   75    85    95    -3
 [7,]   -3    6   16   26   36   46   56   66   76    86    96    -3
 [8,]   -3    7   17   27   37   47   57   67   77    87    97    -3
 [9,]   -3    8   18   28   38   48   58   68   78    88    98    -3
[10,]   -3    9   19   29   39   49   59   69   79    89    99    -3
[11,]   -3   10   20   30   40   50   60   70   80    90   100    -3
[12,]   -3   -3   -3   -3   -3   -3   -3   -3   -3    -3    -3    -3
>

On 9/26/06, Milton Cezar <miltinho_astronauta at yahoo.com.br> wrote:
> Dear R Gurus,
>
>  I have a matrix dim(1000x1000) and I need create a second matrix with dim(1002x1002) and insert my first matrix at position col=2,line=2. Please, see an example below:
>
>  0050055050
>  5550000000
>  5000505005
>  5005000500
>  0055550555
>
>  and I need
>
>  333333333333
>  300500550503
>  355500000003
>  350005050053
>  350050005003
>  300555505553
>  333333333333
>
>  Thanks a lot,
>
>  miltinho
>
>  __________________________________________________
>
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> 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.
>


-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem you are trying to solve?



More information about the R-help mailing list