For loops in R to make all vs. all comparisons: Strategies for making them more efficient (CC053)

Опубликовано: 07 Декабрь 2020
на канале: Riffomonas Project
509
9

For loops are rightfully disparaged amongst R programmers. Why? In this episode I show how to write for loops in R and how to use modification in place to make them more efficient as we try to make an all vs. all comparison amonst a large number of rows in a data frame. Along the way we also use the address and object_size functions from the pryr package. This episode is part of a larger arc of episodes investigating the sensitivity and specificity of amplicon sequence variants (ASVs), also known as exact sequence variants (ESVs). ASVs are growing in popularity for analyzing microbial communities using 16S rRNA gene sequences. Pat demonstrates these concepts by live coding at the command line interface using RStudio, GitHub Flow, and make.

0:00 Introduction
2:50 Tradeoffs in speed and memory
8:02 Writing for loops
13:22 Benchmarking for loops
15:24 Modification in place
20:43 Conclusion

The accompanying blog post contains the exercises and solutions can be found at http://www.riffomonas.org/code_club/2...