Stop lapply from printing to console

前端 未结 3 1987
故里飘歌
故里飘歌 2020-12-03 00:37

When I use lapply and print to the console it prints unwanted [[i]]NULL though I want the intended message to print to the console. I\'ve tried

3条回答
  •  眼角桃花
    2020-12-03 01:22

    Use l_ply from plyr:

    library(plyr)
    FUN <- function(x) {
        FUN2 <- function(z) message(z)
        l_ply(1:3, function(i) FUN2(paste(x, i)))
    }
    FUN("hello")
    

提交回复
热议问题