Skip to content

Commit 31c9304

Browse files
authored
Merge pull request #1096 from ethanwhite/loops-updates
Updates to loops assignment
2 parents 0c223d7 + b12f5e3 commit 31c9304

File tree

3 files changed

+14
-7
lines changed

3 files changed

+14
-7
lines changed

assignments/r-iteration-2.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ layout: page
33
element: assignment
44
title: Repeating Things 2
55
language: R
6-
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']
7-
points: [25, 25, 40, 10, 'Challenge - optional', 'Challenge - optional', 'Challenge - optional']
6+
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']
7+
points: [20, 20, 20, 30, 10, 'Challenge - optional', 'Challenge - optional']
88
---
99

1010
### Learning Objectives

exercises/Loops-basic-for-loops-R.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,13 @@ for (__ in 1:length(________)){
4040
areas
4141
```
4242

43-
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:
43+
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.
44+
45+
```r
46+
height_ft <- c(5.1, 6.3, 5.7, 5.4)
47+
```
48+
49+
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:
4450

4551
```r
4652
lengths = c(1.1, 2.2, 1.6)

exercises/Making-choices-dna-or-rna-iteration-R.md

+5-4
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,15 @@ sequence the only way to tell the difference between DNA and RNA is that
1414
RNA has the base Uracil (`"u"`) instead of the base Thymine (`"t"`). Have the
1515
function return one of three outputs: `"DNA"`, `"RNA"`, or `"UNKNOWN"`.
1616

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

2219
```
2320
sequences = c("ttgaatgccttacaactgatcattacacaggcggcatgaagcaaaaatatactgtgaaccaatgcaggcg", "gauuauuccccacaaagggagugggauuaggagcugcaucauuuacaagagcagaauguuucaaaugcau", "gaaagcaagaaaaggcaggcgaggaagggaagaagggggggaaacc", "guuuccuacaguauuugaugagaaugagaguuuacuccuggaagauaauauuagaauguuuacaacugcaccugaucagguggauaaggaagaugaagacu", "gauaaggaagaugaagacuuucaggaaucuaauaaaaugcacuccaugaauggauucauguaugggaaucagccggguc")
2421
```
2522

23+
1. Use the function you wrote and a `for` loop to create a vector of sequence types for the values in `sequences`
24+
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
25+
3. Use the function and `sapply` to create a vector of sequence types for the values in `sequences`
26+
2627
*Optional: For a little extra challenge make your function work with both upper
2728
and lower case letters, or even strings with mixed capitalization*

0 commit comments

Comments
 (0)