Is there a way to input a dataset made up of a string of 0's and 1's into R without scientific notation?

28 Views Asked by At

so this is my first time posting a question so bare with me. I am trying to create a data frame in R that is made up of a series of 1's and 0's. Each string of numbers represents an individual fish capture history (1 = captured, 0 = not captured) over a period of capture events (each number, either a 1 or 0, is a capture event). When trying to make this seemingly easy data frame in R, R keeps changing the number string into scientific notation. However, when I use format(df,scientific = FALSE) it inputs weird numbers.

Here is the data frame I am trying to create:

df<-data.frame(ch = c(1000110000100000000001,1111111111111111111111,0111111111111111111111,0101000000001000011111,0111111111111111111111,1111111111111111111111,1111111111111111111111,1111111000000000000000,1111111111111111111111,1111111111111111111111,1111111111111111111111,1011111111111110111111)

which made this outcome pop up:

ch
<dbl>
1.000110e+21                
1.111111e+21                
1.111111e+20                
1.010000e+20                
1.111111e+20                
1.111111e+21                
1.111111e+21                
1.111111e+21                
1.111111e+21                
1.111111e+21

I then did this to get rid of scientific notation:

df <- format(df, scientific = FALSE)

which made this outcome:

ch
<S3: AsIs>
1   1000110000100000006164          
2   1111111111111111082004          
3   111111111111111114752           
4   101000000001000013824           
5   111111111111111114752           
6   1111111111111111082004          
7   1111111111111111082004          
8   1111111000000000032808          
9   1111111111111111082004          
10  1111111111111111082004  

Why is it inputting random numbers into my string?

Also, I need "ch" to be a character instead of whatever S3: AsIs is. I tried this but it does not help:

df$ch <- as.character(df$ch)

Any help at all would be appreciated!

0

There are 0 best solutions below