data={{2, 3.415}, {3, 3.366}, {4, 3.329}, {5, 3.302}, {6, 3.27}, {7, 3.245}, {8, 3.225}, {9, 3.2}, {10,3.182}}

fdata=Table[{data[[i, 1]]*589.3*(10^(-9)), ((data[[1,2]]+3.79)*(10^(-2))/2-data[[i, 2]]*(10^(-2)))^2}, {i, 1, Length[data]}]

fdata

ListPlot[fdata, AxesOrigin->{0,0}]

Fit[fdata, {1,x}, x]

lm=LinearModelFit[fdata, {x}, {x}, Weights->(1/x2err)]

lm[{"ParameterTable", "RSquared", "BestFit"}]

Show[ListPlot[fdata], Plot[lm[{"BestFit"}], {x, fdata[[1,1]], fdata[[Length[fdata], 1]]}]]

x2err=Table[N[Round[2*((data[[1,2]]+3.79)*(10^(-2))/2-data[[i, 2]]*(10^(-2)))*0.0001, (10^(-7))]], {i, 1, Length[data]}]

Needs["ErrorBarPlots`"]

Show[ErrorListPlot[Table[{{fdata[[i, 1]], fdata[[i, 2]]}, ErrorBar[0.1*(10^(-9))*data[[i,1]],x2err[[i]]]}, {i, 1, Length[fdata]}], AxesOrigin->{1*(10^(-6)),2*10^-6}], Plot[lm[{"BestFit"}], {x, fdata[[1,1]], fdata[[Length[fdata], 1]]},AxesOrigin->{0,0}]]

Show[ErrorListPlot[Table[{{fdata[[i, 1]], fdata[[i, 2]]}, ErrorBar[0.1*(10^(-6))*data[[i,1]],x2err[[i]]]}, {i, 1, Length[fdata]}]], Plot[lm[{"BestFit"}], {x, fdata[[1,1]], fdata[[Length[fdata], 1]]}], {AxesOrigin->{0,0}, PlotLabel->"Bums", AxesLabel->{"     nλ (m)", "(x^2) ((m^2))"}}]

Table[{{fdata[[i, 1]], fdata[[i, 2]]}, ErrorBar[x2err[[i]]]}, {i, 1, Length[fdata]}]

templm=lm; datarange=fdata; func={x}; funcvar={x}; origin={0,0};errorrange=datarange;

dograph[datarange_, errorrange_, func_, funcvar_, args_]:=Module[{c},
Print[lm=LinearModelFit[datarange, func, funcvar]]; Print[" "];
Print[lm["ParameterTable"]]; Print[" "];
Print["R Squared value: ",lm["RSquared"]]; Print[" "];
Show[ErrorListPlot[Table[{{datarange[[i, 1]], datarange[[i, 2]]}, ErrorBar[errorrange[[i,1]],errorrange[[i,2]]]}, {i, 1, Length[datarange]}]], Plot[templm[{"BestFit"}], {x, datarange[[1,1]], datarange[[Length[datarange], 1]]}], args]]

dograph[fdata, Table[{0.1*(10^(-9)), x2err[[i]]}, {i, 1, Length[fdata]}], {x}, {x}, {AxesOrigin->{0,0}, PlotLabel->"poo"}]

plotter[{dataset_, y_}, x_]=ListPlot[{dataset, y}]

plotter[{2, 5}]

lm[{"ParameterTable"}][[1, 1, 1, 3, 2]]

lm[{"ParameterTable"}][[1,1,1,3,3]]

Print[lm[{"ParameterTable"}][[1, 1, 1, 3, 2]],"±", lm[{"ParameterTable"}][[1,1,1,3,3]]]