# How to create a Budget line in excel or R

Im interested in programming a budget line or PPF which is responsive to changes in relative prices, and income effect.

I know the equation for the budget line is $$m\geq p_1x_1+p_2x_2$$ Lets say we have an Income of $m=100$ and prices $p_1=1$ and $p_2=2$.

How would I go about programming this into an excel spreadsheet or R?

• Can you provide more details about the production theory you are thinking of? Is this an abstract theory, using $n$ inputs $x_i$, or is this about capital and labour? Which production function? Also, have you done something? I'm not sure asking for code is entirely on-topic. Commented Apr 28, 2017 at 9:58
• Agreed. All you've said is: "I want to program something about producer theory". That's absurdly general. Commented Apr 28, 2017 at 13:36
• @luchonacho better?
– EconJohn
Commented Apr 28, 2017 at 16:11
• I would say so. But, in the end, all what you have is a function. You still have two unknowns and one equation. The system is undetermined. Do you want simply to create a graph of this, which moves according to your chosen parameterisation? If you could add more info to the question, it would be great. At the moment I don't think it's clear enough. Commented Apr 28, 2017 at 16:16
• Yeah, I just want a graph which changes by parameterisation. Im kinda just going back to basics as i want to apply my economic theory to real data sets. this is a start.
– EconJohn
Commented Apr 28, 2017 at 16:38

Another R code that does it...

m <- 100
p <- c(1, 2)
curve(m/p[2] - p[1]/p[2]*x, from = 0, to = m/p[1], lwd = 2,
xlab = expression(x[1]),
ylab = expression(x[2]))


If you want to draw a budget constrain which takes $m$, $p_1$ and $p_2$ as inputs, this is a R code that does it:

# Clear environment
remove(list = ls())

# Enter inputs
m=100
p1=1
p2=2

# Create plot
plot(c(0,(m/p1)*1.1), c(0,(m/p2)*1.1), type = "n", xlab = expression(x[1]), ylab = expression(x[2]), xaxs="i", yaxs="i")
abline(m/p2, -p1/p2, col = 1, lwd = 2)


You get:

The limit of axes adjust accordingly to the parameters, adding a 10% more to each axis crossing point.