Displaying 1 result from an estimated 1 matches for "fcttest".
Did you mean:
pcttest
2010 Nov 19
3
Still confused with lapply
...wing that I cannot change the structure of the function).
I hope you understand my french explainations ...
Thanks in advance for your help,
Have a nice week-end,
Ptit Bleu.
df1<-data.frame(c(1,2,3,4), c(9,6,5,8), c(5,4,8,6))
names(df1)<-c("C1", "C2", "C3")
fcttest<-function(a1,a2,a3) {
v<-a1*a2
w<-a2+a3
return(c(v,w))
}
# The following for loop works
result<-data.frame()
for (i in 1:length(df1[,1])) {
result<-rbind(result,fcttest(df1[i,1],df1[i,2],df1[i,3]))
}
# But the command
lapply(df1, fcttest)
# gives (in french, sorry)
# Erreur da...