Neotropical bat risk assessments
2011-Dec-15 12:03 UTC
[R] How to open files that contain "0"
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 -- Bruce W. Miller, Ph.D. Conservation Ecologist Neotropical Bat Project office details Gallon Jug, Belize Mailing address P.O. Box 37, Belize City Belize, Central America Phone +501-220-9002 -- Bruce W. Miller, PhD. Neotropical bat risk assessments If we lose the bats, we may lose much of the tropical vegetation and the lungs of the planet Using acoustic sampling to map species distributions for>15 years. Providing Interactive identification keys to the vocal signatures of New World Bats For various project details see: https://sites.google.com/site/batsoundservices/ [[alternative HTML version deleted]]
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