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
Merge, cbind: How to merge better?
I want to merge multiple vectors to a data frame. There are two variables, city and id that are going to be used for matching vectors to data frame.
df <- data.frame(array(NA, dim =c(10*50, 2)))
names(df)<-c("city", "id")
df[,1]<-rep(1:50,…

user3077008
- 837
- 4
- 13
- 24
1
vote
0 answers
Fill Dataframe with complete row outputs
Im a bit stuck with a similar question to this one:
Fill and empty data frame in R.
I have a very large output from various parts of my model which are run on for loops. The output is summarized in a single row with the relevant values.…

I Del Toro
- 913
- 4
- 15
- 36
1
vote
1 answer
Combine two data frames to put identical rows adjacent
I have to matrices (or data frames) that contain the same column and rownames.
The rownames of matrix 1 has an ID called dataTissue, the rownames of matrix 2 has the ID dataSerum. I would like to combine the two matrices where identical rows are…

user2300940
- 2,355
- 1
- 22
- 35
1
vote
1 answer
Merging/combining specific columns from separate data frames or objects within a list
I have been searching in vain to find a solution to efficiently combine specific columns from separate data frames or from separate objects within the same list into new data frames. I have 5 data frames that all have the same row names (e.g. x, y,…

zc1
- 13
- 4
1
vote
1 answer
R: dynamic column name in for loop with cbind at each step
My code is:
N = 4;
pred_sales_mean <- c(Q1 = 11000, Q2 = 15000, Q3 = 16000, Q4 = 11000)
pred_sales_sd <- c(Q1 = 3000, Q2 = 4000, Q3 = 5000, Q4 = 3000)
pred_sales <- rbind(mean = pred_sales_mean, sd = pred_sales_sd)
sales <- vector()
for (q in…

Nikolay Petrov
- 188
- 2
- 6
1
vote
2 answers
How to cbind data.frames with differing lengths without knowing the lengths of the data.frames
I am hoping to find a way to cbind data.frames with differing lengths, but I want to cbind the data.frames without having to specify the lengths. As the lengths of the data.frames I will be working with will vary I do not want to find the lengths…

Dre
- 713
- 1
- 8
- 27
1
vote
2 answers
combining column variables with same values into a new variable
dataset being used is in this google sheets link
https://docs.google.com/spreadsheets/d/1eV33Sgx_UVtk2vDtNBc4Yqs_kQoeffY0oj5gSCq9rCs/edit?usp=sharing
AMC.dataset$ExamMC.A<-surveySP15$Exams_A
AMC.dataset$ExamMC.A<-factor(NA, levels=c("TRUE",…

Christopher Hahn
- 13
- 3
1
vote
1 answer
Combining columns from several Excel files, in a specific order
I have 12 Excel files, each of them having 6 columns, 259 rows. Everything is numbers, no text. I have to make a table of 72 columns and 259 rows, combining the 12 files respecting this rule:
The first column should be:
file 1 column 1, file 2…

Elizapascu
- 13
- 5
1
vote
1 answer
How to combine columns in a data frame so that they overlap in R?
Basically, I have data from a between subjects study design that looks like this:
> head(have, 3)
A B C
1 b
2 a
3 c
Here, A, B, C are various conditions of the study, so…

rhonda
- 13
- 3
1
vote
2 answers
How to intersect values from two data frames with R
I would like to create a new column for a data frame with values from the intersection of a row and a column.
I have a data.frame called "time":
q 1 2 3 4 5
a 1 13 43 5 3
b 2 21 12 3353 34
c 3 21 312 123 343
d 4…

Fernando Anselmo
- 19
- 4
1
vote
1 answer
R: Errors in cbind() with kclass() function and missing values in data frame
I have a problem using the kclass() function of the RCompAngrist package when i have missing values in my df. It's a function that is supposed to calculate a "limited information maximum likelihood" estimator with a dependent variable on the left…

avocado1
- 253
- 2
- 8
1
vote
2 answers
Combining Tables In R
UPDATED
I encountered a problem while trying to perform a simple table merging task in R. I'm looking for why this happened and, if it exists, a more elegant solution. Below is the exact data I'm working with and what happened.
I have two tables…

tom
- 977
- 3
- 14
- 30
1
vote
2 answers
cbind values to sublists in R
I have two matrices in a list:
colList <- list()
colList[["V1"]] <- as.matrix(c("asd", "asd", "asd"))
colList[["V2"]] <- as.matrix(c("das", "das", "das"))
And I want to cbind the values of a data.frame value.frame$keyID to each sublist. The first…

OAM
- 179
- 1
- 14
1
vote
1 answer
R: aggregate several colums at once
I am new to R and this is the first time I use stackoverflow so excuse me if I ask for something obvious or my question is not clear enough.
I am working with the following data set
dim(storm)
[1] 883602 39
names(storm)
[1] "STATE__" …

miguel cuenca
- 13
- 2
1
vote
1 answer
Use Final Value In Iterative Process
Here is the code that I am working with:
## Round 1
b <- c(5000,2500)
r <- c(2,2.1)
pm <- c(200,240)
I <- b*(r/1200)
pi <- pm-I
end <- b-pi
end
## Round 2
b1 <- end
r1 <- (2.3,2.3)
I1 <- b1*(r/1200)
pi1 <- pm-I1
end1 <- b1-pi1
end1
This…

Adam Warner
- 1,334
- 2
- 14
- 30