rpy2 - Error in sqrt(e.pow) : non-numeric argument to mathematical function












1















I am using a robust stats package from Rand Wilcox from within rpy2 and hitting a snag when running a robust test for comparing n groups.



The following function takes a DataFrame, and as far as I can tell from the docs, integers representing the columns for the dependent variable and the groups assignments:



wilcox.btrim(df,g=2,dp=1)


When I run it from rpy2, I get the error:



Error in sqrt(e.pow) : non-numeric argument to mathematical function


The same error occurs if, as the first and only input, I pass a list of lists or a df where each column contains the group values. Both of these are also suitable ways of calling the function.



This is my DataFrame:



x = [1, 2, 3]
x = random.choices(x, k=150)
y = np.random.normal(0, 1, 150)

df = pd.DataFrame({
'dependent_variable': y,
'group_labels': x
})

df.head(10)

dependent_variable group_labels
-1.258020 1
0.357578 3
0.809774 1
0.330426 3
-0.210970 2


This is how to get the package so that you are able to reproduce the error:



import pandas as pd
import rpy2.robjects as robjects
import random
import numpy as np
from rpy2.robjects import pandas2ri
from urllib.request import urlopen
from rpy2.robjects.packages import SignatureTranslatedAnonymousPackage
pandas2ri.activate()


url = urlopen('https://dornsife.usc.edu/assets/sites/239/docs/Rallfun-v35.txt')
string = b''.join(url.readlines()).decode()
wilcox = SignatureTranslatedAnonymousPackage(string, "wilcox")


Any idea what is going on here?










share|improve this question





























    1















    I am using a robust stats package from Rand Wilcox from within rpy2 and hitting a snag when running a robust test for comparing n groups.



    The following function takes a DataFrame, and as far as I can tell from the docs, integers representing the columns for the dependent variable and the groups assignments:



    wilcox.btrim(df,g=2,dp=1)


    When I run it from rpy2, I get the error:



    Error in sqrt(e.pow) : non-numeric argument to mathematical function


    The same error occurs if, as the first and only input, I pass a list of lists or a df where each column contains the group values. Both of these are also suitable ways of calling the function.



    This is my DataFrame:



    x = [1, 2, 3]
    x = random.choices(x, k=150)
    y = np.random.normal(0, 1, 150)

    df = pd.DataFrame({
    'dependent_variable': y,
    'group_labels': x
    })

    df.head(10)

    dependent_variable group_labels
    -1.258020 1
    0.357578 3
    0.809774 1
    0.330426 3
    -0.210970 2


    This is how to get the package so that you are able to reproduce the error:



    import pandas as pd
    import rpy2.robjects as robjects
    import random
    import numpy as np
    from rpy2.robjects import pandas2ri
    from urllib.request import urlopen
    from rpy2.robjects.packages import SignatureTranslatedAnonymousPackage
    pandas2ri.activate()


    url = urlopen('https://dornsife.usc.edu/assets/sites/239/docs/Rallfun-v35.txt')
    string = b''.join(url.readlines()).decode()
    wilcox = SignatureTranslatedAnonymousPackage(string, "wilcox")


    Any idea what is going on here?










    share|improve this question



























      1












      1








      1








      I am using a robust stats package from Rand Wilcox from within rpy2 and hitting a snag when running a robust test for comparing n groups.



      The following function takes a DataFrame, and as far as I can tell from the docs, integers representing the columns for the dependent variable and the groups assignments:



      wilcox.btrim(df,g=2,dp=1)


      When I run it from rpy2, I get the error:



      Error in sqrt(e.pow) : non-numeric argument to mathematical function


      The same error occurs if, as the first and only input, I pass a list of lists or a df where each column contains the group values. Both of these are also suitable ways of calling the function.



      This is my DataFrame:



      x = [1, 2, 3]
      x = random.choices(x, k=150)
      y = np.random.normal(0, 1, 150)

      df = pd.DataFrame({
      'dependent_variable': y,
      'group_labels': x
      })

      df.head(10)

      dependent_variable group_labels
      -1.258020 1
      0.357578 3
      0.809774 1
      0.330426 3
      -0.210970 2


      This is how to get the package so that you are able to reproduce the error:



      import pandas as pd
      import rpy2.robjects as robjects
      import random
      import numpy as np
      from rpy2.robjects import pandas2ri
      from urllib.request import urlopen
      from rpy2.robjects.packages import SignatureTranslatedAnonymousPackage
      pandas2ri.activate()


      url = urlopen('https://dornsife.usc.edu/assets/sites/239/docs/Rallfun-v35.txt')
      string = b''.join(url.readlines()).decode()
      wilcox = SignatureTranslatedAnonymousPackage(string, "wilcox")


      Any idea what is going on here?










      share|improve this question
















      I am using a robust stats package from Rand Wilcox from within rpy2 and hitting a snag when running a robust test for comparing n groups.



      The following function takes a DataFrame, and as far as I can tell from the docs, integers representing the columns for the dependent variable and the groups assignments:



      wilcox.btrim(df,g=2,dp=1)


      When I run it from rpy2, I get the error:



      Error in sqrt(e.pow) : non-numeric argument to mathematical function


      The same error occurs if, as the first and only input, I pass a list of lists or a df where each column contains the group values. Both of these are also suitable ways of calling the function.



      This is my DataFrame:



      x = [1, 2, 3]
      x = random.choices(x, k=150)
      y = np.random.normal(0, 1, 150)

      df = pd.DataFrame({
      'dependent_variable': y,
      'group_labels': x
      })

      df.head(10)

      dependent_variable group_labels
      -1.258020 1
      0.357578 3
      0.809774 1
      0.330426 3
      -0.210970 2


      This is how to get the package so that you are able to reproduce the error:



      import pandas as pd
      import rpy2.robjects as robjects
      import random
      import numpy as np
      from rpy2.robjects import pandas2ri
      from urllib.request import urlopen
      from rpy2.robjects.packages import SignatureTranslatedAnonymousPackage
      pandas2ri.activate()


      url = urlopen('https://dornsife.usc.edu/assets/sites/239/docs/Rallfun-v35.txt')
      string = b''.join(url.readlines()).decode()
      wilcox = SignatureTranslatedAnonymousPackage(string, "wilcox")


      Any idea what is going on here?







      python r rpy2






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Dec 3 '18 at 13:58







      campo

















      asked Nov 28 '18 at 16:09









      campocampo

      1309




      1309
























          0






          active

          oldest

          votes











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          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',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53523661%2frpy2-error-in-sqrte-pow-non-numeric-argument-to-mathematical-function%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53523661%2frpy2-error-in-sqrte-pow-non-numeric-argument-to-mathematical-function%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks

          Calculate evaluation metrics using cross_val_predict sklearn

          Insert data from modal to MySQL (multiple modal on website)