Extracting the data points of a subset from a larger data set.

Hello R community,

I have a big data set where i've calculated social relationship stengths (DCSI's) that monkey's have with their various partners. I created a subset that contains a monkey's top 3 partners in terms of relationship strength for a given year.
So now I want to extract the DCSI's that these "top partners" have on years when they didn't make it into the top 3.
So the key variables here are monkey.id and partner.id. I have a large data set that contains relationship strengths to all partners in all years. My subset just contains the top 3 partners DCSI's for each year. But social partners vary each year, and I want to extract any "top partners" DCSI score in years when it didn't make the top 3.
What I want to do is get the DCSI scores for any partner that was ranked in the top 3 on years when they weren't ranked in the top 3.

Here is a dput of my subset:
Df1 <- structure(list(data.year = c(2010L, 2010L, 2010L, 2010L, 2010L,
2010L, 2010L, 2010L, 2010L, 2010L, 2010L, 2010L, 2010L, 2010L,
2010L, 2010L, 2010L, 2010L, 2010L, 2010L, 2010L, 2010L, 2010L,
2010L, 2010L, 2010L, 2010L, 2010L, 2010L, 2010L, 2010L, 2010L,
2010L, 2010L, 2010L, 2010L, 2010L, 2010L, 2010L, 2010L, 2010L,
2010L, 2010L, 2010L, 2010L, 2010L, 2010L, 2010L, 2010L, 2010L,
2010L, 2010L, 2010L, 2010L, 2010L, 2010L, 2010L, 2010L, 2010L,
2010L, 2010L, 2010L, 2010L, 2010L, 2010L, 2010L, 2010L, 2010L,
2010L, 2010L, 2010L, 2010L, 2010L, 2010L, 2010L, 2010L, 2010L,
2010L, 2010L, 2010L, 2010L, 2010L, 2010L, 2010L, 2010L, 2010L,
2010L, 2010L, 2010L, 2010L, 2010L, 2010L, 2010L, 2010L, 2010L,
2010L, 2010L, 2010L, 2010L, 2010L, 2010L, 2010L, 2010L, 2010L,
2010L, 2010L, 2010L, 2010L, 2010L, 2010L, 2010L, 2010L, 2010L,
2010L, 2010L, 2010L, 2010L, 2010L, 2010L, 2010L, 2010L, 2010L,
2010L, 2010L, 2010L, 2010L, 2010L, 2010L, 2010L, 2010L, 2010L,
2010L, 2010L, 2010L, 2011L, 2011L, 2011L, 2011L, 2011L, 2011L,
2011L, 2011L, 2011L, 2011L, 2011L, 2011L, 2011L, 2011L, 2011L,
2011L), current.group = c("F", "F", "F", "F", "F", "F", "F",
"F", "F", "F", "F", "F", "F", "F", "F", "F", "F", "F", "F", "F",
"F", "F", "F", "F", "F", "F", "F", "F", "F", "F", "F", "F", "F",
"F", "F", "F", "F", "F", "F", "F", "F", "F", "F", "F", "F", "F",
"F", "F", "F", "F", "F", "F", "F", "F", "F", "F", "F", "F", "F",
"F", "F", "F", "F", "F", "F", "F", "F", "F", "F", "F", "F", "F",
"F", "F", "F", "F", "F", "F", "F", "F", "F", "F", "F", "F", "F",
"F", "F", "F", "F", "F", "F", "F", "F", "F", "F", "F", "F", "F",
"F", "F", "F", "F", "F", "F", "F", "F", "F", "F", "F", "F", "F",
"F", "F", "F", "F", "F", "F", "F", "F", "F", "F", "F", "F", "F",
"F", "F", "F", "F", "F", "F", "F", "F", "F", "F", "F", "F", "F",
"F", "F", "F", "F", "F", "F", "F", "F", "F", "F", "F", "F", "F"
), monkey.id = c("00J", "00O", "00O", "03J", "03J", "04N", "10S",
"10S", "10S", "14I", "14I", "14L", "14L", "14L", "20F", "20F",
"20F", "24B", "24B", "24B", "28J", "28J", "28J", "28N", "28N",
"29B", "29B", "29B", "29Z", "29Z", "29Z", "32S", "32S", "32S",
"34N", "34N", "35N", "35N", "35N", "36Z", "40L", "40L", "40L",
"42L", "42L", "43F", "43F", "43J", "43J", "43J", "44J", "44J",
"44J", "50I", "50I", "50I", "50S", "50S", "50S", "52P", "52P",
"55V", "55V", "56A", "56A", "56A", "56E", "56E", "56E", "57H",
"57H", "57H", "59A", "59A", "59A", "60P", "60P", "61J", "61J",
"62H", "62H", "62H", "63V", "63V", "63V", "64D", "64D", "64D",
"64P", "64P", "64P", "68J", "68J", "68J", "68V", "68V", "73B",
"73B", "73B", "74S", "74S", "78T", "78T", "79C", "79C", "79C",
"82A", "82A", "82A", "82L", "82L", "82L", "87K", "87K", "88I",
"90D", "90D", "92D", "92D", "98T", "K00", "N12", "O52", "O52",
"R65", "R65", "V36", "V36", "V36", "X44", "X44", "X44", "Z14",
"Z14", "00J", "00J", "00O", "03J", "03J", "04N", "0A4", "0A4",
"0A9", "0A9", "10S", "10S", "14I", "14I", "14L", "14L"), partner.id = c("63V",
"44J", "55V", "62V", "00J", "24B", "14L", "64P", "68V", "29Z",
"V36", "17C", "68V", "10S", "73B", "87K", "X44", "28J", "59A",
"04N", "R65", "V36", "24B", "61J", "00O", "68J", "R65", "24B",
"56A", "68V", "14I", "44J", "82L", "90D", "60P", "92D", "43F",
"73B", "78T", "42L", "52P", "57H", "X44", "61J", "82L", "17C",
"35N", "73B", "R65", "10S", "68J", "00O", "32S", "61J", "63V",
"64P", "Z14", "00J", "40L", "68V", "40L", "61J", "00O", "14I",
"14L", "29Z", "73B", "98T", "V36", "61J", "82L", "Z14", "61J",
"O52", "24B", "68J", "14I", "28N", "50I", "73B", "79C", "K00",
"00J", "50I", "61J", "X44", "14I", "50I", "04N", "10S", "50I",
"29B", "44J", "60P", "10S", "14L", "90D", "35N", "56E", "78T",
"50I", "35N", "56A", "88I", "O52", "62H", "04N", "28J", "57H",
"98T", "57H", "73B", "20F", "43F", "79C", "73B", "79C", "34N",
"35N", "68V", "62H", "04N", "73B", "79C", "28J", "43J", "14I",
"28J", "56E", "20F", "40L", "64D", "57H", "V36", "0A9", "93Z",
"24B", "56A", "00J", "60P", "2A8", "44J", "74S", "93Z", "82L",
"9A4", "29Z", "82A", "29Z", "14I"), DCSI = c(15.0677748544049,
13.3320473141112, 12.270117025579, 3.99126543701154, 1.27636402820631,
7.72561755609198, 18.5164970827263, 17.3079133497021, 15.9792558738643,
13.8380007377055, 15.9123236938435, 14.3415425751191, 16.1986973817819,
18.5164970827263, 9.98514990362561, 1.50262012004116, 7.7992982116322,
22.3682681174399, 7.13866339491725, 7.72561755609198, 13.4544300037771,
14.3448974849627, 22.3682681174399, 16.7837601437734, 1.37884581149295,
4.35697906987097, 2.71801260682784, 2.48555100229651, 15.4651184179358,
7.53176073175261, 13.8380007377055, 3.82909208461894, 2.02394867329858,
1.98148821162099, 2.50201160496072, 5.37841099015538, 5.40235661484879,
18.7296619889796, 6.86706930169635, 0.72099952738372, 2.26936810776144,
4.97060403998144, 3.37324778883097, 1.71728978340486, 0.814232224890235,
4.984040705468, 5.40235661484879, 2.79854631369681, 18.8062144201,
2.09890973527261, 5.16837014940364, 13.3320473141112, 3.82909208461894,
17.4189667067285, 11.5572363008409, 13.8482513418538, 2.14661222925607,
1.9407727004233, 1.99544235395635, 4.51210431137557, 2.26936810776144,
4.87084700908312, 12.270117025579, 4.84363785062909, 11.462523146151,
15.4651184179358, 16.7231608884045, 5.67279712908673, 11.9149284488392,
10.4977820005141, 5.8478010527339, 17.2789259582361, 3.75811702903592,
2.73770835035557, 7.13866339491725, 5.48793052704293, 5.55273661588256,
16.7837601437734, 17.4189667067285, 2.23112452174647, 6.10098435654502,
17.2035453114027, 15.0677748544049, 11.5572363008409, 9.21313423744556,
4.72788504349495, 2.6976446731997, 9.31166080227815, 4.44122437729498,
17.3079133497021, 13.8482513418538, 4.35697906987097, 5.16837014940364,
5.48793052704293, 15.9792558738643, 16.1986973817819, 16.3209829608227,
18.7296619889796, 16.7231608884045, 2.02394867329858, 4.53500839417443,
6.86706930169635, 2.64198428216132, 4.75652206194871, 20.201319683407,
6.10098435654502, 1.81636419398591, 1.83926827678477, 1.33029490263757,
2.81943098767962, 5.8478010527339, 5.4600296044183, 1.50262012004116,
2.25845485240357, 4.75652206194871, 16.3209829608227, 2.81943098767962,
5.37841099015538, 5.2311128713947, 12.1088443955666, 17.2035453114027,
2.42181892531455, 4.13653743447886, 20.201319683407, 13.4544300037771,
18.8062144201, 15.9123236938435, 14.3448974849627, 11.9149284488392,
7.7992982116322, 3.37324778883097, 4.72788504349495, 17.2789259582361,
4.53130153706149, 6.32043755387507, 8.67323080301252, 9.29831854141018,
1.81405795692455, 4.84609324629493, 20.7845207484546, 4.22796779715572,
1.53518658446358, 10.5990048133538, 13.5093808978621, 13.6435302777284,
8.10429734567583, 17.4180195478466, 11.7116658395431, 11.3098461021942,
8.00335433765446), partner.rank = c(1L, 2L, 3L, 2L, 3L, 3L, 1L,
2L, 3L, 3L, 2L, 3L, 2L, 1L, 1L, 3L, 2L, 1L, 3L, 2L, 3L, 2L, 1L,
1L, 3L, 1L, 2L, 3L, 1L, 3L, 2L, 1L, 2L, 3L, 3L, 2L, 3L, 1L, 2L,
3L, 3L, 1L, 2L, 2L, 3L, 2L, 1L, 2L, 1L, 3L, 2L, 1L, 3L, 1L, 3L,
2L, 1L, 3L, 2L, 2L, 3L, 3L, 1L, 3L, 2L, 1L, 1L, 3L, 2L, 2L, 3L,
1L, 2L, 3L, 1L, 3L, 2L, 2L, 1L, 3L, 2L, 1L, 1L, 2L, 3L, 2L, 3L,
1L, 3L, 1L, 2L, 3L, 2L, 1L, 3L, 2L, 3L, 1L, 2L, 3L, 2L, 2L, 3L,
3L, 1L, 2L, 2L, 1L, 3L, 3L, 1L, 2L, 3L, 2L, 2L, 2L, 3L, 2L, 3L,
3L, 2L, 3L, 3L, 2L, 3L, 2L, 1L, 2L, 3L, 1L, 3L, 2L, 1L, 2L, 3L,
2L, 3L, 3L, 2L, 3L, 2L, 3L, 3L, 2L, 1L, 3L, 2L, 3L, 2L, 3L)), row.names = c(NA,
-150L), class = c("tbl_df", "tbl", "data.frame"))

I'm not sure i've explained very well. So say for example in the very first row, monkey 00J. In the year 2010, it had a strong social relationship with 63V (it was its number 1 ranked partner in terms of DCSI score for that year). You'll notice that in the year 2011, 63V does not feature as a top 3 ranked partner of 00J.
In my large data set I have the DCSI score that 00J and 63V have for 2011. I want to find a way to extract this data. And do this for any partner that was a top 3 for any monkey in my subset. I want the DCSI scores for years in which they weren't ranked.

Any ideas would be greatly appreciated.

Have decided to scrap the idea, its not tenable. Thanks for looking.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.