Rate.ILI.Tot = 26.373
I would have thought the two lines of code below would yield identical results, but they do not.
The first returns 26, the second 26.4.
Any idea why?
rate <- update$Rate.ILI.Tot %>% round(,1)
rate <- round(update$Rate.ILI.Tot, 1)
mara
March 29, 2018, 2:25pm
2
Could you please turn this into a self-contained reprex (short for minimal repr oducible ex ample)? It will help us help you if we can be sure we're all working with/looking at the same stuff (libraries loaded, etc.).
Right now the best way to install reprex is:
# install.packages("devtools")
devtools::install_github("tidyverse/reprex")
If you've never heard of a reprex before, you might want to start by reading the tidyverse.org help page . The reprex dos and don'ts are also useful.
If you run into problems with access to your clipboard, you can specify an outfile for the reprex, and then copy and paste the contents into the forum.
reprex::reprex(input = "fruits_stringdist.R", outfile = "fruits_stringdist.md")
For pointers specific to the community site, check out the reprex FAQ, linked to below.
Why reprex?
Getting unstuck is hard. Your first step here is usually to create a reprex, or reproducible example. The goal of a reprex is to package your code, and information about your problem so that others can run it and feel your pain. Then, hopefully, folks can more easily provide a solution.
What's in a Reproducible Example?
Parts of a reproducible example:
background information - Describe what you are trying to do. What have you already done?
complete set up - include any library() calls and data to reproduce your issue.
data for a reprex: Here's a discussion on setting up data for a reprex
make it run - include the minimal code required to reproduce your error on the data…
The reason they are different is because of the comma in your piped version.
library(magrittr)
x <- 26.373
round(x, 1)
#> [1] 26.4
x %>% round(1)
#> [1] 26.4
x %>% round(., 1)
#> [1] 26.4
x %>% round(,1)
#> [1] 26
In the form x %>% round(,1)
you are actually not passing 1 to any argument, so the default of 0 is being used.
3 Likes
much appreciated, thanks for helping out a bigginer
1 Like
mara
March 29, 2018, 2:52pm
5
If your question's been answered, would you mind choosing a solution? (see FAQ below for how) It makes it a bit easier to visually navigate the site and see which questions still need help.
If your question has been answered, don't forget to mark the solution!
How do I mark a solution?
Find the reply you want to mark as the solution and look for the row of small gray icons at the bottom of that reply. Click the one that looks like a box with a checkmark in it:
[image]
Hovering over the mark solution button shows the label, "Select if this reply solves the problem". If you don't see the mark solution button, try clicking the three dots button ( ••• ) to expand the full set of options.
When a solution is chosen, the icon turns green and the hover label changes to: "Unselect if this reply no longer solves the problem". Success!
[solution_reply_author]
…
Thanks