r - 如何使用表访问数据集的交集?
问题描述
我是 R 的初学者。
我有一张桌子 t,我想得到 P(gender|vote)。所以,我尝试了它直观的方式,print(t[gender][vote])。我这样做是因为我想获得 P(Yes|Female)。如果你能帮助这个初学者,那就太棒了。提前致谢。
x = read.csv2("./chilean_voting.csv",stringsAsFactors=FALSE,sep=",");
x[,5] = floor(x[,5]/10)
vote = 9;
education = 6;
gender = 4;
region = 1
age = 5;
region = 2;
t = table(x[,c(education,gender,age,region,vote)])
print(x[age])
print(t[age][gender])
解决方案
推荐阅读
- docker - 在 docker 容器中挂载 kubernetes 卷而不擦除容器的数据
- react-native - 如何将我的输出记录到 .txt 文件而不是 Expo 中的终端?
- c# - 有没有办法将此 WS-Trust 代码移植到 .NET Core?
- typescript - 如何搜索值和嵌套数组值
- wordpress - 动态折扣定价不适用于非登录用户 Woocommerce
- angular - 调试 Angular 应用程序时阻止 Chrome DevTools 打开脚本文件
- javascript - 从使用 id 更改为 class 以从 6 个图像中的任何一个打开模式
- python - 在 DataFrame 中捕获模式并计算其长度
- python - Python:在 python 中复制符号链接文件夹/文件
- android - 从 Kotlin 中的模型访问数组列表