Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using okgrade with R in Jupyter #5

Open
ttimbers opened this issue Jun 12, 2018 · 1 comment
Open

Using okgrade with R in Jupyter #5

ttimbers opened this issue Jun 12, 2018 · 1 comment

Comments

@ttimbers
Copy link

I would like to use okgrade with R in Jupyter - how I start to move forward on this and make this possible?

Some naive ideas I have started to play with include using reticulate (an R package that lets you call Python from R) to import okgrade and call the grade function. And then to use the rpy2 library to call R from Python for the tests in the .py files in tests directory. This seems like a hacky workaround which is less than ideal... Any help/ideas would be appreciated!

@jkuruzovich
Copy link

jkuruzovich commented Jul 21, 2018

I'd love to be able to support some of our R users and I think R support would be a great enhancement. I have a little funding to hire one of our students and might give a shot.

I've been creating R tests with test_that.

#This will load the library.
library('testthat')
#This will generate a file with the output from the tests. You should be sure to test and submit the commit tests.md file.
sink("tests.md")
test_file("test.intro-r-exercises.R", reporter = "tap")
sink() 

The test file looks like this:

  test_that("Q1 Create a variable called sepal_width.mean", {
    expect_equal(sepal_width.mean, 3.054)
  })

  test_that("Q2Create a new column of iris.df called sepalArea", {
    expect_equal(mean(iris.df$sepal_area), 17.80653,tolerance=1e-3)
  })

  test_that("Q3 Create a new dataframe iristrain.df that includes the first 75 rows", {
    expect_equal(nrow(iristrain.df), 75)
    expect_equal(mean(iristrain.df$sepal_length), 5.341333,tolerance=1e-3)
  })

  test_that("Q4 Create a new dataframe iristest.df that includes the last 75 rows of the iris dataframe.", {
    expect_equal(nrow(iristest.df), 75)
    expect_equal(mean(iristest.df$sepal_length), 6.345333,tolerance=1e-3)
  })

  test_that("(5). Create a new vector sepal_length from the sepal_length column of the iris dataframe.", {
    expect_equal(mean(sepal_length), 5.843333,tolerance=1e-3)
    expect_equal(length(sepal_length), 150)
  })

I think if there were a standard way of specifying the tests (similar to R and Python) and a common output file structure, the system would be able to be somewhat agnostic between R and Python.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants