[R] Rlanguage plr and loadiing climatol package

David Winsemius dwinsemius at comcast.net
Sat Nov 20 21:55:36 CET 2010

On Nov 20, 2010, at 3:25 PM, David Potts wrote:

> Hi List
> I am trying to call the R library function rosavent from the climatol
> package via the plr interface package to the postgres database.
> My code is a follows
> create or replace function w_graph() returns text as
> '
> str <- pg.spi.exec("select
> n,nne,ne,ene,e,ese,se,sse,s,ssw,sw,wsw,w,wnw,nw,nnw from wdata");
> pdf("/tmp/foobar.pdf");
> rosavent(str,4,4,ang=-3*pi/16,main="Annual windrose")
> dev.off();
> print("Done");
> '
> When invoked it gives the error
> # select w_graph();
> ERROR:  R interpreter expression evaluation error
> DETAIL:  Error in PLR7843132 <- function() { : could not find function
> "rosavent"
> CONTEXT:  In PL/R function w_graph
> I assume this means it can not find the rosavent function from the
> climatol package.
> I have loaded the climatol package using the following syntax
> install.packages("climatol",lib="/home/dfuncs/r-lang/my-rlib")

I'm not sure if not having loaded climatol is the source of your  
problem, but if it is, you have forgotten to load the package after  
installing it. Perhaps:

require(climatol)   # before the pdf(...) call

> I assume that the an R process created by the plr interface will  
> load a
> library, does any body know how I tell it to load it?

This page:

  makes me thing that PL/R passes r code pg.spi.exec (... calls. Does  
it matter that the illustration on that page uses str<<- pg.spi.exec  
( rahter than str<- ?

(This would seem to be the wrong place to be asking these questions.  
There are websites set up to mediate conversations between PL/R users.)

David Winsemius, MD
West Hartford, CT

More information about the R-help mailing list