Displaying 2 results from an estimated 2 matches for "pvshankar".
2012 May 03
1
How to create data frame column name in a function
Hello,
pvshankar wrote
> 
> Hello all,
> 
> I have a data frame with column names s1, s2, s3....s11
> 
> I have a function that gets two parameters, one is used as a subscript for
> the column names  and another is used as an index into the chosen column.
> 
> For example:
> 
> my_f...
2012 May 03
1
Runtime column name creation
Hello all, 
I have a data frame with column names s1, s2, s3....s11 
I have a function that gets two parameters, one is used as a subscript for
the column names  and another is used as an index into the chosen column. 
For example: 
my_func <- function(subscr, index) 
{ 
  if (subscr == 1) 
  { 
    df$s1[index] <- some value 
  } 
} 
The problem is, I do not want to create a bunch of