[R] error when using subset (0 observations)
David Winsemius
dwinsemius at comcast.net
Mon Dec 31 19:15:00 CET 2012
On Dec 31, 2012, at 3:22 AM, Irucka Embry wrote:
> Hi Jorge, thank-you for the quick response. That suggestion worked
> perfectly.
>
> <-----Original Message----->
>> From: Jorge I Velez [jorgeivanvelez at gmail.com]
>> Sent: 12/31/2012 5:05:14 AM
>> To: iruckaE at mail2world.com
>> Cc: r-help at r-project.org
>> Subject: Re: [R] error when using subset (0 observations)
>>
>> Dear Irucka,
>>
>>
>> Use "02169570" instead of 02169570 -- note the quotes -- when calling
> subset().
Irucka; Please note that subset should allow specification of subset
using logical tests on numeric variables without using quotes, and
that Jorge was making an educated guess that you had unwittingly made
a logical test on a character vector using a numeric comparison.
--
David.
>>
>>
>>
>>
>> On Mon, Dec 31, 2012 at 9:45 PM, Irucka Embry <> wrote:
>>
>> Hi, how are you?
>>
>> My name is Irucka Embry and I would like assistance on properly
>> subsetting some data obtained from a .csv file.
>>
>>> file <-"info_n.csv"
>>
>>> INFO<- getMetaDataFromFile(file)
>> INFO is 92 observations of 14 variables
>>
>>> INFO<- subset(INFO,site.no==02169570)
>> INFO is 0 observations of 14 variables
>>
>> When the site.no is used I should have 1 observation of 14 variables
>> instead of 0. Can you assist me?
>>
>> Thank-you.
>>
>> Irucka Embry
>>
>>
>> This is the function that is called:
>> getMetaDataFromFile <- function(file, hasHeader = TRUE, separator =
> ",")
>> {
>> totalPath <- paste(file, sep = "")
>> tmp <- read.csv(totalPath, header = hasHeader, sep = separator,
>> fill =
>> TRUE, comment.char = "#", as.is = TRUE, stringsAsFactors = FALSE,
>> na.strings = "NA")
>> retval <- as.data.frame(tmp, stringsAsFactors = FALSE)
>> return(retval)
>> }
>>
>>
>> This is an example of the data that is stored in the "info_n.csv"
>> file.
>> There are 92 total sites in this file.
>> site.no flowstation.no shortName dec.lat.va dec.long.va drainSqKm
>> areaUnits drainSqKmFlow areaUnits staAbbrev param.nm paramShortName
>> constitAbbrev param.units
>> 2169570 2169570 Gills Creek at Columbia, SC 33.98960016 -80.97425727
>> 152.7543752904 2 152.7543752904 2 GillsColumSC Total nitrogen, water,
>> unfiltered, milligrams per liter Nitrate as N TN mg/L
>>
>>
>>
>> <span id=m2wTl><p><font face="Arial, Helvetica, sans-serif" size="2"
>> style="font-size:
>> 13.5px">______________________________________________
> _________________<BR>Get
>> the Free email that has everyone talking at <a
> href=http://www.mail2world.com
>> target=new>http://www.mail2world.com</a><br> <font
> color=#999999>Unlimited
>> Email Storage - POP3 - Calendar - SMS - Translator -
>> Much More!</font></font></span>
>> [[alternative HTML version deleted]]
>>
>> ______________________________________________
>> 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.
>
>
> <span id=m2wTl><p><font face="Arial, Helvetica, sans-serif" size="2"
> style="font-size:
> 13.5px
> ">
> _______________________________________________________________
> <BR>Get the Free email that has everyone talking at <a href=http://www.mail2world.com
> target=new>http://www.mail2world.com</a><br> <font
> color=#999999>Unlimited Email Storage POP3 Calendar
> SMS Translator Much More!</font></font></span>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> 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.
David Winsemius, MD
Alameda, CA, USA
More information about the R-help
mailing list