[R] extractor rows from a matrix

Petr Klasterecky klaster at karlin.mff.cuni.cz
Thu Jun 14 10:06:31 CEST 2007


billycorg napsal(a):
> thanks for the answer..but i don't find what i'm looking for!
> 
> now i'm trying to expose better my problem:
> i have:
> 
> ht= a 1096rows x 3 columns matrix 
>  
> i'd like a function like this:
>  
> d[i]=rbind(ht[i,]) for (i in 1:length(ht))
> 
> but this don't work :(
> can anyone seriously help  me?

The problem is that people actually are trying to seriously help you, 
but it is really difficult from your queries...

Please specify what you expect to be your output - a vector where you 
just paste the rows of of the original matrix one by one?
If so, you can do
d <- t(ht)
dim(d) <- NULL

or (a 'dirty' way)
d <- c(t(ht))

It is not at all clear what your statement should do. For example, what 
is length(ht) with ht being a matrix? For R it is the total number of 
elements, but did you mean this or the number of rows/columns??

The suggestion to read R-Intro is the best advice you got here.

Petr

-- 
Petr Klasterecky
Dept. of Probability and Statistics
Charles University in Prague
Czech Republic



More information about the R-help mailing list