R homework

#1
1. Fit appropriate regression models to describe relationship between the variables X and Y using the following three data sets separately. Use Y as the response and X as the explanatory variable. You must show all the necessary tables and fi gures for the model fi t and also comment on the fi t.

Table 1: Data Set - A
\(
\begin{tabular}{|l |r|}
\hline
X & Y \\
\hline
32 & 48.5 \\
36.3 & 42.9 \\
36.5 & 32.6 \\
34 & 38.4 \\
27.1 & 27.6 \\
45.8 & 75.8 \\
\hline
\end{tabular}
\)

Table 2: Data Set - B
\(
\begin{tabular}{|l |r|}
\hline
X & Y \\
\hline
60.5 & 5457.6 \\
56.5 & 4755.2 \\
48 & 3430.3 \\
53.1 & 4203.9 \\
57.1 & 2754.6 \\
25.8 & 7005.8 \\
12 & 6666 \\
\hline
\end{tabular}
\)

Table 3: Data Set - C
\(
\begin{tabular}{|l |r|}
\hline
X & Y \\
\hline
24.2 & 148.5 \\
32.5 & 422.9 \\
10.4 & 328.6 \\
29.1 & 658.4 \\
27.1 & 2796.6 \\
\hline
\end{tabular}
\)

I have tried this as :
Code:
set1 <- read.table("G:\\data1.txt",header=TRUE) # Data set A
regr1 <- lm(Y~X,data=set1)
regr1
with(set1,plot(Y~X,xlab="explanatory variable X",ylab="response variable Y",
          main="Relationship between X & Y of data set1"))

set2 <- read.table("G:\\data2.txt",header=TRUE) # Data set B
regr2 <- lm(Y~X,data=set2)
regr2
with(set2,plot(Y~X,xlab="explanatory variable X",ylab="response variable Y",
          main="Relationship between X & Y of data set2"))


set3 <- read.table("G:\\data3.txt",header=TRUE) # Data set C
regr3 <- lm(Y~X,data=set3)
regr3
with(set3,plot(Y~X,xlab="explanatory variable X",ylab="response variable Y",
          main="Relationship between X & Y of data set3"))
Are these sufficient according to question or i have to add more information to show the relationship of X & Y since i have been asked to show all the necessary tables and fi gures for the model fi t and also comment on the fit.

The 2nd part of the question is:
Combine the three data sets (from question 1) into a R data object data.frame of the following type:
\(
\begin{tabular}{|l c r|}
\hline
X & Y & Type \\
\hline
32 & 48.5 & A \\
36.3 & 42.9 & A \\
\vdots


45.8 & 75.8 & A \\
60.5 & 5457.6 & B \\
\vdots


12 & 6666 & B \\
24.2 & 48.5 & C \\
\vdots


271 & 2796.6 & C \\
\hline
\end{tabular}
\)

I couldn't add new column "Type". But tried to add this by "within"
Code:
datABC <- rbind(set1,set2,set3)
within(datABC,Type={})