私のスクリプトは.xlsxワークシートを読み取り、最後の40行の欠陥数のIチャート、MRチャート、および容量グラフを含む.pdfファイルを作成します。スプレッドシートには2つの列があり、1つ目は材料番号、2つ目は欠陥数です。
ユーザーが材料番号(cat
コマンド)を記述し、システムがそれぞれの欠陥数に基づいてグラフィックを描画するように、スクリプトを変更したいと思います。
例:
ユーザーが番号5、1、3、および8を入力すると、スクリプトは、材料番号とそれぞれの欠陥(1198、1201、1204、1201)を使用して「Data1」という新しいテーブルを作成します。
Number Defect
5 1198
1 1201
3 1204
8 1201
グラフィックの部分はすでに完了しています。cat
コマンドによって作成されたデータを収集するためにデータフレームを作成しようとしましたが、それをワークシートと関連付ける方法がわかりません。使っwhich
てみましたsubset
が、うまくいきませんでした。
私たちを手伝ってくれますか?
どうもありがとうございました。
宜しくお願いします。
cat("\f")
#install.packages(c("qcc", "openxlsx"))
library(qcc)
library(openxlsx)
qcc.options(bg.margin = "white")
#-----------------------------------------------
cat("How many sigmas do you want use for your calculus?")
NSigmas <- scan(n = 1)
`Significant algharisms`<-5
#----------------------------------------------------------------
#Control chart
Spreadsheet1 <- read.xlsx("Chord height at R42000.xlsx", sheet = "BD",
startRow = 1, colNames = TRUE)
Data1 <- tail(Spreadsheet1, 40)
`Chord height at R42000` <- Data1$Defect
pdf("Finish - Chord height at R42000.pdf", paper = "a4r", width = 21 / 2.54,
height = 29.7 / 2.54, title = "Finish - Chord height at R42000.pdf")
`I1 chart` <- qcc(`Chord height at R42000`, type = "xbar.one", nsigmas = (NSigmas/2),
xlab = "Observations", ylab = "Indivudual values", title = "I Chart",
digits = `Significant algharisms`)
`Y axis MR1` <- matrix(cbind(`Chord height at R42000`[1:length(`Chord height at R42000`)-1],
`Chord height at R42000`[2:length(`Chord height at R42000`)]), ncol = 2)
`MR chart` <- qcc(`Y axis MR1`, type = "R", nsigmas = (NSigmas / 2), xlab = "Observations",
ylab = "Moving range", title = "Moving range Chart", digits = `Significant algharisms`)
CapabilidadeI1 <- process.capability(`I1 chart`, spec.limits = c(1198, 1211),
nsigmas = (NSigmas / 2), target = ((1198 + 1211) / 2))
dev.off()
cat("\f")
#install.packages(c("qcc", "openxlsx"))
library(qcc)
library(openxlsx)
qcc.options(bg.margin = "white")
#-----------------------------------------------
cat("How many sigmas do you want use for your calculus?")
NSigmas <- scan(n = 1)
cat("What materials would you like to evaluate? Exit pressing enter twice.")
Materials<-scan()
Materials2<-data.frame(Materials)
`Significant algharisms` <- 5
#----------------------------------------------------------------
#Control chart
Spreadsheet1 <- read.xlsx("Chord height at R42000.xlsx", sheet = "BD",
startRow = 1, colNames = TRUE)
# Data1<-Spreadsheet1[which(Spreadsheet1[,1]==Materials2[,1]),]
# Data1<-subset(Spreadsheet1, Spreadsheet1$Number==Materials2$Materials)
## The variable don't store all numbers I type with "cat" command.
`Chord height at R42000` <- Data1$Defect
pdf("Finish - Chord height at R42000.pdf", paper = "a4r", width = 21 / 2.54,
height = 29.7 / 2.54, title = "Finish - Chord height at R42000.pdf")
`I1 chart` <- qcc(`Chord height at R42000`, type = "xbar.one", nsigmas = (NSigmas/2),
xlab = "Observations", ylab = "Indivudual values", title = "I Chart",
digits = `Significant algharisms`)
`Y axis MR1` <- matrix(cbind(`Chord height at R42000`[1:length(`Chord height at R42000`)-1],
`Chord height at R42000`[2:length(`Chord height at R42000`)]), ncol = 2)
`MR chart` <- qcc(`Y axis MR1`, type = "R", nsigmas = (NSigmas / 2), xlab = "Observations",
ylab = "Moving range", title = "Moving range Chart", digits = `Significant algharisms`)
CapabilidadeI1 <- process.capability(`I1 chart`, spec.limits = c(1198, 1211),
nsigmas = (NSigmas / 2), target = ((1198 + 1211) / 2))
dev.off()
Number Defect
2 1204
5 1198
9 1205
1 1201
4 1198
3 1204
6 1207
8 1201
10 1197
11 1203
12 1199
13 1204
14 1204
19 1208
22 1197
28 1202
30 1209
24 1205
21 1202
25 1202
20 1204
26 1200
65 1205
dt=fread("Number Defect
2 1204
5 1198
9 1205
1 1201
4 1198
3 1204
6 1207
8 1201
10 1197
11 1203
12 1199
13 1204
14 1204
19 1208
22 1197
28 1202
30 1209
24 1205
21 1202
25 1202
20 1204
26 1200
65 1205")
d = scan(n=5)
1: 3
2: 7
3: 11
4: 65
5: 20
Read 5 items
> d
[1] 3 7 11 65 20
dt[which(dt$Number %in% d),]
Number Defect
1: 3 1204
2: 11 1203
3: 20 1204
4: 65 1205
「7」には対応する欠陥がなかったため、表示されませんでした
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加