How do I treat the results of Fit as text?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
4
down vote

favorite
2












I would like to take the results of Fit (or any FittedModel) and treat them as text, including making substitutions for the variables. But I can't figure out how to do this.



For example



"Subscript[I, m]/Subscript[I, r]" <> " = " <> ToString[Fit[currentRatio[32],1,x,x^2,x^3,x]/.x->"Subscript[I, r]"]


produces the garbled output



Subscript[I, m]/Subscript[I, r] = -6 2 -10 3
0.591585 + 0.00126235 I - 1.75804 10 I + 8.08979 10 I
r r r


How do I treat the results of Fit or FittedModel as text?










share|improve this question



























    up vote
    4
    down vote

    favorite
    2












    I would like to take the results of Fit (or any FittedModel) and treat them as text, including making substitutions for the variables. But I can't figure out how to do this.



    For example



    "Subscript[I, m]/Subscript[I, r]" <> " = " <> ToString[Fit[currentRatio[32],1,x,x^2,x^3,x]/.x->"Subscript[I, r]"]


    produces the garbled output



    Subscript[I, m]/Subscript[I, r] = -6 2 -10 3
    0.591585 + 0.00126235 I - 1.75804 10 I + 8.08979 10 I
    r r r


    How do I treat the results of Fit or FittedModel as text?










    share|improve this question

























      up vote
      4
      down vote

      favorite
      2









      up vote
      4
      down vote

      favorite
      2






      2





      I would like to take the results of Fit (or any FittedModel) and treat them as text, including making substitutions for the variables. But I can't figure out how to do this.



      For example



      "Subscript[I, m]/Subscript[I, r]" <> " = " <> ToString[Fit[currentRatio[32],1,x,x^2,x^3,x]/.x->"Subscript[I, r]"]


      produces the garbled output



      Subscript[I, m]/Subscript[I, r] = -6 2 -10 3
      0.591585 + 0.00126235 I - 1.75804 10 I + 8.08979 10 I
      r r r


      How do I treat the results of Fit or FittedModel as text?










      share|improve this question















      I would like to take the results of Fit (or any FittedModel) and treat them as text, including making substitutions for the variables. But I can't figure out how to do this.



      For example



      "Subscript[I, m]/Subscript[I, r]" <> " = " <> ToString[Fit[currentRatio[32],1,x,x^2,x^3,x]/.x->"Subscript[I, r]"]


      produces the garbled output



      Subscript[I, m]/Subscript[I, r] = -6 2 -10 3
      0.591585 + 0.00126235 I - 1.75804 10 I + 8.08979 10 I
      r r r


      How do I treat the results of Fit or FittedModel as text?







      fitting text






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited yesterday









      m_goldberg

      82.6k869190




      82.6k869190










      asked yesterday









      orome

      5,85523680




      5,85523680




















          2 Answers
          2






          active

          oldest

          votes

















          up vote
          4
          down vote



          accepted










          "Subscript[I, m]/Subscript[I, r]" <> " = " <> 
          ToString[Fit[Table[x, x + x^3, x, 0, 1, .1], 1, x, x^2, x^3, x] /.
          x -> "Subscript[I, r]", StandardForm]


          enter image description here



          With InputForm inplace of StandardForm we get




          "Subscript[I, m]/Subscript[I, r] = 0. +
          0.9999999999999991*"Subscript[I, r]" +
          2.511131286529154*^-15*"Subscript[I, r]"^2 +
          0.9999999999999988*"Subscript[I, r]"^3"




          Note: ToString >> Details and Options:




          ToString supports the same set of options as OpenAppend, with default settings FormatType->OutputForm, PageWidth->Infinity, TotalWidth->Infinity.




           ToString[x^2]


          enter image description here



           ToString[x^2, StandardForm]


          enter image description here



           ToString[x^2, InputForm]


          enter image description here






          share|improve this answer





























            up vote
            5
            down vote













            Just use Row:



            Row[
            Subscript[I, m]/Subscript[I, r] ,
            " = ",
            Fit[Table[x, x + x^3, x, 0, 1, .1], 1, x, x^2, x^3, x] /.
            x -> Subscript[I, r]
            ]


            enter image description here






            share|improve this answer






















            • If I try to join that with a string as in the OP I get the same error: "StringJoin::string: String expected at position 2 in...".
              – orome
              yesterday










            • With Row[...] you can combine strings and Style-objects!
              – Ulrich Neumann
              yesterday










            • It never fails that no matter what I'm trying to do, I eventually reach the point where I kick myself and ask: Why didn't I just do this in Python!
              – orome
              yesterday










            Your Answer




            StackExchange.ifUsing("editor", function ()
            return StackExchange.using("mathjaxEditing", function ()
            StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix)
            StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
            );
            );
            , "mathjax-editing");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "387"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            convertImagesToLinks: false,
            noModals: false,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













             

            draft saved


            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f183303%2fhow-do-i-treat-the-results-of-fit-as-text%23new-answer', 'question_page');

            );

            Post as a guest






























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            4
            down vote



            accepted










            "Subscript[I, m]/Subscript[I, r]" <> " = " <> 
            ToString[Fit[Table[x, x + x^3, x, 0, 1, .1], 1, x, x^2, x^3, x] /.
            x -> "Subscript[I, r]", StandardForm]


            enter image description here



            With InputForm inplace of StandardForm we get




            "Subscript[I, m]/Subscript[I, r] = 0. +
            0.9999999999999991*"Subscript[I, r]" +
            2.511131286529154*^-15*"Subscript[I, r]"^2 +
            0.9999999999999988*"Subscript[I, r]"^3"




            Note: ToString >> Details and Options:




            ToString supports the same set of options as OpenAppend, with default settings FormatType->OutputForm, PageWidth->Infinity, TotalWidth->Infinity.




             ToString[x^2]


            enter image description here



             ToString[x^2, StandardForm]


            enter image description here



             ToString[x^2, InputForm]


            enter image description here






            share|improve this answer


























              up vote
              4
              down vote



              accepted










              "Subscript[I, m]/Subscript[I, r]" <> " = " <> 
              ToString[Fit[Table[x, x + x^3, x, 0, 1, .1], 1, x, x^2, x^3, x] /.
              x -> "Subscript[I, r]", StandardForm]


              enter image description here



              With InputForm inplace of StandardForm we get




              "Subscript[I, m]/Subscript[I, r] = 0. +
              0.9999999999999991*"Subscript[I, r]" +
              2.511131286529154*^-15*"Subscript[I, r]"^2 +
              0.9999999999999988*"Subscript[I, r]"^3"




              Note: ToString >> Details and Options:




              ToString supports the same set of options as OpenAppend, with default settings FormatType->OutputForm, PageWidth->Infinity, TotalWidth->Infinity.




               ToString[x^2]


              enter image description here



               ToString[x^2, StandardForm]


              enter image description here



               ToString[x^2, InputForm]


              enter image description here






              share|improve this answer
























                up vote
                4
                down vote



                accepted







                up vote
                4
                down vote



                accepted






                "Subscript[I, m]/Subscript[I, r]" <> " = " <> 
                ToString[Fit[Table[x, x + x^3, x, 0, 1, .1], 1, x, x^2, x^3, x] /.
                x -> "Subscript[I, r]", StandardForm]


                enter image description here



                With InputForm inplace of StandardForm we get




                "Subscript[I, m]/Subscript[I, r] = 0. +
                0.9999999999999991*"Subscript[I, r]" +
                2.511131286529154*^-15*"Subscript[I, r]"^2 +
                0.9999999999999988*"Subscript[I, r]"^3"




                Note: ToString >> Details and Options:




                ToString supports the same set of options as OpenAppend, with default settings FormatType->OutputForm, PageWidth->Infinity, TotalWidth->Infinity.




                 ToString[x^2]


                enter image description here



                 ToString[x^2, StandardForm]


                enter image description here



                 ToString[x^2, InputForm]


                enter image description here






                share|improve this answer














                "Subscript[I, m]/Subscript[I, r]" <> " = " <> 
                ToString[Fit[Table[x, x + x^3, x, 0, 1, .1], 1, x, x^2, x^3, x] /.
                x -> "Subscript[I, r]", StandardForm]


                enter image description here



                With InputForm inplace of StandardForm we get




                "Subscript[I, m]/Subscript[I, r] = 0. +
                0.9999999999999991*"Subscript[I, r]" +
                2.511131286529154*^-15*"Subscript[I, r]"^2 +
                0.9999999999999988*"Subscript[I, r]"^3"




                Note: ToString >> Details and Options:




                ToString supports the same set of options as OpenAppend, with default settings FormatType->OutputForm, PageWidth->Infinity, TotalWidth->Infinity.




                 ToString[x^2]


                enter image description here



                 ToString[x^2, StandardForm]


                enter image description here



                 ToString[x^2, InputForm]


                enter image description here







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited yesterday

























                answered yesterday









                kglr

                164k8188388




                164k8188388




















                    up vote
                    5
                    down vote













                    Just use Row:



                    Row[
                    Subscript[I, m]/Subscript[I, r] ,
                    " = ",
                    Fit[Table[x, x + x^3, x, 0, 1, .1], 1, x, x^2, x^3, x] /.
                    x -> Subscript[I, r]
                    ]


                    enter image description here






                    share|improve this answer






















                    • If I try to join that with a string as in the OP I get the same error: "StringJoin::string: String expected at position 2 in...".
                      – orome
                      yesterday










                    • With Row[...] you can combine strings and Style-objects!
                      – Ulrich Neumann
                      yesterday










                    • It never fails that no matter what I'm trying to do, I eventually reach the point where I kick myself and ask: Why didn't I just do this in Python!
                      – orome
                      yesterday














                    up vote
                    5
                    down vote













                    Just use Row:



                    Row[
                    Subscript[I, m]/Subscript[I, r] ,
                    " = ",
                    Fit[Table[x, x + x^3, x, 0, 1, .1], 1, x, x^2, x^3, x] /.
                    x -> Subscript[I, r]
                    ]


                    enter image description here






                    share|improve this answer






















                    • If I try to join that with a string as in the OP I get the same error: "StringJoin::string: String expected at position 2 in...".
                      – orome
                      yesterday










                    • With Row[...] you can combine strings and Style-objects!
                      – Ulrich Neumann
                      yesterday










                    • It never fails that no matter what I'm trying to do, I eventually reach the point where I kick myself and ask: Why didn't I just do this in Python!
                      – orome
                      yesterday












                    up vote
                    5
                    down vote










                    up vote
                    5
                    down vote









                    Just use Row:



                    Row[
                    Subscript[I, m]/Subscript[I, r] ,
                    " = ",
                    Fit[Table[x, x + x^3, x, 0, 1, .1], 1, x, x^2, x^3, x] /.
                    x -> Subscript[I, r]
                    ]


                    enter image description here






                    share|improve this answer














                    Just use Row:



                    Row[
                    Subscript[I, m]/Subscript[I, r] ,
                    " = ",
                    Fit[Table[x, x + x^3, x, 0, 1, .1], 1, x, x^2, x^3, x] /.
                    x -> Subscript[I, r]
                    ]


                    enter image description here







                    share|improve this answer














                    share|improve this answer



                    share|improve this answer








                    edited yesterday









                    m_goldberg

                    82.6k869190




                    82.6k869190










                    answered yesterday









                    Ulrich Neumann

                    5,080413




                    5,080413











                    • If I try to join that with a string as in the OP I get the same error: "StringJoin::string: String expected at position 2 in...".
                      – orome
                      yesterday










                    • With Row[...] you can combine strings and Style-objects!
                      – Ulrich Neumann
                      yesterday










                    • It never fails that no matter what I'm trying to do, I eventually reach the point where I kick myself and ask: Why didn't I just do this in Python!
                      – orome
                      yesterday
















                    • If I try to join that with a string as in the OP I get the same error: "StringJoin::string: String expected at position 2 in...".
                      – orome
                      yesterday










                    • With Row[...] you can combine strings and Style-objects!
                      – Ulrich Neumann
                      yesterday










                    • It never fails that no matter what I'm trying to do, I eventually reach the point where I kick myself and ask: Why didn't I just do this in Python!
                      – orome
                      yesterday















                    If I try to join that with a string as in the OP I get the same error: "StringJoin::string: String expected at position 2 in...".
                    – orome
                    yesterday




                    If I try to join that with a string as in the OP I get the same error: "StringJoin::string: String expected at position 2 in...".
                    – orome
                    yesterday












                    With Row[...] you can combine strings and Style-objects!
                    – Ulrich Neumann
                    yesterday




                    With Row[...] you can combine strings and Style-objects!
                    – Ulrich Neumann
                    yesterday












                    It never fails that no matter what I'm trying to do, I eventually reach the point where I kick myself and ask: Why didn't I just do this in Python!
                    – orome
                    yesterday




                    It never fails that no matter what I'm trying to do, I eventually reach the point where I kick myself and ask: Why didn't I just do this in Python!
                    – orome
                    yesterday

















                     

                    draft saved


                    draft discarded















































                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f183303%2fhow-do-i-treat-the-results-of-fit-as-text%23new-answer', 'question_page');

                    );

                    Post as a guest













































































                    Popular posts from this blog

                    How to check contact read email or not when send email to Individual?

                    Bahrain

                    Postfix configuration issue with fips on centos 7; mailgun relay