0

My data is a csv file as follows which has been read to a value called var_x_degs:

enter image description here

This goes on for 500+ more rows. I need to visually inspect how well the three replicates "VarXCRep.1", "VarXCRep.2" and "VarXCRep.3" agree/correlate with each other using scatterplots.

My thought process was to calculate correlation between Rep.1 and Rep.2 because I am unable to use cor() for more than two variables. But when I run cor(var_x_degs$VarXCRep.1, var_x_degs$VarXCRep.2) I get back one value. How can I work out correlation between each of the rows, so that each row has its own correlation value? I suppose once I have that value I can at least make a scatterplot. Is there a way to draw correlation between all triplicates?

A D
  • 13
  • 3
  • I am new to R to bear with me on this: I tried ```new <- data.frame(x1=var_x_degs$VarX1Rep.1, x2=var_x_degs$VarX1Rep.1, x3=var_x_degs$VarX1Rep.1) M <- cor(new)``` but the output was just 1 1 1 1 1 1 1 – A D Jan 01 '22 at 21:51
  • Yes because they are the same variable hence perfectly correlated? Run `cor(mtcars)` and see if that is similar to what you need. – NelsonGon Jan 01 '22 at 21:53
  • Apologies, I tried '''new <- select(var_x_degs, VarX1Rep.1, VarX1Rep.2, VarX1Rep.3) M <- cor(new) ''' would this make sense? I do have a spread now – A D Jan 01 '22 at 21:55
  • Yes, I think that is what you want? – NelsonGon Jan 01 '22 at 21:56
  • So my version of RStudio does not load qtlcharts. I was able to make the corrplot. Is there a way to use corrplot in scatter? – A D Jan 01 '22 at 22:01
  • I honestly do not know, I have never created a scatter plot of correlations but you can use `ggplot2` to plot them and maybe color by name of the variable? – NelsonGon Jan 01 '22 at 22:03
  • 1
    Many thanks for your support. Appreciate it. – A D Jan 01 '22 at 22:04
  • [See here](https://stackoverflow.com/q/5963269/5325862) on making a reproducible example that is easier for folks to help with. That includes a workable sample of data (not a picture of it) and a clear sense of what you're trying to get (a specific type of chart, for example). It's also unclear what you're trying to get correlations of—you said you want correlation coefficients per row? You'd only have one rep1 and one rep2 per row, so you're not going to get correlations from that – camille Jan 02 '22 at 02:33

0 Answers0