I have a function that needs to expect a formula as an input, in the form of y~x, for example. Then, I need to pass a series of x-values into that formula to get out the y's.  
For example, if my formula is y~x^2, and my series of x-values is (1,2,3,4), then I should expect (1,4,9,16) as output.
Say I have the formula like this: formula1 <- y~x:
Here's what I've tried thus far:
- Converting the formula into a function: 
as.function(formula1) - Using 
model.frameandmodel.matrixlike so: 
Like so:
formula1 <- y~x^2 
x <- c(1,2,3,4)
my_data <- data.frame("x" = x, "y" = rep(0,length(x))) 
model_frame <- model.frame(formula1, data = my_data)
my_design_matrix <- model.matrix(formula1, model_frame)
- I tried using nls2, but I don't have any parameters to optimize, so I don't see the point.
 
What can I use for this?
Here are the resources I consulted:
How to apply a formula to a vector in R?