Skip to content

Commit b2a975b

Browse files
committed
updates to data and some homework problems
1 parent 2bb1e98 commit b2a975b

37 files changed

+10703
-416
lines changed

content/code/api.pdf

842 KB
Binary file not shown.

content/code/basics.pdf

244 KB
Binary file not shown.

content/code/dplyr.pdf

344 KB
Binary file not shown.

content/code/git.pdf

199 KB
Binary file not shown.

content/code/iteration.pdf

223 KB
Binary file not shown.

content/code/lists.Rmd

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,82 @@ Reduce(rbind, lst)
391391

392392

393393

394+
395+
### Practice problems with lists
396+
397+
```{r}
398+
set.seed(123)
399+
mats <- lapply(1:100, function(x){
400+
matrix(rbinom(5000, 1, 0.3), ncol=rpois(1,20))
401+
})
402+
```
403+
404+
405+
406+
Use either a for loop or an apply statement to calculate the number of rows and columns in the `mats` list defined above.
407+
408+
```{r}
409+
410+
411+
412+
```
413+
414+
415+
Calculate the column sums of each matrix in `mats` and return the object as a list.
416+
417+
```{r}
418+
419+
420+
```
421+
422+
423+
424+
425+
426+
Subset `mats` to include only the matrices that have more than 250 rows. How many matrices are left in the subset list?
427+
428+
```{r}
429+
430+
431+
```
432+
433+
434+
435+
436+
437+
Calculate the fraction of values that are 1 for each matrix in `mats`
438+
439+
```{r}
440+
441+
442+
443+
```
444+
445+
446+
447+
448+
449+
450+
451+
452+
Write code to make each matrix column it's own list element, while keeping the structure of the `mats` list.
453+
454+
So this means that list element 1 would have 16 nested list elements, with each list element corresponding to the values of columns from `mats[[1]]`.
455+
456+
457+
```{r}
458+
459+
460+
```
461+
462+
463+
464+
465+
466+
467+
468+
469+
394470
## sessionInfo
395471

396472
```{r}

0 commit comments

Comments
 (0)