Leonard Mada
2023-Oct-25 12:43 UTC
[R] 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