# Poker winnings from Monday to Friday
poker_vector <- c(140, -50, 20, -120, 240)
# Roulette winnings from Monday to Friday
roulette_vector <- c(-24, -50, 100, -350, 10)
# Give names to both 'poker_vector' and 'roulette_vector'
days_vector <- c("Monday", "Tuesday", "Wednesday", "Thursday", "Friday")
names(roulette_vector) <- days_vector
names(poker_vector) <- days_vector
# What days of the week did you make money on poker?
selection_vector <- poker_vector > 0
# Select from poker_vector these days
poker_winning_days <- 我知道selection_vector是答案的一部分。只是不知道从那里往哪里走。谢谢!
发布于 2015-12-24 16:42:45
由于OP已经创建了selection_vector,我们可以这样做
names(selection_vector)[selection_vector]注意:尽管不需要在全局环境中创建一个单独的对象,但是对于一个包含7个元素的向量来说,这并没有什么坏处。
https://stackoverflow.com/questions/34455586
复制相似问题