Skip to main content
Code input and output

Learn how to show input and output on your slides.

Amy Peterson avatar
Written by Amy Peterson
Updated over a week ago

Question:

When I write a command, I want to show the result of this command to my students. Is there a way to execute code in a slide to get the output?

Answer:

While it is not possible to execute code in the editor, you can show the input code, and its output is to use two separate code blocks, as shown below:

# Reading in data
data(ChickWeight)

# Printing out the first few lines
head(ChickWeight)

  weight Time Chick Diet
1     42    0     1    1
2     51    2     1    1
3     59    4     1    1
4     64    6     1    1
5     76    8     1    1
6     93   10     1    1


Make sure to add a line break between your input and output and add animation to each code block, so it can separately and in sequential order.

Did this answer your question?