1

I have a problem with the following graph:

graph

For every value that I put in plot() I get this graph. Does anyone maybe know what it means?

Cor.test works, I got weak correlation.

my code:

cor.test(podatki$v54, podatki$v197, method = c("pearson"), 
         conf.level = 0.95, use = "all.obs" )


plot(podatki$v54, podatki$v197)
1
  • 1
    hey it seems like your values are ordinal, like they can only take up 1 to 5.. So the points will overlay each other.. And lastly, can you do correlation on this kind of variables?
    – StupidWolf
    Nov 4, 2019 at 23:22

1 Answer 1

1

Your graph looks that way because the points are plotted directly on top of one another.

You can use the jitter(...) function to add small amounts of randomness to the data points so they aren't directly on top of one another (it jitters them around so you can see the ones underneath!) Here is an example you can copy and paste:

# create some random numbers to plot. all are values 1-5.    
x1 <- sample(c(1:5), 100, replace = TRUE)
x2 <- sample(c(1:5), 100, replace = TRUE)

# plotting without jitter
plot(x1, x2)

enter image description here

# plotting with jitter 

plot(jitter(x1), jitter(x2))

enter image description here

jitter(...) changes the values by small amounts so only use the jittered data for plotting, otherwise it will bias your results!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.