# NOT RUN {
field1 <- structField("a", "integer")
field2 <- structField("c", "string")
field3 <- structField("avg", "double")
schema <- structType(field1, field2, field3)
df1 <- gapply(df, list("a", "c"),
function(key, x) { y <- data.frame(key, mean(x$b), stringsAsFactors = FALSE) },
schema)
# }
Run the code above in your browser using DataLab