I have a dataframe with three columns:
sampleData <- structure(list(sgRNA = c("SFPQ_9", "SFPQ_9", "FBXO18_13", "FBXO18_13",
"DDX21_55", "DDX21_55", "TAF6L_11", "TAF6L_11", "NAA40_3", "NAA40_3",
"KDM5A_1", "KDM5A_1", "DGKH_17", "DGKH_17", "NAA30_15", "NAA30_15",
"HMG20A_8", "HMG20A_8", "CASKIN1_35", "CASKIN1_35", "NUBP1_20",
"NUBP1_20", "CTCF_9", "CTCF_9", "THAP11_17", "THAP11_17", "EZH1_9",
"EZH1_9", "SMARCD2_21", "SMARCD2_21", "E2F6_6", "E2F6_6", "CENPA_11",
"CENPA_11", "SP140_35", "SP140_35", "SETD4_3", "SETD4_3", "STAG3_9",
"STAG3_9", "RAD54B_39", "RAD54B_39", "SMC1A_59", "SMC1A_59",
"ZNF257_1246", "ZNF257_1246", "DYNC1I2_4", "DYNC1I2_4", "NTC_77",
"NTC_77"), replicate = c("R1", "R2", "R1", "R2", "R1", "R2",
"R1", "R2", "R1", "R2", "R1", "R2", "R1", "R2", "R1", "R2", "R1",
"R2", "R1", "R2", "R1", "R2", "R1", "R2", "R1", "R2", "R1", "R2",
"R1", "R2", "R1", "R2", "R1", "R2", "R1", "R2", "R1", "R2", "R1",
"R2", "R1", "R2", "R1", "R2", "R1", "R2", "R1", "R2", "R1", "R2"
), abundance = c(450L, 583L, 209L, 231L, 212L, 288L, 958L, 1103L,
562L, 717L, 388L, 452L, 290L, 330L, 201L, 281L, 142L, 258L, 608L,
850L, 218L, 328L, 522L, 711L, 623L, 772L, 371L, 471L, 56L, 52L,
160L, 135L, 359L, 416L, 213L, 348L, 301L, 416L, 185L, 256L, 222L,
238L, 347L, 536L, 765L, 973L, 115L, 117L, 102L, 132L)), row.names = c(NA,
-50L), class = c("tbl_df", "tbl", "data.frame"))
I would like to build a scatterplot. All the values are in the "abundance" column and the "replicate" specifies whether the observation is to be used as a coordinate along x or y axis. While "sgRNA" specifies the point. I understand I can pivot the data to wider format to generate two new columns "R1" and "R2" and plot them against each other using ggplot2, but is there a way to do this without pivoting?



