writing into a csv file

10 views
Skip to first unread message

Ayala Allon

unread,
Sep 2, 2014, 12:47:43 PM9/2/14
to israel-r-...@googlegroups.com
Hi
I created the following data frame. It has 15 rows and 84 columns (the following line of code is part of a function):
results <<- data.frame(cbind(numOfSubjects,betweenSubDF,mrt,srt,t1rt,t15rt,t2rt,nrt,n1tr,n15tr,n2tr,p1tr,p15tr,p2tr,rminv,p5rt,p95rt,q1rt,medrt,q3rt,merr,mac))

However when I write it into a csv file using
write.csv(results,file = "myResults.csv" ) 

I get 85 columns because it writes also the column I marked here in yellow
Does anyone knows why and how I can get rid of it when writing into the csv file?

>head(results)
     numOfSubjects block age gender     mrt1     mrt2     mrt3     mrt4      srt1     srt2      srt3      srt4
5013          5013   1.5  24      2 759.6480 979.1935 899.7037 953.9223 163.68022 154.1969 189.06182 166.14532
5020          5020   1.5  24      2 593.9225 702.3125 566.5000 626.4351 107.75418 108.7093  95.22708  80.76701
5021          5021   1.5  23      1 655.0280 742.0294 558.8611 652.5714 162.35602 172.8887 122.58132 144.79701
5022          5022   1.5  21      2 599.4648 725.2941 580.1944 650.1250  90.90301 155.3398 129.60221 135.52714
5023          5023   1.5  21      2 709.2174 815.0303 814.9677 892.4132 149.96967 192.6310 179.37493 149.35046
5024          5024   1.5  23      2 611.8112 777.3529 650.6571 754.1286 115.03520 130.4112 157.93687 129.73458
        t1rt1    t1rt2    t1rt3    t1rt4   t15rt1   t15rt2   t15rt3   t15rt4    t2rt1    t2rt2    t2rt3    t2rt4 nrt1
5013 740.7765 982.2222 924.0000 962.0000 737.1574 999.0000 937.5200 983.8526 746.3761 979.1935 937.5200 969.1500  125
5020 578.7732 710.0000 540.8333 619.0753 573.9500 693.8889 534.4138 619.5357 579.2764 700.7000 559.3333 622.6048  129
5021 631.6408 760.3636 535.5172 623.9907 629.5040 731.2258 558.3030 619.6953 635.9926 742.0294 564.0882 630.3759  143
5022 593.5833 691.9565 573.2903 638.7900 593.7381 697.6296 569.4706 626.8425 599.4889 725.2941 562.9143 637.9854  142
5023 716.9400 815.6364 795.1000 870.0256 714.0684 841.0741 799.4231 879.8922 713.3228 827.2188 803.0000 897.5042  138
5024 592.2566 775.7083 623.4000 726.2245 584.9612 753.3333 618.9677 730.5440 590.5597 755.8750 611.3438 738.3083  143
     nrt2 nrt3 nrt4 n1tr1 n1tr2 n1tr3 n1tr4 n15tr1 n15tr2 n15tr3 n15tr4 n2tr1 n2tr2 n2tr3 n2tr4     p1tr1     p1tr2
5013   31   27  103    40    13     6    36     17      2      2      8     8     0     2     3 0.3200000 0.4193548
5020   32   34  131    32     8    10    38      9      5      5     19     6     2     1     7 0.2480620 0.2500000
5021   34   36  140    40    12     7    33     18      3      3     12     8     0     2     7 0.2797203 0.3529412
5022   34   36  144    34    11     5    44     16      7      2     17     7     0     1     7 0.2394366 0.3235294
5023   33   31  121    38    11    11    43     21      6      5     19    11     1     1     2 0.2753623 0.3333333
5024   34   35  140    30    10     5    42     14      4      4     15     9     2     3     7 0.2097902 0.2941176
         p1tr3     p1tr4     p15tr1     p15tr2     p15tr3     p15tr4      p2tr1      p2tr2      p2tr3      p2tr4
5013 0.2222222 0.3495146 0.13600000 0.06451613 0.07407407 0.07766990 0.06400000 0.00000000 0.07407407 0.02912621
5020 0.2941176 0.2900763 0.06976744 0.15625000 0.14705882 0.14503817 0.04651163 0.06250000 0.02941176 0.05343511
5021 0.1944444 0.2357143 0.12587413 0.08823529 0.08333333 0.08571429 0.05594406 0.00000000 0.05555556 0.05000000
5022 0.1388889 0.3055556 0.11267606 0.20588235 0.05555556 0.11805556 0.04929577 0.00000000 0.02777778 0.04861111
5023 0.3548387 0.3553719 0.15217391 0.18181818 0.16129032 0.15702479 0.07971014 0.03030303 0.03225806 0.01652893
5024 0.1428571 0.3000000 0.09790210 0.11764706 0.11428571 0.10714286 0.06293706 0.05882353 0.08571429 0.05000000
       rminv1   rminv2   rminv3   rminv4  p5rt1  p5rt2  p5rt3  p5rt4  p95rt1  p95rt2  p95rt3  p95rt4  q1rt1  q1rt2
5013 724.9122 954.0767 844.8306 915.8820 533.00 727.50 497.60 700.10 1081.40 1186.50 1128.50 1185.80 658.00 859.50
5020 577.0583 685.6651 552.9821 615.9180 471.60 525.65 452.90 505.50  797.80  891.30  744.25  782.50 512.00 643.50
5021 617.4345 700.6980 501.4269 626.3859 447.00 485.00 456.75 483.90  958.70  990.05  743.75  941.20 552.50 594.75
5022 583.5184 693.8455 559.1845 622.7780 497.25 506.55 436.75 461.45  743.00  971.05  706.75  888.25 548.25 607.75
5023 670.3121 763.8419 776.8035 867.6643 428.05 479.00 547.00 668.00  958.35 1103.40 1130.00 1150.00 640.25 719.00
5024 593.8084 757.9001 621.0400 733.6333 484.10 594.55 495.10 586.90  876.00 1047.50 1001.90  991.30 535.00 700.25
      q1rt3  q1rt4 medrt1 medrt2 medrt3 medrt4  q3rt1   q3rt2   q3rt3   q3rt4       merr1      merr2 merr3
5013 819.00 858.50  741.0  996.0  922.0  965.0 845.00 1119.00 1021.50 1077.50 0.000000000 0.00000000     0
5020 506.75 568.50  570.0  696.5  533.0  622.0 661.00  754.00  594.25  670.00 0.000000000 0.03030303     0
5021 502.00 549.50  633.0  780.0  540.5  629.5 735.00  866.50  606.75  699.25 0.000000000 0.05555556     0
5022 528.00 563.75  592.5  681.5  565.0  635.0 648.00  833.75  610.00  734.25 0.006993007 0.05555556     0
5023 686.50 784.00  717.5  816.0  799.0  864.0 796.75  953.00  922.50 1006.00 0.000000000 0.05714286     0
5024 556.00 658.50  599.0  775.5  624.0  718.0 659.00  829.00  695.00  834.00 0.000000000 0.02857143     0
           merr4     mac1      mac2 mac3      mac4
5013 0.009615385 1.000000 1.0000000    1 0.9903846
5020 0.015037594 1.000000 0.9696970    1 0.9849624
5021 0.027777778 1.000000 0.9444444    1 0.9722222
5022 0.000000000 0.993007 0.9444444    1 1.0000000
5023 0.016260163 1.000000 0.9428571    1 0.9837398
5024 0.000000000 1.000000 0.9714286    1 1.0000000
> dim(results)
[1] 15 84


Best,
Ayala

amit gal

unread,
Sep 2, 2014, 1:03:23 PM9/2/14
to israel-r-...@googlegroups.com
it automatically adds row names. try help(write.csv) to find which parameters control that, and disable/enable them


--
You received this message because you are subscribed to the Google Groups "Israel R User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to israel-r-user-g...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ayala Allon

unread,
Sep 2, 2014, 1:10:59 PM9/2/14
to israel-r-...@googlegroups.com

I will
Thanks Amit!
Ayala

בתאריך 2 בספט 2014 20:03, "amit gal" <amit...@gmail.com> כתב:
You received this message because you are subscribed to a topic in the Google Groups "Israel R User Group" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/israel-r-user-group/CeTrFnEz7iY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to israel-r-user-g...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages