This works with the example. If the real data is different it may not work. To run the example below just copy and paste it into R. To run with the real data replace textConnection(Lines) with "insulation.txt" everywhere.
Lines <- "Before insul After insul. temp gas temp gas -0.8 7.2 -0.7 4.8 -0.7 6.9 0.8 4.6 0.4 6.4 1.0 4.7 2.5 6.0 1.4 4.0 2.9 5.8 1.5 4.2 3.2 5.8 1.6 4.2 3.6 5.6 2.3 4.1 3.9 4.7 2.5 4.0 4.2 5.8 2.5 3.5 4.3 5.2 3.1 3.2 5.4 4.9 3.9 3.9 6.0 4.9 4.0 3.5 6.0 4.3 4.0 3.7 6.0 4.4 4.2 3.5 6.2 4.5 4.3 3.5 6.3 4.6 4.6 3.7 6.9 3.7 4.7 3.5 7.0 3.9 4.9 3.4 7.4 4.2 4.9 3.7 7.5 4.0 4.9 4.0 7.5 3.9 5.0 3.6 7.6 3.5 5.3 3.7 8.0 4.0 6.2 2.8 8.5 3.6 7.1 3.0 9.1 3.1 7.2 2.8 10.2 2.6 7.5 2.6 8.0 2.7 8.7 2.8 8.8 1.3 9.7 1.5" nfld <- count.fields(textConnection(Lines)) data.lines <- readLines(textConnection(Lines)) data.lines <- ifelse(nfld == 2, paste("NA NA", data.lines), data.lines) my.data <- read.table(textConnection(data.lines), header = TRUE, skip = 1) On Sat, Mar 21, 2009 at 8:13 PM, UBC <cheong0...@hotmail.com> wrote: > > so i am having this question > what should i do if the give data file (.txt) has 4 columns, but different > lengths? > how can i read them in R? > any idea for the following problem? > > > Gas consumption (1000 cubic feet) was measured before and after insulation > was put into > a house. We are interested in looking at the effect of insulation on gas > consumption. The > average outside temperature (degrees celcius) was also measured. The data > are included in > the file "insulation.txt". > > (a) Determine if insulation in the house effects the average gas > consumption. > (b) How much extra gas is used when there is no insulation? Provide an > interval estimate > as well as a point estimate. > > heres the content in "insulation.txt" (u can just copy and paste it to the > notepad so can be read in R) > > Before insul After insul. > temp gas temp gas > -0.8 7.2 -0.7 4.8 > -0.7 6.9 0.8 4.6 > 0.4 6.4 1.0 4.7 > 2.5 6.0 1.4 4.0 > 2.9 5.8 1.5 4.2 > 3.2 5.8 1.6 4.2 > 3.6 5.6 2.3 4.1 > 3.9 4.7 2.5 4.0 > 4.2 5.8 2.5 3.5 > 4.3 5.2 3.1 3.2 > 5.4 4.9 3.9 3.9 > 6.0 4.9 4.0 3.5 > 6.0 4.3 4.0 3.7 > 6.0 4.4 4.2 3.5 > 6.2 4.5 4.3 3.5 > 6.3 4.6 4.6 3.7 > 6.9 3.7 4.7 3.5 > 7.0 3.9 4.9 3.4 > 7.4 4.2 4.9 3.7 > 7.5 4.0 4.9 4.0 > 7.5 3.9 5.0 3.6 > 7.6 3.5 5.3 3.7 > 8.0 4.0 6.2 2.8 > 8.5 3.6 7.1 3.0 > 9.1 3.1 7.2 2.8 > 10.2 2.6 7.5 2.6 > 8.0 2.7 > 8.7 2.8 > 8.8 1.3 > 9.7 1.5 > > > > thx and any ideas would help. > -- > View this message in context: > http://www.nabble.com/data-analysis.-R-tp22641912p22641912.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.