1

I'm new to R so this probably has a simple solution, but I can't find it. I have two datasets:

Dataset 1:

A B C
1 2 3

Dataset 2:

X Y Z
4 5 6

and I want to get

A B C X Y Z
1 2 3 4 5 6

The dataset is just one row each.

Darren Tsai
  • 32,117
  • 5
  • 21
  • 51

2 Answers2

1

Just use cbind:

cbind(dataset1, dataset2)

For your next questions, please create reproducible examples using dput for example. Posting data in the form of images or tables isn't very useful.

You can use CTRL+K to format text as code sample when writing a question on SO.

gaut
  • 5,771
  • 1
  • 14
  • 45
0

You could also use the merge() function:

merge(x, y, by = intersect(names(x), names(y)),
  by.x = by, by.y = by,
  sort = TRUE, …)

This would be more useful when you are combining more complex data.frames but it can be useful to learn it early.

You can look and see how it works in more details as follows; ?merge