Matching rows to log scale data in R

Basically, I don’t know how to build the line most suitable for my data when it will be a logarithmic scale. I put a linear regression line on my graph using lm () and abline (), but now that log = "xy" has been added, it just creates a horizontal line.

enter image description here

Here is a very simplified example of what I'm trying to do (the line is missing here):

lengths = c(10000,3000,3005,3005,3010,20000) counts = c(3,1,1,2,1,3) line=lm(counts~lengths) plot(lengths, counts, col="green", log="xy") abline(line, col="blue") 

I tried a lot of things that I found on similar issues (e.g. using log10() and lines() ) and they did not work with my data.

+8
r plot lm
source share
1 answer
 abline(line, col="blue",untf=TRUE) 

Unfortunately, I did not notice the comments above.

+9
source share

All Articles