我想得到重复的总和。例如,
No. MRN Bicycle
1. 010 1
2. 011 1
3. 011 1
4. 012 0
5. 013 1
6. 014 0
7. 015 1
8. 015 1
9. 015 1
1 is yes
0 is no
我是否知道 MRN 011有1辆自行车的代号。 NOT 2 。( MRN 015有1而不是3 )我想知道自行车总数的回答为 4 )。不 7 。请告诉我如何将命令放入R. 感谢。
答案 0 :(得分:0)
我们可以使用+(table(df1[-1])>1)[,2]
# 10 11 12 13
# 0 1 0 0
来查找具有重复项的MRN。
sum
如果我们需要总和,请用sum(table(df1[-1])>1)
#[1] 1
any
如果目的是找出每个'MRN'中是否有+(table(df1[-1])>0)[,2]
#10 11 12 13
#1 1 0 1
'自行车'
sum
且其import java.io.BufferedWriter;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.util.Scanner;
public class Proceso extends Thread {
File file = new File("lottery.txt");
public Proceso(String msg) {
super(msg);
}
public void run() {
try {
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file, true)));
StringBuffer linea = new StringBuffer();
for (int i = 0; i < 15;i++) {
for (int j = 0; j < 39; j++) {
for (int j2 =0; j2 < 39; j2++) {
for (int k = 0; k < 39; k++) {
for (int k2 = 0 ; k2 < 39; k2++) {
for (int l = 0; l < 39; l++) {
linea.append(i + " " +j + " " +j2 + " " +k + " " +k2 + " " +l + "\n");
bw.write(linea.toString());
}
}
}
}
}
}
bw.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
为3。