Skip to content
This repository has been archived by the owner on Jan 30, 2024. It is now read-only.

Commit

Permalink
Merge branch 'master' into contributors
Browse files Browse the repository at this point in the history
  • Loading branch information
maxheld83 authored May 31, 2019
2 parents c22e07c 266d1a0 commit 3290ef5
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 6,6 @@ title: About
[![Actions Status](https://wdp9fww0r9.execute-api.us-west-2.amazonaws.com/production/badge/soztag/fossos)](https://github.com/soztag/fossos/actions)
<!-- badges: end -->

*Free and Open Source Software for Open Science* ("FOSSOS") is **an ongoing series of seminars** taught by [Max Held](http://www.maxheld.de) at [Friedrich-Alexander Universität Erlangen-Nürnberg (FAU)](https://www.fau.de) at the department of sociology, introducing students to R, as well as the broader open science ecosystem and free and open source best practices and tools.
*Free and Open Source Software for Open Science* ("FOSSOS") is **an ongoing series of seminars** taught by [Max Held](http://www.maxheld.de) at [Friedrich-Alexander Universität Erlangen-Nürnberg (FAU)](https://www.fau.de) at the Department of Sociology, introducing students to R, as well as the broader open science ecosystem and free and open source best practices and tools.

This repository houses the resources for these classes, and all class-related activities are tracked in the above issues.
1 change: 0 additions & 1 deletion index.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 345,6 @@ We're going to use a few digital tools to get organised in this class, all based
- A (currently relevant) subset of these issues are also listed on our **Kanban board** at https://github.com/soztag/fossos/projects/2.
This board gives you an overview what we will be working on in the current and coming sessions.
You can move your "own" issues around the board as appropriate, and you can also add issues that you want to see addressed.
- For more loosely defined conversation (not in the form of a closable issue), there is also a **discussion board** at https://github.com/orgs/soztag/teams/fossos-18-ws.

These venues are also linked from the top bar of the class website, so you can always easily find them.

Expand Down
82 changes: 82 additions & 0 deletions r_intro_datatypes.R
Original file line number Diff line number Diff line change
@@ -0,0 1,82 @@
food_drink <- c("coffee", "tea", "cake", "sugar")
subset(food_drink, c(TRUE, FALSE, TRUE, TRUE))
food_drink[c(TRUE, FALSE, TRUE, TRUE)]
food_drink[c(2, 4)]
food_drink[-2]
food_drink[1:2]
food_drink[food_drink == "tea"]
food_drink[stringr::str_length(food_drink) > 3]

c("coffee", "tea") == "tea"
# type ! = for UNEQUAL operator
# type == for EQUAL operator


#===== Matrices
m <- matrix(data = c(1,2,3,4), nrow = 2)

a <- array(data = 1:8, dim = c(2, 2, 2))
a[ ,1 ,]


#==== list
# rmarkdown::render_site(input = ".") # this is a normal function, which only accepts SOME named arguments
l <- list(number = c(12,13), fruit = "apple", nested_list = list(first = 1/3, second = 2/3))
# list is a special kind of function that also allows arbitrary numbers of arbitrarily named arguments (Non-standard evaluation, NSE)
# sum(l[1]) # this does not work because it just gives the "box", which can't be summed
sum(l[[1]])
l["fruit"] # this gives the box
l[["fruit"]] # this gives content of the box
l$fruit # same as line above, just with syntatic sugar

# ========= names
vec <- c(one = 1, five = 5) # now a named vector
vec[1] # can still subset on indeces
vec["five"] # can also subset on the name
vec[["five"]] # this works as well, but gives same result, because there's no box

l["fruit"] # same syntax as for vectors

# matrices can also have names

m <- matrix(
data = m,
nrow = 2,
dimnames = list(
countries = c("france", "germany"),
fruit = c("grapes", "apples")
)
)

m["france", "apples"]

unnamed_vec <- c(1, 2)
names(unnamed_vec) <- c("one", "two")
# this is how names are actually done behind the scenes
# name_this(object = unnamed_vec, names = c("one", "two")) # line 55 is, in turn, a cleverer version of something like line 56 implemented in C, which is why we can't use/see it directly

# ==== dataframes
# below separate vectors are scary, because the ordering might change and links between same individuals might get confused
# indeces are individuals in the below, but this is not visible or properly stored
df <- data.frame(
# DATA (this gets filled into the ... argument)
shoesize = c(39, 42, 45),
age = c(21, 19, 24),
gender = c("female", "other", "male"),
name = c("Lisa", "Alex", "Peter"),

# OTHER ARGUMENTS
stringsAsFactors = FALSE
# what is a data frame?
# list of vectors each with the same length
# indeces match across rows
# list elements (which become df columns) are vectors
# (later on, columns also be lists or matrices)
)
df

# question: how to find row based on some value in a cell
df
df$name == "Alex"
df[df$name == "Alex", ]
View(df)
4 changes: 2 additions & 2 deletions stack.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 245,7 @@ We will be using different programs going forward.

### Containerisation {#docker}

<i class="fab fa-docker fa-3x fa-rotate-180 fa-flip-vertical fa-pull-left"></i><a class="btn btn-info" href="https://www.docker.com/products/docker-desktop" role="button">Install Docker Desktop</a>
<i class="fab fa-docker fa-3x fa-pull-left"></i><a class="btn btn-info" href="https://www.docker.com/products/docker-desktop" role="button">Install Docker Desktop</a>

Docker is an open-source industry standard to define, provision and share computing environments, known as *containers*.
Containers allow you to run computing environments on other computers.
Expand Down Expand Up @@ -277,7 277,7 @@ We are using it in this class to reduce the burden of local installations, but i
3. Launch a system shell and type in

```
docker run -e PASSWORD=yourpassword --rm -p 8787:8787 rocker/verse
docker run --env=PASSWORD=yourpassword --rm --publish=8787:8787 rocker/verse
```

On macOS and Linux, your default system shell is an application called "Terminal".
Expand Down

0 comments on commit 3290ef5

Please sign in to comment.