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
R Create dummy datasets based on reference dataset
Context
I'd like to build a two dummy survey dataframes for a project. One dataframe has responses to a Relationship survey, and another to aPulse survey.
Here are what each look like -
Relationship Dataframe
#Relationship Data
rel_data=…

Varun
- 1,211
- 1
- 14
- 31
1
vote
1 answer
Change all R columns names using a reference file
I am trying to rename columns in a dataframe in R. However, the renaming has circular referencing. I would like a solution to this problem, the circular referencing cannot be avoided. One way to think was to rename a column and move it to a new…

Bruce Wayne
- 471
- 5
- 18
1
vote
2 answers
Assign the results of do.call using cbind to data frames
I want to combine multiple sets of two data frames (a & a_1, b & b_1, etc.). Basically, I want to do what this question is asking. I created a list of my two data sets:
# create data
a <- c(1, 2, 3)
b <- c(2, 3, 4)
at0H0 <- data.frame(a, b)
c <-…

Lisa
- 909
- 2
- 13
- 31
1
vote
1 answer
Calculations across more than two different dataframes in R
I'm trying to transfer some work previously done in Excel into R. All I need to do is transform two basic count_if formulae into readable R script. In Excel, I would use three tables and calculate across those using 'point-and-click' methods, but…

Pryore
- 510
- 9
- 22
1
vote
1 answer
Problems with binding columns from two data frames using a for loop in R
I have 7 of two different asc files loaded into R, asc[i] and wasc[i], [i] denotes that there are 1:7 ascs and wascs loaded into R. I need to combine the wasc[i] with the asc[i][[1]] (Just the first column in asc[i] with the whole wasc[i] file).…

Connor Murray
- 313
- 3
- 12
1
vote
1 answer
distributing data.frame data across multiple rows in r
I'm using R 3.5.1
I think this is a simple issue, but I'm not super familiar with R.
I have a data.frame object that looks like this
COL1 COL2 COL3
A blah 3
A abc 4
A def 42
B xyz 10
B aaa 3
C pdq 19
I want to…

pdanese
- 2,187
- 4
- 15
- 21
1
vote
1 answer
cbind new column based on values
My data is:
try<-data.frame(Gender=c("Male","Male","Female","Male","Female","Male","Female","Female","Male","Male", "Female","Male","Male","Male", "Male"),
Est=c(0.9956, 1.035, 2.0731, 0.0824, 3.0987, 5.0982, 6.0707, 5.0393, 2.7046,…

mojek
- 195
- 1
- 9
1
vote
1 answer
Combine multiple dataframes of unequal length into a new dataframe
I want to combine multiple dataframes of unequal length into a new dataframe that has NA values for empty rows.
e.g. df1
A
1
2
3
4
5
df2
B
1
2
3
4
5
6
Desired output
df3
A B
1 1
2 2
3 3
4 4
5 5
NA 6
I tired a cbind() but that gives me an…

Rn00b
- 11
- 2
1
vote
0 answers
data.table() gives spurious results depending on column order
I created a ten-row dataframe, then converted it to a datatable. I created it again with a different order of columns. When I converted it to datatable, the result was spurious.
c <- pi
e <- paste("lotsa text, line", as.character(1:10))
…

Robert Hadow
- 457
- 4
- 15
1
vote
2 answers
Alternative in R to cbind loop when final size unknown
I need to calculate for each element of my list all the combination of the elements inside and stock all the combination ( b in the example).
I am currently doing like in my example but for a bigger list it is really slow because of the use of cbind…

Rona
- 97
- 8
1
vote
1 answer
How do we arrange two sets of data according to a specific criteria, eg date, in R
This is regarding data manipulation and cleaning in R.
I have dataset 1:
Date time Range Waterconsumption
1/1/01 0300 31km 2.0liters
2/1/01 0800 30km 1.8liters
3/1/01 0300 33km 1.7liters
4/1/01 0600 32km 1.8liters
5/1/01 0800 28km …

MT32
- 677
- 1
- 11
- 24
1
vote
1 answer
R: Transforming (n*P) * N data frame into n * (N*P)
I'm using R and I have a data frame called df which has (n*P) rows and N columns.
C1 C2 ... CN-1 CN
1-1 100 36 ... 136 76
1-2 120 -33 ... 87 42
1-3 150 14 ... 164 24
:
1-n 20 36 ... 136 76
2-1 …

Makoto Miyazaki
- 1,743
- 2
- 23
- 39
1
vote
2 answers
Multiple Variable Values to Function and Cbind Results
This is a continuation of this question here:
For-Loop By Columns with existing For-loop by Rows
I have a dataset in which I am using 3 variables:
adstock_rate, diminishing_rate, and lag_number
.
These are currently set to only 1 number each.…

nak5120
- 4,089
- 4
- 35
- 94
1
vote
1 answer
merging columns using cbind in R
Here is my code
library(readxl)
library(dplyr)
library(rowr)
filenames = list.files(pattern="*.xlsx")
readdata <- function(filename) {
df <- read_excel(filename)
vec <- select(df, ends_with("Course total (Letter)"))
return(vec)
}
result…

Manoj
- 101
- 2
- 9
1
vote
0 answers
Combine equal length vectors from a list in R
I have a list with different vector length:
[[1]]
X1 X2
"N" "N"
[[2]]
X1 X2
"N" "C"
[[3]]
X1 X2
"S" "S"
[[4]]
X1 X2 X3
"S" "S" "U"
[[5]]
NULL
[[6]]
X1 X2
"S" "N"
[[7]]
X1 X2 X3
"S" "S" "S"
[[8]]
X1 X2
"S" "N"…