我在R中的4x2应急表上计算卡方测试时遇到了困难,我的脚本如下所示:
# Read data
read.table("Mortality_test.txt")
# Assign a name to the data
mortality<- read.table("Mortality_test.txt", ,col.names=c('treatment','dead'), header=TRUE, sep="\t", na.strings="NA", dec=",", stri
我在R上运行prop.test,这里是应急表和prop.test的输出。‘’是数据框架的名称。“集群”和“AD_2”是两个二分变量。
table(a$cluster,a$AD_2)
no yes
neg 1227 375
pos 546 292
prop.test(table(a$cluster,a$AD_2))
2-sample test for equality of proportions with continuity
correction
data: table(a$cluster, a$AD_2)
X-squared
我想通过count()函数在两个长度相同的向量中同时求出NA值的数目:
library(tidyverse)
list1 <-c(NA,NA,3)
list2 <-c(NA,3,4)
count(is.na(list1) & is.na(list2)) # wanna get TRUE 1 FALSE 2 as one only string contains NA values in both variables
它不起作用。存在以下错误:
Error in UseMethod("groups") :
no applicable method f