How to take specific number of digits from a column using read.csv()

Hello,

I have a dataframe containing 3 columns. 1 column containing decimal values. Dataframe looks like

                                                   query  target     value
1:                                         Carnosic acid D00374 0.6089239
2:                                       Dehydroabietane D00374 0.6418605
3: 12-Hydroxy-11-methoxy-8,11,13-abietatrien-20-oic acid D00374 0.6175299
4:                                              Cafestol D00374 0.6250000
5:                                             Estradiol D00374 0.6418605
6:                                               Estrone D00374 0.6418605

From the value column, I would like to take only 3 digits after the decimal point at the time of reading the dataframe. using read.csv(). Is it possible to read a specific number of digits using read.csv()

A reproducible dataframe is given below

structure(list(query = c("Carnosic acid", "Dehydroabietane", 
"12-Hydroxy-11-methoxy-8,11,13-abietatrien-20-oic acid", "Cafestol", 
"Estradiol", "Estrone"), target = c("D00374", "D00374", "D00374", 
"D00374", "D00374", "D00374"), value = c(0.608923884514436, 
0.641860465116279, 0.617529880478088, 0.625, 0.641860465116279, 
0.641860465116279)), row.names = c(NA, -6L), class = c("data.table", 
"data.frame"), .internal.selfref = <pointer: 0x5556d4979500>)

That data.frame does nat seem to work.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.