0

I´m trying to automate a task in R. I need to create an object named with a expression that I extracted from a table. In this example the object is P1 and the named is extracted with as.expression.

 P1<-(cbind(table.df[1,], table.df.sum))
P1TEXT<-as.expression(row.names(Table.df)[1])

I want P1 to be named with the expression extracted by P1TEXT Thank you very much

  • 2
    You can use `assign(x = as.character(P1TEXT), value = P1)`. (Of course you don't need the intermediate `P1` and `P1TEXT` values... or the `as.expression`. You could go straight to `assign(row.names(table.df)[1], value = cbind(...))`.) Suggested dupes: [How to name variables on the fly (R-FAQ)](https://stackoverflow.com/q/2679193/903061) and [Create a variable name with `paste`](https://stackoverflow.com/q/5510966/903061). – Gregor Thomas Jul 28 '17 at 16:35
  • And of course there is no valid reason to do this ... – Roland Jul 28 '17 at 16:53

0 Answers0