LoslegenKostenlos loslegen

Working with Environments (2)

Most types of R variable use "copy by value", meaning that when you take a copy of them, the new variable has its own copy of the values. In this case, changing one variable does not affect the other.

Environments use a different system, known as "copy by reference", so that all copies are identical; changing one copy changes all the copies.

Useful biology fact: RNA bases are slightly different to DNA bases. They are A, C, G, and U.

Diese Übung ist Teil des Kurses

Object-Oriented Programming with S3 and R6 in R

Kurs anzeigen

Interaktive Übung

Versuche dich an dieser Übung, indem du diesen Beispielcode vervollständigst.

# Assign lst
lst <- list(
  perfect = c(6, 28, 496),
  bases = c("A", "C", "G", "T")
)

# Copy lst
lst2 <- ___
  
# Change lst's bases element
___
  
# Test lst and lst2 identical
___ 
Code bearbeiten und ausführen