Multiple Polynomial Regression in R

Hi all,
I need to do predict the values of some variables from a set of predictors.
The variables I need to predict are called Y1 and Y2 belonging to Y.
The predictors I have are X0, ..., X400 belonging to X.

I tried to predict Y from X with several techinques (linear regression, lasso, regression tree and random forest) but all of them cannot achieve a good test error rate.
I now want to try with polynomial regression but I am not able to do it in R.

The inputs X and Y are csv.
My attempt basically was the following:

lm(Y~poly(X, degree = 2, raw=TRUE), data=dataset)

but apparently X cannot be a set of values. It must a be a specific predictor (e.g. X1).

How can I work it out?