Skip to content

Commit

Permalink
Merge pull request #1096 from ethanwhite/loops-updates
Browse files Browse the repository at this point in the history
Updates to loops assignment
  • Loading branch information
ethanwhite authored Oct 29, 2024
2 parents 0c223d7 + b12f5e3 commit 31c9304
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
4 changes: 2 additions & 2 deletions assignments/r-iteration-2.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ layout: page
element: assignment
title: Repeating Things 2
language: R
exercises: ['Basic For Loops', 'Size Estimates By Name Loop','Multi-file Analysis', 'Check That Your Code Runs', 'DNA or RNA Iteration', 'Cocili Data Exploration', 'Length of Floods']
points: [25, 25, 40, 10, 'Challenge - optional', 'Challenge - optional', 'Challenge - optional']
exercises: ['Basic For Loops', 'Size Estimates By Name Loop','Multi-file Analysis', 'DNA or RNA Iteration', 'Check That Your Code Runs', 'Cocili Data Exploration', 'Length of Floods']
points: [20, 20, 20, 30, 10, 'Challenge - optional', 'Challenge - optional']
---

### Learning Objectives
Expand Down
8 changes: 7 additions & 1 deletion exercises/Loops-basic-for-loops-R.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,13 @@ for (__ in 1:length(________)){
areas
```

5\. Complete the code below to calculate an area for each pair of `lengths` and `widths`, store the areas in a vector, and after they are all calculated print them out:
5\. Write a for loop that loops over the following vector and stores the height in meters (height_m = height_ft / 3.28) in a new vector. After the for loop make sure to display the vector to the console by running the vectors name on its own line.

```r
height_ft <- c(5.1, 6.3, 5.7, 5.4)
```

6\. Complete the code below to calculate an area for each pair of `lengths` and `widths`, store the areas in a vector, and after they are all calculated print them out:

```r
lengths = c(1.1, 2.2, 1.6)
Expand Down
9 changes: 5 additions & 4 deletions exercises/Making-choices-dna-or-rna-iteration-R.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,15 @@ sequence the only way to tell the difference between DNA and RNA is that
RNA has the base Uracil (`"u"`) instead of the base Thymine (`"t"`). Have the
function return one of three outputs: `"DNA"`, `"RNA"`, or `"UNKNOWN"`.

1. Use the function and a `for` loop to print the type of the sequences in the
following list.
2. Use the function and `sapply` to print the type of the sequences in the
following list.
Copy and paste the following sequence data into your script:

```
sequences = c("ttgaatgccttacaactgatcattacacaggcggcatgaagcaaaaatatactgtgaaccaatgcaggcg", "gauuauuccccacaaagggagugggauuaggagcugcaucauuuacaagagcagaauguuucaaaugcau", "gaaagcaagaaaaggcaggcgaggaagggaagaagggggggaaacc", "guuuccuacaguauuugaugagaaugagaguuuacuccuggaagauaauauuagaauguuuacaacugcaccugaucagguggauaaggaagaugaagacu", "gauaaggaagaugaagacuuucaggaaucuaauaaaaugcacuccaugaauggauucauguaugggaaucagccggguc")
```

1. Use the function you wrote and a `for` loop to create a vector of sequence types for the values in `sequences`
2. Use the function and a `for` loop to create a data frame that includes a column of sequences and a column of their types
3. Use the function and `sapply` to create a vector of sequence types for the values in `sequences`

*Optional: For a little extra challenge make your function work with both upper
and lower case letters, or even strings with mixed capitalization*

0 comments on commit 31c9304

Please sign in to comment.