Message Boards Message Boards

0
|
4418 Views
|
2 Replies
|
2 Total Likes
View groups...
Share
Share this post:

[Solved] How to better perform this operation within a mapping?

Posted 4 years ago
POSTED BY: Richard Frost
2 Replies

How is this done without the use of List?

Just

If[StringPart[#, -1] == ".", # <> "0%", # <> "%"] & @ ToString @ Round[100*#[[2]], 0.1]

but consider:

ToString[NumberForm[100 #[[2]], {Infinity, 1}]] <> "%" & /@ 
  {{, 0.0156}, {, 0.01}}

{"1.6%", "1.0%"}

Or

TextString@Quantity[Round[100 #[[2]], .1], "Percent"] & /@ 
  {{,  0.0156}, {, 0.01}}
POSTED BY: Kuba Podkalicki

Thank you Kuba for your quick reply plus examples. So "& @" now makes sense, a prefixed pure function. NumberForm is a good idea too -- it gets to the heart of what I wanted. Quantity[] is also desirable, but upon export in tabular form does not easily import to some programs. Works great in plots though.

POSTED BY: Richard Frost
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract