我正在尝试生成一个R markdown文档,其中包含由ggplot2和corrplot图形组成的代码块以及使用摘要函数的摘要统计信息。
但是,只要我尝试使用以下代码块生成R降价文档
## Nurse Bed (fine; see notes)
summary(df3$nurseBed)
summary(df4$nurseBed)
summary(df5$nurseBed)
summary(d$nurseBed)
hist(d$nurseBed, col = "orange", main = "Before Exterme/Outlier Value is Removed")
tail(sort(d$nurseBed),10)
outlier <- d[which(d$nurseBed > 40),] # identify
outlier <- d[which(d$nurseBed > 40),c("Code","Year","Period","nurseBed")] # the outlier
# and remove it
d[c(101,265),"nurseBed"] <- NA
hist(d$nurseBed, col = "pink", main = "After Exterme/Outlier Value is Removed")
boxplot(d$nurseBed, col = "pink", main = "Box Plot for Nurse Bed ratio after the outlier/extreme values")
tail(sort(d$nurseBed),10)
summary(d$nurseBed)
IQR(d$nurseBed, na.rm = TRUE)
# Identify the extreme values for nursebed ratio after the removal
select(d, Code, Trust, Year, Specialists, nurseBed) %>%
filter(nurseBed > 4.2) %>%
arrange(nurseBed)
plot(df3$nurseBed, df3$TFPscore, main = "Nurse Bed Ratio and Productivity", xlab = "TFP", ylab = "Nurse Bed",
col = "blue")
cor(df3$nurseBed, df3$TFPscore, use = "complete.obs")
plot(df3[df3$Specialists==0,]$nurseBed, df3[df3$Specialists==0,]$TFPscore,
main = "Nurse Bed Ratio and Productivity excluding Specialists", xlab = "TFP", ylab = "Nurse Bed",
col = "red")
cor(df3[df3$Specialists==0,]$nurseBed, df3[df3$Specialists==0,]$TFPscore, use = "complete.obs")
# Revert to original data
d <- df[df$Year %in% c("2010/11", "2011/12", "2012/13"),]
它显示以下错误消息:
退出第1715-1757行(test.Rmd) hist.default出错(d $ nurseBed,col =“orange”,main =“删除Exterme / Outlier值之前”): 'x'必须是数字 电话:... withVisible - &gt; eval - &gt; eval - &gt; hist - &gt; hist.default 另外:有50个或更多警告(使用警告()查看前50个) 执行暂停
请原谅我,如果我的问题很天真,但我是R markdown的新手,我在其他来源寻求帮助,但无济于事
普通R控制台中的代码可以正常工作。