-1

I have a vector:

> vec_names
           X59         X57         X55         X53        X51        X49         X47        X45         X43
avergage  Name 10.94054611 13.01835168 15.49076971 18.4327442 21.9334523 26.09900755 31.0556763 36.95370519
                 X41         X39         X37         X35         X34         X33        X32         X31
avergage 43.97187534 52.32292165 62.25998116 74.08426615 88.15419455 100.1501521 109.247149 119.1704588
                 X30         X29         X28         X27         X26         X25         X24         X23
avergage 129.9951384 141.8030623 154.6835423 168.7340024 184.0607161 200.7796101 219.0171411 238.9112524
                 X22         X21         X20         X19         X18         X17         X16        X15
avergage 260.6124171 284.2847762 310.1073805 338.2755445 369.0023236 402.5201262 439.0824707 478.965904
                 X14         X13        X12         X11         X10         X9          X8          X7
avergage 522.4720924 569.9301036 621.698896 678.1700331 739.7706459 806.966663 880.2663349 960.2240785
                 X6          X5          X4          X3    fraction
avergage 1047.44467 1142.587821 1246.373165 1359.585703 1483.081741

In this vector I store the names of the columns of my data frame but it looks strange with so many decimal places. How to change the decimal places for the values in the vector ?

I know that I can use:

options(digits=2)

but it works only for printing the data. I'd like to save this data frame using write.csv and draw some heatmaps so just let me know how I can change the decimal places for the values in that vector.

Shaxi Liver
  • 1,052
  • 3
  • 25
  • 47

1 Answers1

1

You can round the values with round(x, digits=2).

Jaap
  • 81,064
  • 34
  • 182
  • 193