I've got the following code:
fit.list <- lapply(sample.names, function(sample.name) {
lapply(f1(target), function(seq.name) {
f2(arguments)
})
})
f2 is returning sometimes:
warning("Warning message")
return(NULL)
How can I catch the warning message inside the second lapply? I'm a newbie to R, excuse me.
EDITED:
Could be one of these workarounds?
1
tryCatch({
fit.list <- lapply(sample.names, function(sample.name) {
print(sample.name);
lapply(f1(target), function(seq.name) {
f2(arguments)
})
})
},
warning=function(e) {
message(paste("Warning caused by sample:", sample))
return(NULL)
})
2
fit.list <- lapply(sample.names, function(sample.name) {
tryCatch({
lapply(f1(target), function(seq.name) {
f2(arguments)
})
},
warning=function(e) {
message(paste("Warning caused by sample:", sample))
return(NULL)
})
})
3
fit.list <- lapply(sample.names, function(sample.name) {
lapply(f1(target), function(seq.name) {
tryCatch({
f2(arguments)
},
warning=function(e) {
message(paste("Warning caused by sample:", sample))
return(NULL)
})
})
})
Thank you very much!