[R] data analysis. R

jim holtman jholtman at gmail.com
Sun Mar 22 04:41:38 CET 2009


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 <cheong0618 at 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 at 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?




More information about the R-help mailing list