Using R to remove data which is below a quartile threshold

I am creating correlations using R, with the following code: Values<-read.csv(inputFile, header = TRUE) O<-Values$Abundance_O S<-Values$Abundance_S cor(O,S) pear_cor<-round(cor(O,S),4) outfile<-paste(inputFile, ".jpg", sep = "") jpeg(filename = outfile, width = 15, height = 10, units = "in", pointsize = 10, quality = 75, bg = "white", res = 300, restoreConsole = TRUE) rx<-range(0,20000000) ry<-range(0,200000) plot(rx,ry, ylab="S", xlab="O", main="O vs S", type="n") points(O,S, col="black", pch=3, lwd=1) mtext(sprintf("%s %.4f", "pearson: ", pear_cor), adj=1, padj=0, side = 1, line = 4) dev.off() pear_cor I now need to find the lower quartile for each set of data and exclude data that is within the lower quartile. I would then like to rewrite the data without those values and use the new column of data in the correlation analysis (because I want to threshold the data by the lower quartile). If there is a way I can write this so that it is easy to change the threshold by applying arguments from Java (as I have with the input file name) that's even better! Thank you so much. I have now implicated the answer below and that is working, however I need to keep the pairs of data together for the correlation. Here is an example of my data (from csv): Abundance_O Abundance_S 3635900.752 1390.883073 463299.4622 1470.92626 359101.0482 989.1609251 284966.6421 3248.832403 415283.663 2492.231265 2076456.856 10175.48946 620286.6206 5074.268802 3709754.717 269.6856808 803321.0892 118.2935093 411553.0203 4772.499758 50626.83554 17.29893001 337428.8939 203.3536852 42046.61549 152.1321255 1372013.047 5436.783169 939106.3275 7080.770535 96618.01393 1967.834701 229045.6983 948.3087208 4419414.018 23735.19352 So I need to exclude both values in the row if one does not meet my quartile threshold (0.25 quartile). So if the quartile for O was 45000 then the row "42046.61549,152.1321255" would be removed. Is this possible? If I read in both columns as a dataframe can I search each column separately? Or find the quartiles and then input that value into code to remove the appropriate rows? Thanks again, and sorry for the evolution of the question!
Hi, welcome to SO. Since you are new here, you might want to read the about and FAQ sections of the website to help you get the most out of it. Please also read how to make a great reproducible example and update your question accordingly!

以上就是Using R to remove data which is below a quartile threshold的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » JavaScript 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准

联系我们

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏