The functions cbind and rbind are S3 generic, with methods for data frames. The data frame method will be used if at least one argument is a data frame and the rest are vectors or matrices. There can be other methods; in particular, there is one for time series objects. See the section on ‘Dispatch’ for how the method to be used is selected.
Questions tagged [cbind]
450 questions
1
vote
2 answers
R - cbind lists ( lm summary )
I am looking to cbind lm summary stored in different lists.
I have like 20 different models stored, so I would like to avoir cbind by hand.
Do you have any idea how I could do this ?
Here are a sample of my list
data = list(structure(list(`a…

giac
- 4,261
- 5
- 30
- 59
1
vote
2 answers
cbind coerces a data frame to matrix
I'm having trouble When using cbind. Prior to using cbind the object is a data.frame of two character vectors.
After I add a column using cbind, the data.frame object changes class to matrix. I've tried as.vector, declaring h as an empty…

Ken
- 11
- 3
1
vote
1 answer
How to rbind vectors into different columns, leaving NAs in remaining cells
Let's say I have an unspecified number of vectors of different lengths, and I want to effectively rbind them together, with the caveat that they must each occupy a different column in the resulting data.frame. You may assume that the vectors are…

bgoldst
- 34,190
- 6
- 38
- 64
1
vote
1 answer
Combining and appending columns of different lengths, by row number, R
I'm working with biochemical data from subjects, analysing the results by sex. I have 19 biochemical tests to analyse for each sex, for each of two drugs (haematology and anatomy tests coming later).
For reasons of reproducibility of results and for…

Michelle
- 1,281
- 2
- 16
- 31
1
vote
2 answers
R -- How can I calculate group means for a list of data frames, using a different subset condition to calculate each mean?
I have a list of three data frames and would like to generate another list of three data frames whose rows consist of each of the values of a grouping variable (g1) and the means of six variables by the g1 variable. The twist is that I would like to…

IamWill
- 35
- 5
1
vote
1 answer
combining two histograms on the same plot with R
I would like to draw a histogram to compare two datasets on the same plot. The length of the vectors are different. d1 has 180 numbers and d2 has 300 numbers.I tried the following code as…

ayya
- 31
- 1
- 4
1
vote
1 answer
Merge and Sum Multiple CSV files in R
First Question/Post, Hopefully I've not duplicated this but have searched as many terms as I can think of. I'm sure this is going to be a "doh" moment, But here goes:
Using R I'm trying to read in several 100 .csv files, of two columns each, type…

NoobMat
- 73
- 1
- 1
- 5
1
vote
2 answers
Better way to cbind newly calculated column and quickly naming output
I've finally lost my habit of loops in R. Basically usually calculating new columns, and then doing calculations and aggregations on these new columns.
But I have a question regarding cbind which I use for adding columns.
Is there a better way than…

maze
- 335
- 4
- 9
1
vote
1 answer
cbind for list of zoo objects
What is a clean way to get around the following issue?
I want to cbind a list of zoo objects with do.call.
>> zz <- list( zoo(1:10,1:10), zoo(101:110,1:10), zoo(201:210,1:10) )
>> names(zz)<-c('test','bar','foo')
>> do.call(cbind,zz)
> test bar…

user2297212
- 23
- 6
1
vote
1 answer
Using rbind()/cbind() to append single row data in R
I have 6 numeric lists each containing different number of values i.e [1:350] , [1:450] .... . I am trying to append all of these lists into a singular list i.e [1:1050] using rbind(), but the output I get is dataframe of [1:350, 1:6].
Can someone…

show_stopper
- 288
- 5
- 17
1
vote
3 answers
Combine table with different elements
I have items in different lists and I want to count the item in each list and output it to a table. However, I ran into difficulty when there are different items in the list. Too illustrate my problem:
item_1 <- c("A","A","B")
item_2 <-…

Adrien
- 151
- 1
- 8
1
vote
2 answers
merge by date not time in R
I have a large time-series file that I imported from my working directory and then turn them into log returns by:
read.csv("/Volumes/3TB/ALLsince1996.csv",header=T)-> ALL
all <- xts(ALL[,2:dim(ALL)[2]], order.by= as.POSIXct(ALL[,1],…

Rime
- 912
- 2
- 11
- 39
1
vote
1 answer
cbind or merge by pasting names?
I have many large xts objects in my workspace that i am trying to combine by using cbind , merge, apply or even in a loop. Currently, the xts data is tick data and cannot paste it here because of its length. However, what I am trying to do…

Rime
- 912
- 2
- 11
- 39
1
vote
2 answers
To merge list's members with differing number of rows
Here is my list that you can run in your console (please, tell me if it's too long for example purposes, I can amend it):
my_list = list(structure(list(PX_LAST = c(0.398, 0.457, 0.4, 0.159, 0.126,
0.108, 0.26, 0.239, 0.222, 0.191, 0.184)), .Names =…

Lisa Ann
- 3,345
- 6
- 31
- 42
1
vote
1 answer
Merge and append rows within a dataframe in R
I have read many of the threads and do not think my question has been asked before. I have a data.frame in R related to advertisements shown to customers as such:.. I have many customers, 8 different products.. so this is just a sample
mydf <-…

blast00
- 559
- 2
- 8
- 18