Re: [R] data analysis. R

2009-03-22 Thread UBC

thx for ur fast responds.
but sorry for asking stupid, i am a turn beginner of R (just trying it out
3 months, and i am taking my first course about it)
so, to tackle this questions,
i was told to use nested design method,
could you actually show me how would u attempt this problem?
(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.

i just got confused by the backgroud information.
We are interested in looking at the effect of insulation on gas
consumption. The average outside temperature (degrees celcius) was also
measured.

so how should my model looks like?
i dont even know what should be my explanatory/response variables...

thx in advance



Gabor Grothendieck wrote:
 
 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 insulAfter insul.
 tempgas tempgas
 -0.87.2-0.74.8
 -0.76.90.84.6
 0.46.41.04.7
 2.56.01.44.0
 2.95.81.54.2
 3.25.81.64.2
 3.65.62.34.1
 3.94.72.54.0
 4.25.82.53.5
 4.35.23.13.2
 5.44.93.93.9
 6.04.94.03.5
 6.04.34.03.7
 6.04.44.23.5
 6.24.54.33.5
 6.34.64.63.7
 6.93.74.73.5
 7.03.94.93.4
 7.44.24.93.7
 7.54.04.94.0
 7.53.95.03.6
 7.63.55.33.7
 8.04.06.22.8
 8.53.67.13.0
 9.13.17.22.8
 10.2  2.67.52.6
8.02.7
8.72.8
8.81.3
9.71.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.
 
 

-- 
View this message in context: 
http://www.nabble.com/data-analysis.-R-tp22641912p22643290.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 

[R] data analysis. R

2009-03-21 Thread UBC

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 insulAfter insul.
tempgas tempgas
-0.87.2-0.74.8
-0.76.90.84.6
0.46.41.04.7
2.56.01.44.0
2.95.81.54.2
3.25.81.64.2
3.65.62.34.1
3.94.72.54.0
4.25.82.53.5
4.35.23.13.2
5.44.93.93.9
6.04.94.03.5
6.04.34.03.7
6.04.44.23.5
6.24.54.33.5
6.34.64.63.7
6.93.74.73.5
7.03.94.93.4
7.44.24.93.7
7.54.04.94.0
7.53.95.03.6
7.63.55.33.7
8.04.06.22.8
8.53.67.13.0
9.13.17.22.8
10.2  2.67.52.6
8.02.7
8.72.8
8.81.3
9.71.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.


Re: [R] data analysis. R

2009-03-21 Thread jim holtman
If the input file has a separator other than a space (e.g., tabs or
commas) then you can read it is and the missing data will be NAs and
you can decide how to handle it.  If it does not have a separator,
then maybe you can read it in with read.fwf.  Otherwise when you read
it in, you can tell the system to 'fill' the missing data, but you
don't really know what columns that might be in.  So you have some
choices; you are able to read in data that may have different lengths
in the columns, but if it is ill-structured, it may be difficult to
determine how to handle the missing data.

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.




-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem that you are trying to solve?

__
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.


Re: [R] data analysis. R

2009-03-21 Thread Gabor Grothendieck
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 insulAfter insul.
tempgas tempgas
-0.87.2-0.74.8
-0.76.90.84.6
0.46.41.04.7
2.56.01.44.0
2.95.81.54.2
3.25.81.64.2
3.65.62.34.1
3.94.72.54.0
4.25.82.53.5
4.35.23.13.2
5.44.93.93.9
6.04.94.03.5
6.04.34.03.7
6.04.44.23.5
6.24.54.33.5
6.34.64.63.7
6.93.74.73.5
7.03.94.93.4
7.44.24.93.7
7.54.04.94.0
7.53.95.03.6
7.63.55.33.7
8.04.06.22.8
8.53.67.13.0
9.13.17.22.8
10.2  2.67.52.6
   8.02.7
   8.72.8
   8.81.3
   9.71.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.


Re: [R] data analysis. R

2009-03-21 Thread Dylan Beaudette
On Sat, Mar 21, 2009 at 5: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.

Dude- really? This is just a funky-format version of the whiteside
data found in the MASS package:

library(MASS)
whiteside


See the posting guide (http://www.r-project.org/posting-guide.html),
especially the section on homework questions.

__
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.