Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
Lesson Template
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
prace-lessons
Lesson Template
Commits
8762c560
Commit
8762c560
authored
8 years ago
by
Greg Wilson
Browse files
Options
Downloads
Patches
Plain Diff
Displaying generated files
parent
5b16dd23
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
_episodes/07-rmarkdown-example.md
+104
-0
104 additions, 0 deletions
_episodes/07-rmarkdown-example.md
bin/setup-labels
+0
-84
0 additions, 84 deletions
bin/setup-labels
fig/swc-rmd-plot-example-1.png
+0
-0
0 additions, 0 deletions
fig/swc-rmd-plot-example-1.png
with
104 additions
and
84 deletions
_episodes/07-rmarkdown-example.md
0 → 100644
+
104
−
0
View file @
8762c560
---
title
:
"
Using
RMarkdown"
teaching
:
10
exercises
:
2
questions
:
-
"
How
to
write
a
lesson
using
RMarkdown?"
objectives
:
-
"
Explain
how
to
use
RMarkdown
with
the
new
lesson
template."
-
"
Demonstrate
how
to
include
pieces
of
code,
figures,
and
challenges."
keypoints
:
-
"
It
shouldn't
be
difficult"
---
This episode demonstrates all the features that can be used when writing a
lesson in RMarkdown.
This first chunk is really important, and should be included in all markdown lessons.
The rest of the lesson should be written as a normal RMarkdown file. You can
include chunk for codes, just like you'd normally do:
Normal output:
~~~
{.r}
1 + 1
~~~
{: .source}
~~~
[1] 2
~~~
{: .output}
Output with error message:
~~~
{.r}
x[10]
~~~
{: .source}
~~~
Error in eval(expr, envir, enclos): object 'x' not found
~~~
{: .error}
Output generating figures:
~~~
{.r}
library(ggplot2)
~~~
{: .source}
~~~
Warning: package 'ggplot2' was built under R version 3.1.3
~~~
{: .error}
~~~
{.r}
ggplot(diamonds, aes(x = carat, y = price, color = cut)) +
geom_point()
~~~
{: .source}
<img
src=
"../fig/swc-rmd-plot-example-1.png"
title=
"plot of chunk plot-example"
alt=
"plot of chunk plot-example"
style=
"display: block; margin: auto;"
/>
For the challenges and their solutions, you need to pay attention to the where
the
`>`
go and where to leave blank lines. Otherwise, you can include chunks in
it to include instructions and solutions.
> ## Challenge: Can you do it?
>
> What is the output of this command?
>
>
> ~~~{.r}
> paste("This", "new", "template", "looks", "good")
> ~~~
> {: .source}
>
> > ## Solution
> >
> >
> > ~~~
> > [1] "This new template looks good"
> >
> > ~~~
> > {: .output}
> {: .solution}
{: .challenge}
This diff is collapsed.
Click to expand it.
bin/setup-labels
deleted
100755 → 0
+
0
−
84
View file @
5b16dd23
#!/bin/bash
#
## This script sets up labels for issues in your GitHub repository.
##
## Syntax:
##
## $ tools/setup-label OWNER REPO
##
## Parameters:
##
## - OWNER: GitHub username of the owner of the repository
## - REPO: the name of the repository
##
## Example:
##
## For set up the labels at https://github.com/wking/swc-modular-shell use
##
## $ tools/setup-label wking swc-modular-shell
CURL_FLAGS
=
"--silent --fail"
if
test
$#
-lt
2
then
echo
"Missing parameters."
echo
grep
'^##'
tools/setup-labels |
sed
's/## //'
|
sed
's/##//'
exit
1
fi
OWNER
=
$1
REPO
=
$2
GITHUB_URL
=
https://github.com/
${
OWNER
}
/
${
REPO
}
LABELS
=(
bug build defer discussion documentation enhancement newcomer-friendly upstream work-in-progress
)
COLORS
=(
FF0000 551033 66FF00 0000FF D4318C E0115F FCE883 83F52C 545AA7
)
LABELS_TO_DELETE
=(
duplicate filed-by-newcomer getting-started
help
%20wanted help-wanted invalid left-as-was suitable-for-newcomer question wontfix
)
# Test if repository exists
curl
-s
--head
${
GITHUB_URL
}
|
head
-n
1 |
grep
-q
"HTTP/1.[01] [23].."
if
test
$?
-ne
0
then
echo
"ERROR: this repository doesn't exist"
exit
$?
fi
echo
"Before setup the labels for
${
GITHUB_URL
}
"
echo
"you must provide some informations."
echo
"Your GitHub username:"
read
USERNAME
echo
"Your GitHub password:"
read
-s
PASSWORD
# Delete labels
for
INDEX
in
$(
seq
0
$((${#
LABELS_TO_DELETE
[*]
}
-
1
))
)
do
# Try to delete label
curl
${
CURL_FLAGS
}
-X
DELETE
\
-u
${
USERNAME
}
:
${
PASSWORD
}
\
"https://api.github.com/repos/
${
OWNER
}
/
${
REPO
}
/labels/
${
LABELS_TO_DELETE
[
${
INDEX
}
]
}
"
>
/dev/null
done
# Create labels
for
INDEX
in
$(
seq
0
$((${#
LABELS
[*]
}
-
1
))
)
do
# Try create new label
curl
${
CURL_FLAGS
}
-X
POST
\
-u
${
USERNAME
}
:
${
PASSWORD
}
\
-d
"{
\"
name
\"
:
\"
${
LABELS
[
${
INDEX
}
]
}
\"
,
\"
color
\"
:
\"
${
COLORS
[
${
INDEX
}
]
}
\"
}"
\
"https://api.github.com/repos/
${
OWNER
}
/
${
REPO
}
/labels"
>
/dev/null
if
test
$?
-ne
0
then
# Try to fix label color
curl
${
CURL_FLAGS
}
-X
PATCH
\
-u
${
USERNAME
}
:
${
PASSWORD
}
\
-d
"{
\"
name
\"
:
\"
${
LABELS
[
${
INDEX
}
]
}
\"
,
\"
color
\"
:
\"
${
COLORS
[
${
INDEX
}
]
}
\"
}"
\
"https://api.github.com/repos/
${
OWNER
}
/
${
REPO
}
/labels/
${
LABELS
[
${
INDEX
}
]
}
"
>
/dev/null
if
test
$?
-ne
0
then
echo
"Failed when trying to create and update the label
${
LABELS
[
${
INDEX
}
]
}
."
echo
"Please check at
${
GITHUB_URL
}
/labels"
echo
""
echo
"If you find a bug report it at"
echo
"https://github.com/swcarpentry/lesson-template/."
fi
fi
done
This diff is collapsed.
Click to expand it.
fig/swc-rmd-plot-example-1.png
0 → 100644
+
0
−
0
View file @
8762c560
135 KiB
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment