Unable to save.

print(New_data, digits = 2) is showing positive results according to the command but typing Final_data <- print(New_data, digits = 2) is not saving the desired results as shown earlier in the R console. I am using this command to remove decimals.

The print function returns its argument, not the result of the print. If you want to round to integers, you can do this:

Final_data <- mutate(New_data, across(.cols = where(is.numeric), .fns = round))
1 Like
x <- 3.1415
y <- format(x,digits=2)
#> [1] "3.1"

Created on 2023-04-02 with reprex v2.0.2

Mean age of the riders

Final_data %>% mean(Age, na.rm=TRUE)

The earlier stated problem was solved, Thank you ! Could you help me with the "mean" function, I am unable to find the Mean Age. Typing the command it shows NULL.

num [1:2336188] 33 29 40 29 33 34 34 33 62 35 ...

The mean() function is not designed to be used with the %>% pipe. The code

Final_data %>% mean(Age, na.rm=TRUE)

is the same as

mean(Final_data, Age, na.rm=TRUE)

which does not work. Your need

mean(Final_data$Age, na.rm =TRUE)
1 Like

The second one delivered the answer. Thank you !

This topic was automatically closed 42 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.