Skip to content

Instantly share code, notes, and snippets.

@nilforooshan
Last active October 2, 2024 12:04
Show Gist options
  • Select an option

  • Save nilforooshan/b1791fc5eebd64dac4677f65de3b1c12 to your computer and use it in GitHub Desktop.

Select an option

Save nilforooshan/b1791fc5eebd64dac4677f65de3b1c12 to your computer and use it in GitHub Desktop.
R: Return the number of decimals

Return the number of decimals

nchar(strsplit(as.character(5.230000), "\\.")[[1]][2])

[1] 2

nchar(strsplit(as.character(5.230200), "\\.")[[1]][2])

[1] 4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment