Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 201839

Mutate function to columns except few cells

$
0
0

I have got a dataset where I need to round of values for few columns at once. I have applied mutate function to do this. But in the columns there are some texts as well that needs to excluded, For example,

df 
ColA   ColB      ColC
A     56.568     45.590
B     60.596      B
C     A          78.456

df1 <- df %>% mutate_at(vars(ColB, ColC),funs(round(.,1)))

But since the columns contains characters,I am not able to execute it. Expected output is

df1
ColA   ColB    ColC
A     56.5     45.5
B     60.5      B
C     A        78.4


Viewing all articles
Browse latest Browse all 201839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>