r - Select rows satisfying condition on two variables jointly in dplyr -
i have 2 dataset, big_table
, small_table
big_table = structure(list(fxw = structure(c(7l, 8l, 3l, 7l, 7l, 1l, 6l, 1l, 3l, 2l, 6l, 5l, 3l, 3l, 7l, 5l, 2l, 3l, 2l, 6l, 5l, 1l, 6l, 2l, 4l, 8l, 3l, 1l, 7l, 5l, 3l, 2l, 2l, 2l, 1l, 2l, 1l, 5l, 4l, 1l, 4l, 6l, 3l, 3l, 5l, 3l, 8l, 3l, 8l, 1l, 2l, 1l, 8l, 1l, 6l, 3l, 5l, 2l, 6l, 7l, 6l, 8l, 6l, 8l, 4l, 1l, 6l, 7l, 7l, 1l, 2l, 4l, 4l, 6l, 1l, 4l, 1l, 1l, 2l, 4l, 2l, 7l, 4l, 6l, 7l, 2l, 2l, 1l, 2l, 7l, 5l, 2l, 2l, 8l, 1l, 2l, 5l, 2l, 8l, 2l), .label = c("aa", "af", "ag", "ah", "ai", "bg", "eh", "ff"), class = "factor"), cp = c("cad/aoa", "chf/aud", "cad/ats", "usd/cdf", "jpy/cdf", "eur/aud", "jpy/cny", "eur/aoa", "chf/cdf", "cad/cdf", "usd/cny", "eur/aud", "jpy/aud", "usd/cdf", "jpy/ats", "jpy/cdf", "cad/cny", "gbp/ats", "chf/aoa", "gbp/aud", "usd/cny", "jpy/cdf", "chf/aoa", "gbp/ats", "eur/aud", "gbp/bdt", "eur/aoa", "gbp/ats", "jpy/cny", "cad/ats", "cad/cny", "chf/cdf", "eur/cny", "jpy/bdt", "gbp/bdt", "eur/aud", "cad/cdf", "cad/ats", "gbp/ats", "eur/aud", "jpy/ats", "gbp/bdt", "eur/ats", "cad/cny", "chf/aud", "chf/cdf", "cad/ats", "cad/cdf", "cad/cny", "jpy/cdf", "jpy/bdt", "usd/bdt", "eur/cny", "chf/cdf", "gbp/cny", "chf/cny", "chf/cdf", "chf/aud", "cad/aud", "gbp/ats", "chf/bdt", "jpy/aud", "chf/bdt", "cad/bdt", "chf/aud", "cad/ats", "cad/cny", "cad/ats", "jpy/bdt", "gbp/cny", "gbp/aud", "usd/aoa", "usd/aoa", "gbp/aoa", "gbp/aoa", "eur/cny", "cad/cny", "jpy/cdf", "chf/cny", "cad/bdt", "usd/cny", "chf/aoa", "gbp/aud", "usd/aud", "chf/bdt", "jpy/ats", "jpy/ats", "gbp/bdt", "jpy/aoa", "jpy/aud", "gbp/cdf", "chf/cdf", "usd/ats", "chf/cny", "chf/bdt", "cad/ats", "eur/aud", "chf/cdf", "jpy/bdt", "gbp/aud")), .names = c("fxw", "cp"), row.names = c(na, -100l), class = c("tbl_df", "tbl", "data.frame" )) small_table = structure(list(swh = structure(c(8l, 7l, 1l, 5l, 3l, 7l, 8l, 6l, 6l, 4l), .label = c("aa", "af", "ag", "ah", "ai", "bg", "eh", "ff"), class = "factor"), scp = structure(c(5l, 23l, 19l, 36l, 12l, 28l, 14l, 7l, 10l, 21l), .label = c("cad/aoa", "cad/ats", "cad/aud", "cad/bdt", "cad/cdf", "cad/cny", "chf/aoa", "chf/ats", "chf/aud", "chf/bdt", "chf/cdf", "chf/cny", "eur/aoa", "eur/ats", "eur/aud", "eur/bdt", "eur/cdf", "eur/cny", "gbp/aoa", "gbp/ats", "gbp/aud", "gbp/bdt", "gbp/cdf", "gbp/cny", "jpy/aoa", "jpy/ats", "jpy/aud", "jpy/bdt", "jpy/cdf", "jpy/cny", "usd/aoa", "usd/ats", "usd/aud", "usd/bdt", "usd/cdf", "usd/cny"), class = "factor")), .names = c("swh", "scp"), row.names = c(256l, 238l, 19l, 179l, 83l, 243l, 265l, 186l, 189l, 128l), class = "data.frame")
i trying use dplyr
select subset of rows of big_table
pairs (big_table$fxw, big_table$cp)
in (small_table$swh, small_table$scp)
jointly.
we can inner_join
inner_join(big_table, small_table, = c(fxw = "swh", cp = "scp"))
Comments
Post a Comment