这里用到 eval() 和 parse() 函数。首先使用 parse() 函数将字符串转化为表达式(expression),而后 使用 eval() 函数对表达式求解。 x <- 1:10 a <- "print(x)" class (a) eval(parse(text = a))