Skip to content
Prev 395339 / 398502 Next

by function does not separate output from function with, mulliple parts

Dear John,

Printing inside the function is problematic. Your function itself does 
NOT print the labels.

Just as a clarification:

F = factor(rep(1:2, 2))
by(data.frame(V = 1:4, F = F), F, function(x) { print(x); return(NULL); } )
#?? V F
# 1 1 1
# 3 3 1
#?? V F
# 2 2 2
# 4 4 2
# F: 1 <- this is NOT printed inside the function
# NULL
# ---------------------------------------------------------
# F: 2
# NULL

### Return Results
by(data.frame(V = 1:4, F = F), F, function(x) { return(x); } )
# F: 1
# ? V F
# 1 1 1
# 3 3 1
# --------------------------------------------------
# F: 2
#?? V F
# 2 2 2
# 4 4 2

Maybe others on the list can offer further assistance.

Sincerely,

Leonard