FIND DATA: By Journal | Sites   ANALYZE DATA: Help with R | SPSS | Stata | Excel   WHAT'S NEW? US Politics | IR | Law & Courts🎵
   FIND DATA: By Journal | Sites   WHAT'S NEW? US Politics | IR | Law & Courts🎵
WHAT'S NEW? US Politics | IR | Law & Courts🎵

Run R Code Example Online

# This sample code creates objects, performs computations, and produces a graphic.
# Try changing the value of thisIntercept and thisSlope 

# Assigning Values to Objects
thisIntercept = 0
thisSlope = -1
simDataX = runif(20, -10, 10)

# Performing Computations with Objects
simDataY = thisIntercept + thisSlope*simDataX + runif(20, -10, 10)

# Creating Graphics
plot(x="", y="", xlim=c(-10,10), ylim=range(simDataY), xlab="X Values", ylab="Y Values")
abline(a=thisIntercept, b=thisSlope)
points(x=simDataX , y=simDataY, col="red")
abline(lm(simDataY ~ simDataX), col="red")