Skip to content

Commit 9e21ec2

Browse files
Update 01-r-basics.Rmd
fixes #184
1 parent bd42ebf commit 9e21ec2

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

episodes/01-r-basics.Rmd

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -417,28 +417,28 @@ the name of the vector followed by square brackets. In those square brackets
417417
we place the index (e.g. a number) in that bracket as follows:
418418

419419
```{r, purl = FALSE}
420-
# get the 3rd value in the snp_genes vector
421-
snp_genes[3]
420+
# get the 3rd value in the snp vector
421+
snp[3]
422422
```
423423

424424
In R, every item your vector is indexed, starting from the first item (1)
425425
through to the final number of items in your vector. You can also retrieve a
426426
range of numbers:
427427

428428
```{r, purl = FALSE}
429-
# get the 1st through 3rd value in the snp_genes vector
429+
# get the 1st through 3rd value in the snp vector
430430
431-
snp_genes[1:3]
431+
snp[1:3]
432432
```
433433

434434
If you want to retrieve several (but not necessarily sequential) items from
435435
a vector, you pass a **vector of indices**; a vector that has the numbered
436436
positions you wish to retrieve.
437437

438438
```{r, purl = FALSE}
439-
# get the 1st, 3rd, and 4th value in the snp_genes vector
439+
# get the 1st, 3rd, and 4th value in the snp vector
440440
441-
snp_genes[c(1, 3, 4)]
441+
snp[c(1, 3, 4)]
442442
```
443443

444444
There are additional (and perhaps less commonly used) ways of subsetting a
@@ -447,9 +447,9 @@ examples](https://thomasleeper.com/Rcourse/Tutorials/vectorindexing.html)).
447447
Also, several of these subsetting expressions can be combined:
448448

449449
```{r, purl = FALSE}
450-
# get the 1st through the 3rd value, and 4th value in the snp_genes vector
450+
# get the 1st through the 3rd value, and 4th value in the snp vector
451451
# yes, this is a little silly in a vector of only 4 values.
452-
snp_genes[c(1:3,4)]
452+
snp[c(1:3,4)]
453453
```
454454

455455
## Adding to, removing, or replacing values in existing vectors
@@ -458,7 +458,7 @@ Once you have an existing vector, you may want to add a new item to it. To do
458458
so, you can use the `c()` function again to add your new value:
459459

460460
```{r, purl = FALSE}
461-
# add the gene 'CYP1A1' and 'APOA5' to our list of snp genes
461+
# add the gene "CYP1A1" and "APOA5" to our list of snp genes
462462
# this overwrites our existing vector
463463
snp_genes <- c(snp_genes, "CYP1A1", "APOA5")
464464
```

0 commit comments

Comments
 (0)