[R] Concatenation

David Winsemius dwinsemius at comcast.net
Fri May 21 21:58:55 CEST 2010


On May 21, 2010, at 12:21 AM, santana sarma wrote:

> Hi David,
>
> SORRY - I am trying to be more clearer this time.
>
> Let's say the dataframe has some rows and columns, with unique  
> rownames and column names. The rest of the data in the dataframe are  
> just numbers.

So have you tried any of the solutions offered so far?

c(apply(df[1:10,], 1, I))

c(df[ , 1:10]

This will not become any more clear unless you offer an R object. Your  
terminology has obviously been contaminated by excessive contact with  
spreadsheets. If you want R-answers you need to learn to define R- 
objects and employ R-terminology.

-- 
David.
>
> I wish to concatenate those rows. That means : I wish to concatenate  
> first 10 rows' values in one row, then next 20 rows's values in the  
> next row .... and so on.
>
> Similarly, for columns : The first 10 column's values will be one  
> below the other ... and so on.
>
> Cheers,
>
>
> = = = = = = = = =  = =
>
>
> On Fri, May 21, 2010 at 3:53 PM, David Winsemius <dwinsemius at comcast.net 
> > wrote:
>
> On May 20, 2010, at 11:05 PM, santana sarma wrote:
>
>  Hi,
>
> I have a dataframe with some 800 rows and 14 columns.
>
> Could you please advise how I can concatenate the rows - one after  
> another.
> Similarly for columns, one below the other.
>
> Not sure exactly what you are after:
>
> unlist might accomplish the second task.
>
> Whether c(apply(df, 1, I)) would be satisfactory for the first task  
> might depend on whether the columns in the dataframe were all of the  
> same type. Now that I think of it, both soolutions would force the  
> types to be that same.
>
> ?"c"
> ?I
> ?apply
>
> df[1:nrow(df), ]   ...  would essentially give you the first  
> request, but it would not be any different than just typing df.  
> So .... what do intend this process to accomplish?
>
> --
>
> David Winsemius, MD
> West Hartford, CT
>
>

David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list