Search This Blog

Sunday, March 31, 2013

How to create a list of matrix in R

I want to create a list of 2D matrices
> x
     [,1] [,2]
[1,]    1    6
[2,]    2    7
[3,]    3    8
[4,]    4    9
[5,]    5   10

> y
     [,1] [,2]
[1,]  301  306
[2,]  302  307
[3,]  303  308
[4,]  304  309
[5,]  305  310

> MATS<- span="">c(x,y)

> MATS[1]
[1] 1
I would like to be able to refer to MATS[1] as if it where x...
share|improve this question

1 Answer

up vote 1 down vote accepted
Try
x <- span=""> matrix(1:10, ncol=2)
y <- span=""> x+300

MATS <- span=""> list(x, y) # use 'list' instead of 'c' to create a list of matrices
MATS
[[1]]
     [,1] [,2]
[1,]    1    6
[2,]    2    7
[3,]    3    8
[4,]    4    9
[5,]    5   10

[[2]]
     [,1] [,2]
[1,]  301  306
[2,]  302  307
[3,]  303  308
[4,]  304  309
[5,]  305  310
Here you have to refer to MATS[[1]] as if it were x
If you want to append a new matrix to the exiting list try
z <- span=""> x+500
MATS[[3]] <- span=""> z  # appeding a new matrix to the existing list
MATS

[[1]]
     [,1] [,2]
[1,]    1    6
[2,]    2    7
[3,]    3    8
[4,]    4    9
[5,]    5   10

[[2]]
     [,1] [,2]
[1,]  301  306
[2,]  302  307
[3,]  303  308
[4,]  304  309
[5,]  305  310

[[3]]
     [,1] [,2]
[1,]  501  506
[2,]  502  507
[3,]  503  508
[4,]  504  509
[5,]  505  510
One drawback of this approach is that you have to know the position in the list where you have to append the new matrix, if you don't know it or simply if you dont want this approach, then here's a trick:
unlist(list(MATS, list(z)), recursive=FALSE) # will give u the same list :D

Installing Kile on Microsoft Windows

KileOnWindows

Installing Kile on Microsoft Windows

Thanks to the efforts of the KDE on Windows team, it is now possible to install and run Kile natively on the Microsoft Windows operating system!
In order to install and use Kile on Microsoft Windows, a LaTeX distribution, like MikTeX has to be installed first. Please follow the installation instructions of your chosen distribution.
Next, Kile and the required KDE libraries have to be installed. For this purpose, the KDE on Windows initiative provides an installer which downloads and installs the necessary packages. You can download the installer and install Kile as follows.
  • and run it.
  • Next, you have to choose the installation path for the KDE packages.
  • Now, it is recommended to select "End User" mode and for best results, the packages compiled for MSVC.
  • In the next step a temporary directory for storing the downloaded packages has to be selected. It is fine to use the default value.
  • The Internet connectivity settings can be changed next. These settings depend, of course, on your particular network setup.
  • Now, a mirror for downloading the packages has to be selected. It is recommended to choose a mirror that is located geographically close to your location. However, sometimes the most recent packages can sometimes be found on the master server http://www.winkde.org.
  • Next, a KDE for Windows release has to be selected. Currently, the most recent release is version 4.8.0.
  • Now, the main packages have to be selected. In the applications tab, the package "Kile" has to be selected and it is recommended to install the "kdebase-workspace" package in order to install the KDE system settings tool.
Note: Due to a problem with the dependencies recorded for the Kile package in the 4.8.0 release, it is also necessary to install the "Kate" and "Okular" packages in this step.
  • Additionally, in the "Spelling Packages" tab, dictionaries can be selected for spell checking.
  • The installer is then presenting additional packages that will be downloaded and installed as dependencies of the previously selected packages.
  • Next, the installer is downloading and installing the packages.
  • Finally, Kile should have been added to the start menu,
  • and you can run it!
Finally, it should be noted that the Microsoft Windows version of Kile might contain more bugs than its Linux counterpart. Hence, please report every problem that you notice in the KDE bug tracking system against Kile.

Installing Kile 2.1

With the KDE 4.8 release for Windows, the instructions above will actually install an unstable version of Kile.
If you prefer to work with a more stable version, you will have to download the appropriate 'gitStable-2.1' package of Kile from http://www.winkde.org/pub/kde/ports/win32/repository-4.8/kde/. If you exactly followed the instructions above, the required file will be http://www.winkde.org/pub/kde/ports/win32/repository-4.8/kde/kile-vc100-gitStable-2.1-bin.tar.bz2.
The file that you have downloaded then has to be extracted in the KDE installation directory (in the example above, C:\KDE).