1

My goal is to visualize the outcome of the pearson test on the dataframe called Width_Dens in the snapshot below. I could not copy the dataframe because it is too big, so hopefullly this picture makes it clear. In order to visualize the outcome of the pearson test for my data, the following script is used:

ggscatter(Width_dens, x = "Width", y = "Density", 
         add = c("reg.line"), conf.int = TRUE, 
         cor.coef = TRUE, cor.method = "pearson")
         xlab = "Canal Width (m)", ylab = "Plastic density ( m^-2)")

It gives the following error:

Don't know how to automatically pick scale for object of type units. Defaulting to continuous.
Error in Ops.units(x, range[1]) : 
  both operands of the expression should be "units" objects

Does anybody have a clue what is wrong with this code? Or maybe another way to plot a similar graph?

enter image description here

zx8754
  • 52,746
  • 12
  • 114
  • 209
  • It's easier to help you if you include a simple [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input and desired output that can be used to test and verify possible solutions. Please do not share pictures of data. We can't copy/paste that into R and it's not clear how the data is stored. List all non-base R packages you are using. – MrFlick Jan 13 '21 at 09:16
  • The problem is that my dataset is 377 rows long and i am not succeeding in extracting certain rows from it. Therefore I have trouble posting it. – Jelmer Visser Jan 13 '21 at 09:37
  • you sure `Width_dens` is a data frame? – tjebo Jan 13 '21 at 11:29
  • 1
    It looks like you have units on those columns so they might not be `numeric`. Confirm with `str(Width_dens)` – Dan Adams Jan 13 '21 at 12:29

0 Answers0