I have created a test function, called testFunc which expects two arguments.
testFunc<-function(x,y){
length(x)
nrow(y)
}
Now I want to use lappy to apply this function to a list, keeping the y argument fixed.
Consider a test list, testList:
testList<-list(a=c(1,2,3,4,5,5,6),b=c(1,2,4,5,6,7,8))
Can we use lapply to run testFunc on testList$a and testList$b with same value of y?
I tried this call:
lapply(X = testList, FUN = testFunc, someDataFrame)
But I am always getting the length of someDataFrame as the output. Am I missing something obvious.
yto be fixed within the function and use onlyxas argument? i.e.testfunc <- function(x, y=...) {...}?