เริ่มต้นใช้งานเริ่มต้นใช้งานได้ฟรี

Working with Environments (1)

The environment variable type is similar to a list in that it can contain other variables.

You can create a new environment using new.env() (docs).

Variables can be added to the environment using the same syntax as for lists, that is, you can use the $ and [[ operators.

แบบฝึกหัดนี้เป็นส่วนหนึ่งของหลักสูตร

Object-Oriented Programming with S3 and R6 in R

ดูคอร์ส

คำแนะนำการฝึกหัด

  • Create a new environment named env.
  • Use the dollar operator to add an element to env named perfect that contains the first three perfect numbers, 6, 28, 496.
  • Use the double square bracket operator to add an element to env named bases that contains the letters of DNA bases, A, C, G, T.

แบบฝึกหัดเชิงโต้ตอบแบบลงมือทำ

ลองทำแบบฝึกหัดนี้โดยเติมโค้ดตัวอย่างนี้ให้สมบูรณ์

# Define a new environment
env <- 
  
# Add an element named perfect
  

# Add an element named bases
  
แก้ไขและรันโค้ด