Fitting a function to x-y data points

Read in some x-y data and then find a least-squares fit to the data as a linear combination of given functions, or as a nonlinear function.

1. Read in arrays x and y from file xyL.dat, and find the best 5th-degree polynomial fit

xy = ReadList["xyL.dat",{Number,Number}];
Fit[ xy, {x^5, x^4, x^3, x^2, x^1, 1}, x]

2. Read in arrays x and y from file xyN.dat, and find the best fit to y(x) = a exp(bx) sin(cx + d)

xy = ReadList["xyN.dat",{Number,Number}];
Needs["Statistics`NonlinearFit`"]
YofX[x_] = a Exp[b x] Sin[c x + d]
initialguesses = {{a,0.5}, {b,-0.5},{c,1.5},{d,0.5}}
ft = NonlinearFit[xy, YofX[x], x, initialguesses]
Plot[ft, {x,0,20}];