# 设置工作空间
# 把“数据及程序”文件夹拷贝到F盘下,再用setwd设置工作空间
setwd("E:/数学建模大赛/数学建模培训1(8.14)/chapter3/示例程序")
# 读入数据
saledata <- read.csv(file = "./data/catering_sale.csv", header = TRUE)
tail(saledata)
# 缺失值检测 并打印结果,由于R把TRUE和FALSE分别当作1、0,可以用sum()和mean()函数来分别获取缺失样本数、缺失比例
sum(complete.cases(saledata))
sum(!complete.cases(saledata))
mean(!complete.cases(saledata))
saledata[!complete.cases(saledata), ]# 异常值检测箱线图
sp <- boxplot(saledata$"销量", boxwex = 0.7)
sp$out
title("销量异常值检测箱线图")
xi <- 1.1
sd.s <- sd(saledata[complete.cases(saledata), ]$"销量")
mn.s <- mean(saledata[complete.cases(saledata), ]$"销量")
points(xi, mn.s, col = "red", pch = 18)
arrows(xi, mn.s - sd.s, xi, mn.s + sd.s, code = 3, col = "pink", angle = 75, length = .1)
text(rep(c(1.05, 1.05, 0.95, 0.95), length = length(sp$out)), labels = sp$out[order(sp$out)], sp$out[order(sp$out)] + rep(c(150, -150, 150, -150), length = length(sp$out)), col = "red")
详细解决方案
Mathematical modeling03
热度:84 发布时间:2023-10-16 06:56:43.0
相关解决方案
- Mathematical modeling The problem01
- Mathematical modeling03
- Mathematical modeling02(图片显示不出来)
- Mathematical modeling Error01
- Mathematical modeling01(odbcConnect、sqlFetch、sqlQuery)
- HDOJ 1017 A Mathematical Curiosity
- Mathematical Curse(dp)
- Codeforces Round #516 (Div. 2,B. Equations of Mathematical Magic(思维)
- ACM-ICPC 2018 焦作赛区网络预赛 Mathematical Curse (简单DP+维护极值)
- mathematical induction
- A Mathematical Curiosity数学好奇心 15
- HDOJ1017 A Mathematical Curiosity
- 【ACM-ICPC 2018 焦作赛区网络预赛 B.Mathematical Curse】 DP
- 【CF_516_div2_B】Equations of Mathematical Magic
- zoj - 2928 - Mathematical contest in modeling(爬山)
- Mathematical Analysis of 2048, The Game论文分享