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
1 answer
Operating with two panel dataset with same dates
I am trying to manipulate two datasets filled with:
728 rows and 365 columns. Data are average daily temperatures measured every day of the year.
938 rows and 365 columns. Data are average daily temperatures measured every day of the year
Dataset…

nflore
- 196
- 1
- 10
1
vote
0 answers
I have a list of matrices with equal number of rows. I want to cbind the matrices
I have a list of matrices with an equal number of rows. I want to combine the matrices column-wise (much like the cbind function). Suppose A and B are matrices with an equal number of rows. My list l is l[[1]] = A and l[[2]] = B. What I want is a…

Paul
- 107
- 4
1
vote
1 answer
benferroni adjusted p-value - how to bind it without exponentiating just like OR and CI?
I am trying to get my benferroni adjusted p value to my cbinded list of OR and CI and face two issues:
when I extract p-values from my logistic regression I get the intercept as well, however I proceed with transformation regardless of that. I do…

GaB
- 1,076
- 2
- 16
- 29
1
vote
2 answers
How to cbind multiple columns in R
mydata <- data.frame(a = 2, b = 3, c = 3)
myvec <- c(2, 9, 1)
I would like to column bind mydata with myvec. I want the final output to look something like this:
> mydata
a b c myvec1 myvec2 myvec3
1 2 3 3 2 9 1
However, if I…

Adrian
- 9,229
- 24
- 74
- 132
1
vote
0 answers
How to use cbind to add a vector to a dataframe that has different number of rows
I'm trying to add a column within my dataframe with the values stored in a vector, but I'm getting the error message Error in data.frame(..., check.names = FALSE) : arguments imply differing number of rows: 82, 63
This is the code I…

Marcus
- 15
- 4
1
vote
1 answer
Binding dataframes with different length to an Excel file in separate columns
The data frame are not having same number of rows. The datasets are uneven
So how to add the data frame horizontally in separate column of single sheets?
Below is the code I am using to write separate data frame for sample data
files <-…

shanti
- 57
- 1
- 8
1
vote
3 answers
How to concatenate two matrix column by column?
Let's say I have two matrices A and B with the same dimensions like follow:
A = matrix(1:30, nrow=3, ncol=10)
B = matrix(30:1, nrow=3, ncol=10)
#dim(A) = dim(B)
#[1] 3 10
A
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
[1,] 1 4 7…

Ph.D.Student
- 704
- 6
- 27
1
vote
0 answers
R cbind is very slow
There is a question that has a very similar title (cbind runs very slow) but it does not help me with my problem. I am retrieving 10+ JSON files with 100 variables each and I try to create one big data.frame/table with 1000 columns. In practice, I…

Gecko
- 354
- 1
- 10
1
vote
1 answer
Merging data frames of different lengths without unique keys
I am trying to merge two data frames of different lengths without using a unique key.
For example:
Name <- c("Steve","Peter")
Age <- c(10,20)
df1 <- data.frame(Name,Age)
> df1
Name Age
1 Steve 10
2 Peter 20
Name <-c("Jason","Nelson")
School…

Steviee kann
- 35
- 3
1
vote
2 answers
How to append a list of arrays onto a list of dataframes in R
I have the following list.
df1 <- data.frame(a = rnorm(10), b = rnorm(10), vector = 1)
df2 <- data.frame(a = rnorm(10), b = rnorm(10), vector = 2)
df3 <- data.frame(a = rnorm(10), b = rnorm(10), vector = 3)
df4 <- data.frame(a = rnorm(10), b =…

useryk
- 309
- 2
- 10
1
vote
1 answer
Snakemake doesn't read full file in R?
I'm using some quick R script to cbind files after performing quantification (kallisto/salmon).
The problem is, I get an R error, saying my input files aren't the same length so cbind() won't work.
This is obviously not the case, they all are 16887…

Exenter
- 23
- 6
1
vote
2 answers
iterating table() results into matrix/data frame
This must be simple but I'm banging my head against it for a while. Please help. I have a large data set from which I get all kinds of information via table(). I then want to store these counts, with the rownames that were counted. For a…

ShouldaKnownThis
- 49
- 4
1
vote
3 answers
How can I append my dataframe to itself (cbind) a given number of times? in R
I am basically trying to produce a REALLY large dataset for testing purposes, and I have an example dataset with 600,000 rows.
I want to append this df to itself n times, how would I do this?
I could cbind it to itself multiple times manually, but…

theprotagonist
- 21
- 3
1
vote
3 answers
R: is there a way to cbind non-numeric columns
library(Rmpfr)
mynumber <- new("mpfr", .Data = list(new("mpfr1", prec = 50L, exp = c(1045L,
0L), sign = 1L, d = c(151748608L, -358118319L)), new("mpfr1",
prec = 50L, exp = c(20L, 0L), sign = 1L, d = c(-1114947584L,
-1905679017L)),…

Adrian
- 9,229
- 24
- 74
- 132
1
vote
2 answers
how to cbind many data-frames?
I have 247 data frames which are sequentially named (y1, y2, y3, ...., y247). They are resulted from the following code:
for (i in (1:247)) {
nam <- paste("y", i, sep = "")
assign(nam, dairy[dairy$FARM==i,"YIT"])
}
I wish to cbind all of them…

S. Abbas S. Salehi
- 11
- 2