On Mon, Dec 20, 2010 at 11:24 AM, Jeff Allen <lists@jdadesign.net> wrote:

> Hello.
>
> I'm looking to create an R package which requires a user-specific parameter
> in order to work. To be more descriptive: I'm making a database API
> available via an R package, but I want to control access to this API by
> using keys so that I can monitor activity at the user-level and make sure no
> one is abusing the database. So the R package is complete, but I need a way
> for users to specify their key so that it can be included in each call to
> the API. I'm looking for a way to avoid having the include the API key in
> every function call, but instead be able to include the key when you first
> attach the package.
>
> The functionality I'm looking for would essentially be to be able to pass a
> parameter to a package through the library call. That doesn't seem to be
> possible, so I'm looking for alternatives that would be user-friendly.
>
> I'd appreciate any thoughts!
>
>
Hi, Jeff.

I think the standard way this is usually handled (in multiple languages, not
just R) is to create a connection object (where connection credentials would
be specified) and then use that object in further calls to the db API.  You
might consider the DBI interface (
http://cran.r-project.org/web/packages/DBI/index.html) as the basis for your
API.

That said, if you don't choose to use the standard interface, there are a
number of ways that this type of thing could be done.

1)  Read a file from the system that contains the information (like .psqlrc
of .my.cnf file)
2)  Read an environment variable or two--these could be set before starting
R or using R commands to set the environment variable
3)  Setting an R option
4)  Other, more creative solutions such as reading the username, etc., from
environment
5)  Combinations of the above....
6)  There may be others.

All of these except (4) will require the user to specify once per R session
the information that you need.

Sean

	[[alternative HTML version deleted]]

