使用二进制值时 R 中的直方图
我有几所学校的学生数据。我想使用 R 显示每所学校通过测试的所有学生百分比的直方图。 我的数据看起来像这样(id,学校,通过/失败):
432342 school1通过
454233 school2失败
543245 school1失败
等'
(重点是我只对通过的学生的百分比感兴趣,显然是那些没有通过的学生我想为每所学校有一栏,显示该学校通过的学生的百分比)
谢谢
I have data of students from several schools. I want to show a histogram of the percentage of all students that passed the test in each school, using R.
My data looks like this (id,school,passed/failed):
432342 school1 passed
454233 school2 failed
543245 school1 failed
etc'
(The point is that I am only interested in the percent of students that passed, obviously those that didn't passed have failed. I want to have one column for each school that shows the percent of the students in that school that passed)
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
![扫码二维码加入Web技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
有很多方法可以做到这一点。
一是:
there are many ways to do that.
one is:
我之前的回答并没有完全解决。这是重做。示例来自 @eyjo 的回答。
My previous answer didn't go all the way. Here's a redo. Example is the one from @eyjo's answer.
由于您有个人记录(id)并且想要根据索引(学校)进行计算,我建议
tapply
为此。Since you have individual records (id) and want to calculate based on index (school) I would suggest
tapply
for this.