ASchnur
ASchnur

Reputation: 13

Adding second set of points to pairs2 plots

I’m hoping that there is a simple answer to this question - is there a way to plot a second set of points on top of pairs2 plots, from a second dataframe?

This question was somewhat answered here using the pairs function and kmeans for defining centerpoints, but I am attempting to do the same thing using the pairs2 function (I have 8 variables that I am posing against each other, showing part of 4 here for simplicity) and pre-defined centerpoints (contained in a second dataframe that has many less rows than the dataframe with the initial variables) that will change based on the two variables that are used in each plot.

df1 <- data.frame(
  TM = c(25.1889,24.1304,24.0604,23.9402,23.7745,23.6654,23.6645,22.8439,21.3716,21.4657,21.2049,17.3545,17.7282,17.4494,12.2787,12.2857,13.1354,8.2202,8.2664,8.6777,6.2524,6.213,6.2178,5.836,5.6775,5.1592,5.0871,5.169,4.1378,4.1378,4.1187,3.2187,3.2187,3.2308,2.568),
  SAM = c(36.1452,35.8868,35.8872,35.874,35.9173,35.9898,36.0154,36.053,35.8427,35.8532,35.829,35.3498,35.4001,35.3643,34.7479,34.7496,34.8415,34.4096,34.4138,34.4416,34.3268,34.3289,34.329,34.3271,34.3303,34.3649,34.3747,34.3936,34.4629,34.4629,34.4649,34.527,34.527,34.5264,34.5909),
  OY = c(206.2866,212.5171,207.3589,205.7436,202.1023,192.1531,190.6164,179.7472,178.2853,176.2884,176.5031,187.4516,183.8077,184.0845,183.0525,179.0316,179.9783,189.5713,185.268,181.5232,206.1538,201.0054,200.9562,200.0553,193.3422,174.8636,169.43,161.9325,149.089,149.089,150.2571,148.2609,148.2609,149.8462,145.8923),
  SIL = c(0.478441942,0.576011972,0.380745706,0.380736114,0.575939073,0.478281445,0.478272244,0.47814645,1.141410862,0.575593193,0.575563169,1.335656023,1.043229301,1.14068256,4.667007731,4.569575097,3.71251671,1.042085277,9.320365185,8.950634348,13.98250042,14.65426647,14.37189781,17.69141471,20.07645471,31.58209857,33.00297051,35.30033062,57.66252594,57.08823677,57.74992561,78.87097909,78.57900854,78.75430906,99.11314727),
  stringsAsFactors = FALSE)


df2 <- data.frame(
  params = c("AA","BB","CC","DD","EE","FF"),
  Ct = c(4.51,2.2,4.67,1.1,0.89,7.3),
  Sa = c(34.25,34.57,34.67,34.73,34.7,34.6),
  Ph = c(1.2,2.09,3.3,2.76,1.89,1.1),
  stringsAsFactors = FALSE)


#I am using pairs2 currently as follows to plot the df1 variables against each other:

pairs2(df1[1], df1[c(2,3,4)])

As per the pairs answer linked above, I attempted to use rbind to have these both appear together on the same plot, but I’m thinking that pairs2 acts differently than pairs with this function as I got several errors for extra “,” that I’m not sure actually had anything to do with the function itself.

Upvotes: 0

Views: 28

Answers (0)

Related Questions