# sc <- sparkR.init(master="local")
# sqlContext <- sparkRSQL.init(sc)
#
# on.exit({
# message("Stopping Spark...")
# sparkR.stop()
# message("OK.")
# })
#
# suppressPackageStartupMessages(library(dplyr))
# suppressPackageStartupMessages(library(nycflights13))
#
# set.seed(123)
# data <- sample_n(flights, 10000)
# df <- createDataFrame(sqlContext, data.frame(data))
#
# prior_library(SparkRext)
#
# context("filter")
#
# test_that("one condition", {
# result <- filter(df, month == 12) %>% count
# expect_equal(result, 883)
# })
#
# test_that("two conditions", {
# result <- filter(df, month == 12, day == 31) %>% count
# expect_equal(result, 27)
# })
#
# test_that("no conditions", {
# expect_error(filter(df), "unable to find an inherited method for function*")
# })
#
# test_that("use variable", {
# x <- 12
# result <- filter(df, month == x) %>% count
# expect_equal(result, 883)
# })
#
# test_that("use variable same name", {
# x <- list(month = 12)
# result <- filter(df, month == x$month) %>% count
# expect_equal(result, 883)
# })
#
# test_that("with pipe", {
# result <- df %>% filter(month == 12) %>% count
# expect_equal(result, 883)
# })
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.