In: Computer Science
# How do you select the the vector c(7, 8, 9) using the following four approaches
# (1) Using the [[]] operator once and only once # Your code below
(2) Using the [] operator once # Your code below
(3) Using the $ operator # Your code below
(4) Using a column vector name without using the $ operator # Your code below
ANSWER:
CODE TEXT
# defining a dataframe with columname value and c(7,8,9)
df <- data.frame(value=c(7,8,9))
# (1) Using the [[]] operator once and only once
df[[1]]
# (2) Using the [] operator once\
df[,1]
# (3) Using the $ operator
df$value
# (4) Using a column vector name without using the $ operator
df[,"value"]
CODE IMAGE
OUTPUT IMAGE