# NOT RUN {
schema <- structType(structField("a", "integer"), structField("c", "string"),
structField("avg", "double"))
df1 <- gapply(df, list("a", "c"),
function(key, x) { y <- data.frame(key, mean(x$b), stringsAsFactors = FALSE) },
schema)
schema <- structType("a INT, c STRING, avg DOUBLE")
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