plot - 'x' and 'y' lengths differ in R -


i trying plot horizontal line in r, giving me error.

code:

w <- seq(1, 99, by=1) alpha <- 0.1 beta <- 0.001  u <- alpha*w -(beta/2)*w*w uprime <- alpha -(beta)*w udprime <- -beta utprime <- 0  plot(w,udprime,type = "l",main = "graph of u(w) versus wealth",xlab = "wealth",ylab = "utility function") 

when plot function out, error:

error in xy.coords(x, y, xlabel, ylabel, log) :    'x' , 'y' lengths differ 

why so? need guidance.

to plot horizontal line second derivative of wealth utility function, you'll need make sure udprime has point every point w. there's 2 ways this:

shortcut:

plot(cbind(w, udprime)) 

more "true math":

udprime = -beta * w^0 

Comments

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -