[R] How to show number in the %f format?
David Winsemius
dwinsemius at comcast.net
Thu Sep 24 08:28:24 CEST 2009
On Sep 23, 2009, at 6:42 PM, Peng Yu wrote:
> On Wed, Sep 23, 2009 at 5:16 PM, David Winsemius <dwinsemius at comcast.net
> > wrote:
>>
>> On Sep 23, 2009, at 5:58 PM, Peng Yu wrote:
>>
>>> Hi,
>>>
>>> I have the following matrix, which is printed %e format (in C's
>>> way).
>>> I am wondering how make it be printed in %f format (in C's way)?
>>
>> ??"printf" # scroll down to base package listings, the C function
>>
>> ?sprintf # the s/r function
>
> I tried the following command. The column names are missing and the
> command is a little complicated. Is there any better solution?
>
>> t(apply(significant_analysis_results[,7:8],1,function(x){sprintf("%.
>> 7f",x)}))
Why not apply to the column index? ... rather than to the row and
then transposing.
> [,1] [,2]
> Nab2 "0.0000019" "0.0000000"
> Rasal1 "0.0000248" "0.0000105"
> Ccndbp1 "0.0000001" "0.0002269"
> Svep1 "0.0000000" "0.0000000"
> Ppara "0.0008219" "0.0000000"
> Pros1 "0.0000009" "0.0000000"
> Papss2 "0.0000000" "0.0000002"
> Hdac9 "0.0000000" "0.0000000"
> Adcyap1r1 "0.0000000" "0.0000000"
> Robo1 "0.0000000" "0.0000000"
> Sema3a "0.0000000" "0.0000000"
> Rab9b "0.0000110" "0.0000011"
> Tgfb3 "0.0000000" "0.0000000"
> Slc9a9 "0.0074608" "0.0000000"
> Creb5 "0.0000003" "0.0000000"
> Ccnd1 "0.0007869" "0.0000001"
> Pafah1b3 "0.0000000" "0.0000068"
> Tiam2 "0.0000000" "0.0000000"
> Etv5 "0.0000000" "0.0000000"
> Hcrtr2 "0.0000000" "0.0000166"
>
>
>>
>>>
>>> Regards,
>>> Peng
>>>
>>>> significant_analysis_results[,7:8]
>>>
>>> pval(ki-wt) pval(ko-wt)
>>> Nab2 1.913348979e-06 2.731944670e-09
>>> Rasal1 2.482254110e-05 1.054711084e-05
>>> Ccndbp1 6.307674516e-08 2.268947934e-04
>>> Svep1 0.000000000e+00 1.564526286e-12
>>> Ppara 8.218961690e-04 2.802202914e-13
>>> Pros1 8.787052919e-07 0.000000000e+00
>>> Papss2 0.000000000e+00 2.190819073e-07
>>> Hdac9 0.000000000e+00 8.881784197e-16
>>> Adcyap1r1 2.085731587e-11 1.998401444e-15
>>> Robo1 0.000000000e+00 0.000000000e+00
>>> Sema3a 4.903322193e-11 0.000000000e+00
>>> Rab9b 1.099629676e-05 1.116694168e-06
>>> Tgfb3 0.000000000e+00 0.000000000e+00
>>> Slc9a9 7.460784795e-03 1.552167950e-09
>>> Creb5 2.959174867e-07 8.973577437e-11
>>> Ccnd1 7.868573521e-04 1.460805570e-07
>>> Pafah1b3 1.576464070e-08 6.757446065e-06
>>> Tiam2 0.000000000e+00 0.000000000e+00
>>> Etv5 2.279731959e-12 0.000000000e+00
>>> Hcrtr2 1.258646520e-10 1.661509722e-05
>>>>
>>>> str(significant_analysis_results[,7:8])
>>>
>>> num [1:20, 1:2] 1.91e-06 2.48e-05 6.31e-08 0.00 8.22e-04 ...
>>> - attr(*, "dimnames")=List of 2
>>> ..$ : chr [1:20] "Nab2" "Rasal1" "Ccndbp1" "Svep1" ...
>>> ..$ : chr [1:2] "pval(ki-wt)" "pval(ko-wt)"
>>>
>>> ______________________________________________
>>> R-help at r-project.org mailing list
>>> https://stat.ethz.ch/mailman/listinfo/r-help
>>> PLEASE do read the posting guide
>>> http://www.R-project.org/posting-guide.html
>>> and provide commented, minimal, self-contained, reproducible code.
>>
>> David Winsemius, MD
>> Heritage Laboratories
>> West Hartford, CT
>>
>>
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
David Winsemius, MD
Heritage Laboratories
West Hartford, CT
More information about the R-help
mailing list