Skip to content

Commit c13eefd

Browse files
Merge pull request #159 from ytakemon/iss157_YT
Updates challenge on creating tables using select() and ends_with() fixes #157 , fixes #158
2 parents 9a7faed + f30a48d commit c13eefd

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

episodes/05-dplyr.Rmd

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,12 +129,25 @@ select(variants, ends_with("B"))
129129
>
130130
> Create a table that contains all the columns with the letter "i" and column "POS",
131131
> without columns "Indiv" and "FILTER".
132-
> Hint: look at the help function `ends_with()` we've just covered.
132+
> Hint: look at for a function called `contains()`, which can be found in the help documentation for ends with we just covered (`?ends_with`). Note that contains() is not case sensistive.
133133
>
134134
>> ## Solution
135135
>>
136136
>> ```{r}
137-
>> select(variants, contains("i"), -Indiv, -FILTER, POS)
137+
>> # First, we select "POS" and all columns with letter "i". This will contain columns Indiv and FILTER.
138+
>> variants_subset <- select(variants, POS, contains("i"))
139+
>> # Next, we remove columns Indiv and FILTER
140+
>> variants_result <- select(variants_subset, -Indiv, -FILTER)
141+
>> variants_result
142+
>> ```
143+
>
144+
> We can also get to `variants_result` in one line of code:
145+
>
146+
>> ## Alternative solution
147+
>>
148+
>> ```{r}
149+
>> variants_result <- select(variants, POS, contains("i"), -Indiv, -FILTER)
150+
>> variants_result
138151
>> ```
139152
> {: .solution}
140153
{: .challenge}

0 commit comments

Comments
 (0)