Limiting the number of decimals in a dataframe (R)

后端 未结 4 1835
青春惊慌失措
青春惊慌失措 2021-02-05 08:26

I would like to limit the number of decimals when a data frame is imported. My .txt input have 16 decimals to each row in collumn \"Value\". My dataframe look like that:

4条回答
  •  执念已碎
    2021-02-05 09:04

    I have a dataframe of 13 columns where the 1st 2 columns are integers and the rest of the columns are numeric with decimals. I want the decimal values alone to be restricted to 2 decimal places. Applying @G. Grothendieck 's method above, a simple solution below:

    DF[, 3:13] <- round(DF[, 3:13], digits = 2)

提交回复
热议问题