datacamp / tutorial

R Package to convert R Markdown files to DataCamp Light HTML files
Other
86 stars 31 forks source link

Install tidyverse on DataCamp's servers #21

Closed ismayc closed 7 years ago

ismayc commented 7 years ago

I just tried to load library(tidyverse) and library(nycflights13) in a chunk via tutorial::go_interactive() and received the Error: there is no package called 'tidyverse' error and a similar error for nycflights13. Could you provide a listing of the CRAN packages that are installed on the DataCamp servers?

filipsch commented 7 years ago

Hey @ismayc we indeed do not have all packages on DataCamp's servers. To see which packages are available, you can use rownames(installed.packages()) in the console. I'll update this issue to install tidyverse and will do this asap. I'll let you know when it's available!

ismayc commented 7 years ago

Hi @filipsch. I have tried to run rownames(installed.packages()) multiple times but get that my session has been disconnected after it tries to evaluate for a few seconds each time.

What is the process for adding new packages to DataCamp's servers? I'm particularly interested in different R packages to allow students to more easily access interesting data frames in R:

filipsch commented 7 years ago

@ismayc there's no strict policy for adding new packages on DataCamp, basically we just listen to requests like this and add packages whenever people need them. Currently there are over 4000 packages available, but they aren't are all necessarily the latest versions. We have been working on a more generic system where you can specify which packages you want in a DataCamp course and which version, but this is only supported for full-fledged DataCamp courses (that you can create through datacamp.com/teach), not via DataCamp Light chunks yet. This is on the roadmap though! I'll install tidyverse, nycflights13, babynames, fivethirtyeight and okcupiddata in a minute. Let me know if there's anything else you'd like.

ismayc commented 7 years ago

Thanks! I'm working on developing a course right now via datacamp.com/teach so that's great! I look forward to adding exercises using those packages.

filipsch commented 7 years ago

That's already possible!

devtools::install_version("tidyverse", "1.1.0")
devtools::install_version("nycflights13", "0.2.1")
...

Normally, the build logs in teach should now show that a 'course image' is being created for your course. If the build passes, you will have the packages available to you.

Let me know if you encounter any issues with this, happy to help!

In any case, I'll also make the packages available in the basic setup for courses that don't use the new system.

ismayc commented 7 years ago

Excellent! Did I overlook this in the help provided by DataCamp somewhere?

filipsch commented 7 years ago

@ismayc Yeah, it's more of an internal thing currently, we'll open it up to everybody soon.

ismayc commented 7 years ago

Ah, no problem! Just wanted to make sure I wasn't bugging you with questions when the answers were right in front of me. Thanks so much again!

ismayc commented 7 years ago

I'm still having trouble being able to use the fivethirtyeight package and am receiving the same error as before. screen shot 2017-01-23 at 1 20 38 pm

ismayc commented 7 years ago

The latest build is passing too:

screen shot 2017-01-23 at 1 26 01 pm

filipsch commented 7 years ago

Hey @ismayc I checked on DataCamp, and it works fine? Go to: https://campus.datacamp.com/courses/3085/8353?ex=1 And submit the answer; works fine for me! Let me know if you don't see the same behavior.

ismayc commented 7 years ago

Ah, I have been looking at it in the Preview window of the editor retrieved when I press Edit this Course. I would guess that Preview doesn't have the capabilities of adding packages yet?

ismayc commented 7 years ago

I've changed my workflow to just write my markdown files in RStudio, push to GitHub, and then check the results at https://campus.datacamp.com/courses/3085/8353?ex=1 . Really slick! Thanks, @filipsch!

filipsch commented 7 years ago

@ismayc as soon as you have successfully built a course image, normally the teach editor should also use that package in the preview, but I'll have to check. We recently launched a new version of the campus app, and this might have been looked over. For now, the other workflow you propose is probably the most trustworthy one. Let me know as soon as you see something out of the ordinary, happy to get some outside feedback! I'll close this for now, if that's okay.

ismayc commented 7 years ago

This workflow is great! I'm really liking it so far. I now have a separate question for you:

Is the R Markdown interface in Garrett's course available for use in other courses too like the one I am creating? I'm happy to chat in another way since we have gone far off the original issue created here.

filipsch commented 7 years ago

@ismayc yes it is, but we're not actively developing or documenting it because it's not being used in a lot of places.

This is the writeup for this exercise from garrett's course:

--- type:MarkdownExercise xp:100 skills:1,5 key:3c547b4e1b
## The R Markdown Exercise interface

For this course, DataCamp has developed a new kind of interface that looks like the R Markdown pane in RStudio. You have a space (my_document.Rmd) to write R Markdown documents, as well as the buttons to compile the R Markdown document. To keep things simple, we'll stick with making html and pdf documents, although it is also possible to create Microsoft Word documents with R Markdown.

When you click "Knit HTML", DataCamp will compile your R Markdown document and display the finished, formatted results in a new pane.

To give you a taste of the things you'll learn in this course, we've prepared two documents in the editor on the right:

- my_document.Rmd containing the actual R Markdown code;
- faded.css, a supplementary file that brands your report.

*** =instructions
- Change the title of the Markdown Document from "Ozone" to "Hello R Markdown".
- Click the "Knit HTML" button to see the compiled version of your sample code.

*** =hint
To change the title, change the value that comes after "title: " in my_document.Rmd on the right. Then, submit your work by clicking the "Knit HTML" button.

*** =sample_code
{{{my_document.Rmd}}}
---
title: "Ozone"
output:
  html_document:
    css: faded.css
---

## Data

The `atmos` data set resides in the `nasaweather` package of the *R* programming language. It contains a collection of atmospheric variables measured between 1995 and 2000 on a grid of 576 coordinates in the western hemisphere. The data set comes from the [2006 ASA Data Expo](http://stat-computing.org/dataexpo/2006/).

Some of the variables in the `atmos` data set are:

* **temp** - The mean monthly air temperature near the surface of the Earth (measured in degrees kelvin (*K*))

* **pressure** - The mean monthly air pressure at the surface of the Earth (measured in millibars (*mb*))

* **ozone** - The mean monthly abundance of atmospheric ozone (measured in Dobson units (*DU*))

You can convert the temperature unit from Kelvin to Celsius with the formula

$$ celsius = kelvin - 273.15 $$

And you can convert the result to Fahrenheit with the formula

$$ fahrenheit = celsius \times \frac{9}{5} + 32 $$

```{r, echo = FALSE, results = 'hide'}
example_kelvin <- 282.15
```

For example, `r example_kelvin` degrees Kelvin corresponds to `r example_kelvin - 273.15` degrees Celsius.

{{{faded.css}}}

h1{
  color: white;
  padding: 10px;
  background-color: #3399ff
}

ul {
  list-style-type: square;
}

.MathJax_Display {
  padding: 0.5em;
  background-color: #eaeff3
}

*** =solution
{{{solution.Rmd}}}
---
title: "Hello R Markdown"
output:
  html_document:
    css: faded.css
---

## Data

The `atmos` data set resides in the `nasaweather` package of the *R* programming language. It contains a collection of atmospheric variables measured between 1995 and 2000 on a grid of 576 coordinates in the western hemisphere. The data set comes from the [2006 ASA Data Expo](http://stat-computing.org/dataexpo/2006/).

Some of the variables in the `atmos` data set are:

* **temp** - The mean monthly air temperature near the surface of the Earth (measured in degrees kelvin (*K*))

* **pressure** - The mean monthly air pressure at the surface of the Earth (measured in millibars (*mb*))

* **ozone** - The mean monthly abundance of atmospheric ozone (measured in Dobson units (*DU*))

You can convert the temperature unit from Kelvin to Celsius with the formula

$$ celsius = kelvin - 273.15 $$

And you can convert the result to Fahrenheit with the formula

$$ fahrenheit = celsius \times \frac{9}{5} + 32 $$

```{r, echo = FALSE, results = 'hide'}
example_kelvin <- 282.15
```

For example, `r example_kelvin` degrees Kelvin corresponds to `r example_kelvin - 273.15` degrees Celsius.

{{{faded.css}}}
h1{
  color: white;
  padding: 10px;
  background-color: #3399ff
}

ul {
  list-style-type: square;
}

.MathJax_Display {
  padding: 0.5em;
  background-color: #eaeff3
}

*** =sct
```{r}
test_error()
test_rmd_file({
  test_yaml_header(options = "title",
                   not_called_msg = "Make sure to define the title on top of the R Markdown document in the editor.",
                   incorrect_msg = "Set the title of the document to \"Hello R Markdown\". Beware of typos and caps!")
  test_yaml_header(options = "output.html_document.css",
                   not_called_msg = "Don't change anything in the title apart from the document title!",
                   incorrect_msg = "Don't change anything in the title apart from the document title!")
})
success_msg("Nice job! Cool, right? Continue to the next exercise to get introduced to the basics of R Markdown.")
```

Watch out: the 'automated exercise checker' that runs on www.datacamp.com/teach currently does not work for markdown exercises. This will be fixed soon.

ismayc commented 7 years ago

Great! @rudeboybert and I are really excited about this DataCamp platform. It solves a lot of logistical issues we've had in the past in teaching students how to use and work with R. We are looking forward to testing it out this coming semester in our classroom and are glad that it will tie in nicely with our textbook at http://moderndive.com.

ismayc commented 7 years ago

A couple more questions:

If you have documentation on this that I have missed, please let me know. I'm happy to read over the help manuals but I couldn't find this on first glance.