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
2
votes
1 answer
Counting the occurences of a string in dataframe row
I have a data frame (named as df) of 144 columns (trial numbers) containing the information about the trial success (Yes/No) per participant (the rows). A subset would look like this:
V1 V2 V3 V4 V5
Yes No Yes Yes …

e. erhan
- 61
- 6
2
votes
1 answer
Add columns to specific rows in a list of data frames from a data frame in R
I want to add two columns next to the headers of the list mentioned below (except the 1st data frame).
Structure of the list of data frames multidf where I want to add the columns
structure(list(`0` = structure(list(X01.04.2020 = 0:1, Asset =…

Abhik Paul
- 39
- 1
- 9
2
votes
3 answers
How do I move the bottom half of a column's values into a newly created column?
I have a column that contains means of three different measurements in the first 50% of rows, and the associated standard errors in the last 50% of rows. In the previous column are the names used for each of those (meanNativeSR, meanExoticSR,…

E. Moore
- 321
- 1
- 5
- 11
2
votes
1 answer
Putting several rows into one column in R
I am trying to run a time series analysis on the following data set:
Year 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780
Number 101 82 66 35 31 7 20 92 154 125
Year 1781 1782 1783 …

Chesso
- 167
- 8
2
votes
1 answer
How to add put together a single dataframe from a list of dataframes
I have a list of dataframes that I want to put columns together.
To illustrate here's a dummy set:
Data1 <- data.frame(A = c(1, 2, 3, 4, 5),
B = c(2, 3, 5, 3, 10))
Data2 <- data.frame(A = c(1, 2, 3, 4, 6),
C…

Drew
- 563
- 2
- 8
2
votes
0 answers
R: inconsistent behaviour when adding numbers in matrices
I am trying to solve an exercise on Fibonacci sequences in R. The crux is that the animals are mortal.
Goal is to enter 3 variables (life span, overall duration, number of offspring). The animals need 1 time unit to mature. To solve this, I create a…

Vi Hammer
- 21
- 3
2
votes
3 answers
Bind vector with list of vectors using cbind
I have an original data.frame and I would like to run lapply on certain columns then cbind the remaining columns with the results from the lapply operation.
See code below. I would ideally like b to contain the first id column from the data.frame…

Prevost
- 677
- 5
- 20
2
votes
1 answer
Output only show number of element in a list
I have vectors of time, status and gender and would like to do a Survival Analysis:
time <- c(306,455,1010,210,883,1022,310,361,218,166)
status <- c(0,1,0,1,0,0,1,0,1,1)
gender <-…

mojek
- 195
- 1
- 9
2
votes
2 answers
Equivalent of R cbind() function in Oracle?
I am new to sql and struggling to solve this very simple task.
Considering,
with table1 as (select '1' col1 from dual union
select '2' col1 from dual union
select 'NO_PATTERN' col1 from dual union
select 'RANDOM_STUFF' col1 from dual)
select…

Seymour
- 3,104
- 2
- 22
- 46
2
votes
2 answers
Homogenize time series type, frequency and length
I am trying to bind together a number of variables that I created previously. Nevertheless, the starting and ending dates of the time-series are not equal amongst the variables. The way I am trying to do so is via:
data.start <- c(1960,1)
data.end…

Sean
- 35
- 8
2
votes
2 answers
R: Binding columns by key variable
I want to combine two dataframes, df1 and df2, by different groups of a key variable in x1. It is basically some join operation, however, I do not want the rows to duplicate and do not care about the relationship among the added columns.
Assume:…

Fabian H
- 21
- 1
2
votes
2 answers
How to cbind and rbind 2 lists of dataframes
I have 2 lists of dataframes. Each list has 24 dataframes
list1 <- (data1, data2, ..., data24)
list2 <- (result1, result2, ...., result3)
I want to cbind data1 with result1, data2 with result2 and so on. Then rbind all dataframes together like…

Thuong Tra
- 19
- 3
2
votes
1 answer
Match Columns with rows and subtract from columns
my data looks like:
>dput(mea)
>structure(list(mea = c(NA, NA, NA, NA, 7.5, 19.5)), .Names = "mea",
row.names = c(NA,-6L), class = "data.frame")
and
>dput(m1)
>structure(list(t = c(5e-04, 0.001, 0.0015, 0.002, 0.0025,…

Chris
- 55
- 8
2
votes
1 answer
How to bind columns in high dimensional arrays following a specific order?
I have two high dimensional arrays, both with 1000 rows, 3 columns, 10 slices and 4 groups of slices.
I want to bind them but matching the columns between them. Example below:
#dumb data
array1 <- array(1:4, dim = c(2,1,2,2),dimnames =…

Oscar L
- 35
- 6
2
votes
2 answers
R's cbind functionality in Spark Scala
I have a requirement to cbind [as it happens in R] two dataframes in spark using scala, which do not have a ID column.
Any pointers on any readily available function for it, or some other workaround for it?
Example:
DF1:
Name Age
ABC 10
…

Sourajyoti Datta
- 61
- 1
- 8