Reputation: 13
I have a problem with the following 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)
Upvotes: 1
Views: 54
Reputation: 278
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)
# plotting with jitter
plot(jitter(x1), jitter(x2))
jitter(...) changes the values by small amounts so only use the jittered data for plotting, otherwise it will bias your results!
Upvotes: 1