I would like to write a function that converts a polynomial into a named vector. The entries of the vector should correspond to the coefficients of the polynomial and be named as x^n, where n is the corresponding exponent.
The output should look like this:
> function("2x^5 + x + 3x^5 - 1 + 4x")
x^0 x^1 x^2 x^3 x^4 x^5
-1 5 0 0 0 5
Cheers!