0

I'm new to R and I'm struggling with some datasets....

I have two datasets - dataset A includes x(depth) and y(concentration) and dataset B includes x(depth) and y(age).

In dataset A, my depth is evenly spread out, such as

Depth(cm) Concentration(ppm)

    1    100
    2    110
    3    112
    4    95
    5    29
    6    40
    7    20
    8    114
    9    92
    10   93

and so on.

But in my dataset B, my depth is spaced out irregularly, such as

Depth (cm) Age(year)

    1    10
    3    19
    7    32

In this case, would it be possible to extract columns with depths of dataset B (at 1, 3, 7cm) from dataset A, so that I'll get something like below as a result?

Depth (cm) Concentration (ppm)

    1    100
    3    112
    7    20
Jaap
  • 81,064
  • 34
  • 182
  • 193
Jen
  • 331
  • 2
  • 11
  • The question on the link above is basically the same but I can't figure out how to actually work this out... df1 <- data.frame(A=sample(1:10, 10), B=sample(1:10, 10)) Here, how am I supposed to pull A and B out from my data columns instead of random sampling numbers? @josliber – Jen Feb 13 '16 at 13:44
  • `A[A$Depth %in% B$Depth,]` – josliber Feb 13 '16 at 14:25

0 Answers0