0

I currently have the following R code, which is grouping the data into "bands", based upon the value in the column BLANLIMAMT. This works perfectly.

library(dplyr)


#Import the data
MyData <- read.csv("LibFile.csv", stringsAsFactors = FALSE)

#Profile the Data
bTable<- MyData %>% 
  group_by(gr=cut(BLANLIMAMT, breaks= seq(0, 50000000, by = 500000)) )%>% 
  summarise(n= n()) %>%
  arrange(as.numeric(gr))

My issues is with formatting the output. The values in column gr (in bTable) currently look like (0,5e+05). I would like them to look like 0 to 500,000 etc. Here is a screenshot of the table:

Here is a screenshot of the table

Any thoughts on how I would achieve this?

Dant19
  • 1
  • 2

2 Answers2

1

use dig.lab=8 within cut. for example

bTable<- MyData %>% 
  group_by(gr=cut(BLANLIMAMT, breaks= seq(0, 50000000, by = 500000), dig.lab=8) )%>% 
  summarise(n= n()) %>%
  arrange(as.numeric(gr))

It gives the number of digits before it switches to scientific notation.

drmariod
  • 11,106
  • 16
  • 64
  • 110
0

Use options("scipen"=100, "digits"=4)

You can play with exact numbers to your liking :).

‘scipen’: integer. A penalty to be applied when deciding to print numeric values in fixed or exponential notation. Positive values bias towards fixed and negative towards scientific notation: fixed notation will be preferred unless it is more than ‘scipen’ digits wider.

Source: https://stat.ethz.ch/R-manual/R-devel/library/base/html/options.html

Denis Rasulev
  • 3,744
  • 4
  • 33
  • 47