首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >将您在盈利天数中赢得的金额分配给变量poker_winning_days

将您在盈利天数中赢得的金额分配给变量poker_winning_days
EN

Stack Overflow用户
提问于 2015-12-24 16:35:00
回答 1查看 314关注 0票数 2
代码语言:javascript
复制
# 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是答案的一部分。只是不知道从那里往哪里走。谢谢!

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-12-24 16:42:45

由于OP已经创建了selection_vector,我们可以这样做

代码语言:javascript
复制
names(selection_vector)[selection_vector]

注意:尽管不需要在全局环境中创建一个单独的对象,但是对于一个包含7个元素的向量来说,这并没有什么坏处。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/34455586

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档