rjava - p-value calculation using Java -
i want make java program calculate p-value of data want upload, getting trouble so. data been read java program, next step solve data getting p-value.
the input file is:
the input should be:- name a b c a 1.7085586 0.73179674 3.3962722 b 0.092749596 -0.10030079 -0.47453594 c 1.1727467 0.15784931 0.0572958 d -0.91714764 -0.62808895 -0.6190882 e 0.34570503 0.10605621 0.30304766 f 2.333506 -0.2063818 0.4022169 g 0.7893815 1.449388 1.5907407 , output should this:- name pvalue a 0.129618298 b 0.4363544 c 0.323631285 d 0.017916658 e 0.076331828 f 0.385619995 g 0.035449488
i have run data in r program want write java solve this.
my java code till is:
import java.io.bufferedreader; import java.io.filereader; import java.io.ioexception; public class abc { public static void main(string[] args) { // todo auto-generated method stub bufferedreader br = null; try { string scurrentline; br = new bufferedreader(new filereader("c:/documents , settings/admin/desktop/test.txt")); while ((scurrentline = br.readline()) != null) { system.out.println(scurrentline); //output = bufferedreader.getparser().getasdoublearray("br"); } } catch (ioexception e) { e.printstacktrace(); } { try { if (br != null)br.close(); } catch (ioexception ex) { ex.printstacktrace(); } } } }
this reading data , showing in console of java. how proceed?
i think facing problem retrieving , printing values file. below program gives output in required format :
import java.io.bufferedreader; import java.io.filereader; import java.io.ioexception; public class abc { public static void main(string[] args) { bufferedreader br = null; string scurrentline; try { br = new bufferedreader(new filereader("c:/documents , settings/admin/desktop/test.txt")); // override default header row br.readline(); system.out.println("name" + "\t" + "pvalue"); while ((scurrentline = br.readline()) != null) { int = 0; string str[] = scurrentline.split("\t"); system.out.print(str[i] + "\t"); double dvalue1 = double.parsedouble(str[++i]); double dvalue2 = double.parsedouble(str[++i]); double dvalue3 = double.parsedouble(str[++i]); // pvalue calc here double pvalue = 1.2334; system.out.println(pvalue); } } catch (ioexception e) { e.printstacktrace(); } { try { if (br != null) br.close(); } catch (ioexception ex) { ex.printstacktrace(); } } } }
Comments
Post a Comment