[R] cwhmisc package error

David Winsemius dwinsemius at comcast.net
Wed Sep 22 04:59:10 CEST 2010


On Sep 21, 2010, at 10:11 PM, Adrienne Wootten wrote:

> R-listers,
>
> I'm working on a project where I need to get the lowercase of the  
> county
> variable in a dataset alike to the example below (only difference is  
> that
> the full dataset has all the states and counties in the southeast  
> United
> States).  I keep getting this strange error with the lowerize function
> (which didn't occur the first few times I use the code below), and  
> oddly
> enough the error doesn't happen with the function CapLeading (which  
> is in
> the same package).
>
>> correlfile[1:3,]
>    state  statecounty     county
> 1    AL  AL_AUTAUGA AUTAUGA
> 2    AL  AL_BALDWIN BALDWIN
> 3    AL  AL_BARBOUR BARBOUR
>
> library(cwhmisc)

On the basis of my initial testing I suspect that these are character  
vectors rather than factors. If you could produce the results of dput  
on a larger number of rows it might be helpful.

Another thought would be to replace the "=" operator with "<-"

The "=" behavior can occasionally be unpredictable. (I repeated the  
operation of the rhs of that assignment 1000 times inside a replicate  
call and did not trigger an error with that tiny dataset after reading  
it in with stringsAsFactors =FALSE.

I also wonder why it was necessary to make a new function that does  
the same thing as the tolower() function, and I wonder if you might  
substitute a base function for this flakey function?

traceback immediately after the error might also be informative.

R 2.9 is getting pretty old (2 years?) and you should check to see if  
upgrading to a current version of R and cwhmisc will solve the  
problem. (We are getting ready for R 2.12 at this point.)

-- 
David.


>>
> correlfile$county[correlfile$state=="AL"]=lowerize(correlfile 
> $county[correlfile$state=="AL"])
>
> Error in get(as.character(FUN), mode = "function", envir = envir) :
>  object 'f' of mode 'function' was not found
>
>>
> correlfile$county[correlfile$state=="AL"]=CapLeading(correlfile 
> $county[correlfile$state=="AL"])
>
> System specs involved
> R version 2.9.2
> cwhmisc package version 2.1
> OS - Redhat Enterprise Linux version 5.5
>
> Another strange thing that seems to happen is that when I open R in a
> different working directory of the server, the lowerize function works
> without giving this error, for a short while.  Before long, it  
> begins giving
> the aforementioned error message again.
>
> I haven't found anything in the archives on this so I turn to the R- 
> listers.
>
> Any ideas on why this keeps happening would be very helpful!
> Thanks!
>
>
> Adrienne Wootten
> Graduate Research Assistant
> State Climate Office of North Carolina
> North Carolina State University
>
> 	[[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.



More information about the R-help mailing list