我有3个重复处理中的每一个的处理和对照数据。数据中的第1列至第3列为处理,第4列至第6列为对照。
我在R中执行t.test,如下所示:
df$p.value <- apply (df, 1, function(x) t.test(x[1:3], x[4:6],alternative = "two.sided", paired = TRUE)$p.value)
当我对数据执行t.test时。我收到错误消息:
Error in t.test.default(x[1:3], x[4:6], alternative = "two.sided", paired = TRUE) :data are essentially constant
因此,我希望通过使用tryCatch
来将某些行出现错误时将错误变成“ NA”:
df$p.value <- tryCatch({
apply(df, 1, function(x) t.test(x[1:3], x[4:6],alternative = "two.sided", paired = TRUE)$p.value)
}, error = function(e) {NA})
但是,尽管我有一些可比较的数据,它仍返回所有“ NA”。我该如何解决该脚本?
谢谢。
答案 0 :(得分:1)
您可以尝试
@Override
public void processTemplate(Context context, Transformer transformer) throws IOException {
AreaBuilder areaBuilder = this.getAreaBuilder();
boolean processFormulas = this.isProcessFormulas();
areaBuilder.setTransformer(transformer);
List<Area> xlsAreaList = areaBuilder.build();
Iterator var4 = xlsAreaList.iterator();
Area xlsArea;
while (var4.hasNext()) {
xlsArea = (Area) var4.next();
xlsArea.applyAt(new CellRef(xlsArea.getStartCellRef().getCellName()), context);
}
if (processFormulas) {
var4 = xlsAreaList.iterator();
while (var4.hasNext()) {
xlsArea = (Area) var4.next();
this.setFormulaProcessor(xlsArea);
xlsArea.processFormulas();
}
}
logger.info("===================delete template sheet in CusJxlsHelper");
if (this.isDeleteTemplateSheet()) {
transformer.deleteSheet("TEMPLATE");
}
transformer.write();
}
// realize any method if neccessary.