Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/list/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何为R中列表中的每个元素调用不同的值_R_List_Apply - Fatal编程技术网

如何为R中列表中的每个元素调用不同的值

如何为R中列表中的每个元素调用不同的值,r,list,apply,R,List,Apply,我有一个包含29个数据帧的列表。 我正在尝试使用ifelse()进行一个简单的转换,看起来像这样: with(df,ifelse(col1>x,col1当需要将多个值传递给lappy时,必须改用mappy mapply( function(df, x, y) { #print("df") #print(df) #print("x") #print(x) #print("y") #print(y) with(df, ifelse(leng

我有一个包含29个数据帧的列表。 我正在尝试使用
ifelse()
进行一个简单的转换,看起来像这样:
with(df,ifelse(col1>x,col1当需要将多个值传递给
lappy
时,必须改用
mappy

mapply(
  function(df, x, y) {
    #print("df")
    #print(df)
    #print("x")
    #print(x)
    #print("y")
    #print(y)
    with(df, ifelse(length > x, length <- length - x, length <- length + y)) 
  },
  list,
  info$x,
  info$y
)  
mapply(
函数(df,x,y){
#打印(“df”)
#打印(df)
#打印(“x”)
#打印(x)
#打印(“y”)
#打印(y)

使用(df,ifelse)(length>x,length Ahh,好的,这是有意义的。接下来,这将生成一个包含结果的数据帧。我如何让它将新输出放在相同的旧数据帧列表中?谢谢!忽略该注释中的问题,意识到我只需要包含
;return(df)
&
SIMPLIFY=FALSE
mapply(
  function(df, x, y) {
    #print("df")
    #print(df)
    #print("x")
    #print(x)
    #print("y")
    #print(y)
    with(df, ifelse(length > x, length <- length - x, length <- length + y)) 
  },
  list,
  info$x,
  info$y
)