[R] How to open files that contain "0"

Sarah Goslee sarah.goslee at gmail.com
Thu Dec 15 13:20:56 CET 2011


It doesn't have anything to do with 0 values.

read.table() is treating everything after the # (the default comment
character) as a comment.

Using comment.char = "" in read.table() will change that behavior.

Special characters in files cause all sorts of issues.

Sarah

On Thu, Dec 15, 2011 at 7:03 AM, Neotropical bat risk assessments
<neotropical.bats at gmail.com> wrote:
> Hi all,
>
> How can I set open files that contain values of Zero =0?
>
> These are valid values for the parameters I need to evaluate.
> I have tried CSV and tab formats.
> Trying XL Connect and/or XLConnectJars dies not seem to work to open
> Excel files so I am at a loss on how to get the data into a DF.
>
>
> Sample of data with 0 values:
>
> Filename        Dur     TBC     Fmax    Fmin    Fmean   Fc      S1      Sc      Pmc
> g8221843.13#    5.06    0       38.93   36.2    37.96   36.45   -34.08  192.69  6.8
> g8221843.13#    0.41    5.29    38.83   36.04   38.83   38.83   -261.93         -513.05         0
> g8221843.13#    0.66    0.68    35.71   33.4    36.42   35.63   -238.04         -392.06         0.2
> g8221843.13#    0.58    54.84   42.78   40.3    41.1    40.3    410     0       6.2
>
>
> This message is displayed in the console:
>
>  > BASCTWS <- read.table("C:/=Bat data
> working/R/BASCTWS.txt",header=T,sep="\t",quote="")
> Error in scan(file, what, nmax, sep, dec, quote, skip, nlines,
> na.strings,  :
>   line 1 did not have 10 elements
>  >
> Obviously I am missing something basic, seems I was able to do this in
> the past.
>
> Bruce
>
-- 
Sarah Goslee
http://www.functionaldiversity.org



More information about the R-help mailing list