Message Boards Message Boards

0
|
1936 Views
|
4 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Evaluating by two lines instead of one line code?

Posted 2 years ago

Hello, I calculated together as

StringReplace[ToString[h["ANOVATablePValues"], TraditionalForm], 
 "{" ~~ x___ ~~ "}" -> x]

It showed the error as: enter image description here When I calculated separately, it was correct as:

ToString[h["ANOVATablePValues"], TraditionalForm]
StringReplace["\!\(\*FormBox[\({1.2943642097764646`*^-9}\),
TraditionalForm]\)", "{" ~~ x___ ~~ "}" -> x]

The results were:

{1.29436*10^-9}

and

1.29436*10^-9

enter image description here

POSTED BY: Zhenyu Zeng
4 Replies
Posted 2 years ago

Why convert to a string to remove the {}? Why not

h["ANOVATablePValues"] // First
POSTED BY: Rohit Namjoshi
Posted 2 years ago

But why was the previous one wrong?

POSTED BY: Zhenyu Zeng
Posted 2 years ago

Because they are not the same. Compare

ToString[h["ANOVATablePValues"], TraditionalForm] // FullForm

with what you used with StringReplace where it "worked".

POSTED BY: Rohit Namjoshi
Posted 2 years ago

But when I copied the result of ToString[h["ANOVATablePValues"], TraditionalForm], it is "\!\(\*FormBox[\({1.0440125915074059*^-41}), TraditionalForm])"` that can be evaluated by StringReplace function correctly.

POSTED BY: Zhenyu Zeng
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