[R] convert data.frame to parameters

Duncan Murdoch murdoch.duncan at gmail.com
Mon Oct 7 14:04:25 CEST 2013


On 07/10/2013 7:56 AM, Charles Annis wrote:
> Greetings:
>
> I have a 24 row,  2-column csv file.  The first column is character, with
> the names of parameters.  The second column is numeric, containing the
> parameter values.
>
> I can produce a 2-column data.frame with  case.study.parameters <-
> read.csv(...)
>
> I want to convert the data.frame to 24 parameters having those names and
> their associated numeric values.
>
> I've tried using package "ParamHelpers" with no success.  Likely because it
> really isn't intended for that purpose.
>
> Can anyone help?

You say you want "parameters", but that's not an R type.  So here's one 
way, but it might not be what you're looking for.

df <- data.frame(names=letters, values=1:26)
parameters <- df$values
names(parameters) <- df$names

Duncan Murdoch



More information about the R-help mailing list