# How to print the exact values of all elements in a column of an R data frame?

R ProgrammingServer Side ProgrammingProgramming

To print the exact values of all elements in a column of an R data frame, we can follow the below stops −

• First of all, create a data frame.

• Then, use options function and provide the required number of digits for printing.

## Example

#### Create the data frame

Let’s create a data frame as shown below −

x<-
sample(c(1.1525412,1.25743874,2.36987321,3.6527142,1.98742315,6.25429836,2.111685723,3.200447169),25,replace=TRUE)
df<-data.frame(x)
df

## Output

On executing, the above script generates the below output(this output will vary on your system due to randomization) −

      x
1  6.254298
2  1.152541
3  1.152541
4  1.152541
5  3.652714
6  2.111686
7  1.152541
8  6.254298
9  1.257439
10 2.369873
11 2.111686
12 2.111686
13 1.257439
14 1.152541
15 3.652714
16 2.111686
17 1.152541
18 3.652714
19 2.111686
20 1.152541
21 1.152541
22 1.257439
23 3.652714
24 1.257439
25 3.652714

Print exact values of all elements

Using options function and providing 16 digits for printing as shown below −

x<-
sample(c(1.1525412,1.25743874,2.36987321,3.6527142,1.98742315,6.25429836,2.111685723,3.200447169),25,replace=TRUE)
df<-data.frame(x)
options(digits=16)
df

## Output

        x
1  3.200447169
2  6.254298360
3  2.369873210
4  6.254298360
5  3.200447169
6  3.200447169
7  1.152541200
8  6.254298360
9  2.111685723
10 1.257438740
11 1.987423150
12 1.257438740
13 6.254298360
14 3.200447169
15 3.652714200
16 2.111685723
17 6.254298360
18 1.152541200
19 1.152541200
20 3.200447169
21 3.200447169
22 1.257438740
23 2.111685723
24 2.111685723
25 2.111685723
Updated on 11-Nov-2021 05:38:53