One way to add the text is to use a list with named elements for the row and
column names:
> (M <- matrix(1:9, ncol=3, byrow=TRUE,
+ dimnames=list(" "=LETTERS[1:3],
+ "THIS IS AN EXAMPLE\nOF a 3x3 MATRIX"=LETTERS[1:3])) )
THIS IS AN EXAMPLE
OF a 3x3 MATRIX
A B C
In R, see ?connectionfor information about functions similar to
matlab's fopen.
If what you're trying to do is write information and the matrix to a
file, then you can at least get started with something along the
lines of:
cat('This is my information\nand a second line of it\n',file
You can also use the comment() function to add comments to any kind of R
object.
Matthieu Dubois
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide
You can use the Matrix package:
Matrix::Matrix(1:9, ncol = 3)
On Thu, Jan 14, 2010 at 8:04 AM, wrote:
> Dear colleagues,
>
> I would need to add text (some rows of information) in a matrix. For example,
> given this matrix
>
>
> 1 2 3
> 4 5 6
> 7 8 9
>
> I would need to add this info:
>
> THIS
On 14-Jan-10 10:04:27, carfer...@alum.us.es wrote:
> Dear colleagues,
>
> I would need to add text (some rows of information) in a matrix.
> For example, given this matrix
>
> 1 2 3
> 4 5 6
> 7 8 9
>
> I would need to add this info:
>
> THIS IS AN EXAMPLE
> OF a 3x3 MATRIX
> 1 2 3
> 4 5 6
> 7
5 matches
Mail list logo