How to fix an error message “Error in round(pwfst, 3) : non-numeric argument to mathematical function”












0















I am using



pwfst <-stamppFst(gl, nboots=1, percent=95, nclusters=1)
round(pwfst,3)


This works perfectly if nboots = 1, but when I try nboots = 3,
I get the following error:



Error in round(pwfst, 3) : non-numeric argument to mathematical function


I want to eventually use nboots = 100



I have read several posts with



non-numeric argument to mathematical function


But none relate to this problem. One post advised advised ensuring I only had the necessary packages loaded. I have done that and no change.



Has anyone any ideas please?
thanks.



EDIT: pwfstis not a list.
It has this form - there are 5 more columns



              Bees Nest Ridge_12 Bees Nest Ridge_15 Broken Back Trail Cousins Creek
Bees Nest Ridge_12 NA NA NA NA
Bees Nest Ridge_15 0.092 NA NA NA
Broken Back Trail 0.124 0.067 NA NA
Cousins Creek 0.396 0.352 0.376 NA
Sawpit Rd 0.104 0.046 0.077 0.349
Wallaby Rocks 0.450 0.384 0.421 0.540
Bees Nest Ridge_13 0.161 0.098 0.132 0.403
Wingen Maid 0.433 0.376 0.409 0.537
Bees Nest Ridge_14 0.086 0.025 0.056 0.354


Second edit:



str(pwfst)


returns



num [1:9, 1:9] NA 0.0922 0.1243 0.3964 0.1038 ...
- attr(*, "dimnames")=List of 2
..$ : chr [1:9] "Bees Nest Ridge_12" "Bees Nest Ridge_15" "Broken Back Trail" "Cousins Creek" ...
..$ : chr [1:9] "Bees Nest Ridge_12" "Bees Nest Ridge_15" "Broken Back Trail" "Cousins Creek" ...






Hopefully that is enough info for someone to be able to help me.
Thanks,
Ruth P










share|improve this question





























    0















    I am using



    pwfst <-stamppFst(gl, nboots=1, percent=95, nclusters=1)
    round(pwfst,3)


    This works perfectly if nboots = 1, but when I try nboots = 3,
    I get the following error:



    Error in round(pwfst, 3) : non-numeric argument to mathematical function


    I want to eventually use nboots = 100



    I have read several posts with



    non-numeric argument to mathematical function


    But none relate to this problem. One post advised advised ensuring I only had the necessary packages loaded. I have done that and no change.



    Has anyone any ideas please?
    thanks.



    EDIT: pwfstis not a list.
    It has this form - there are 5 more columns



                  Bees Nest Ridge_12 Bees Nest Ridge_15 Broken Back Trail Cousins Creek
    Bees Nest Ridge_12 NA NA NA NA
    Bees Nest Ridge_15 0.092 NA NA NA
    Broken Back Trail 0.124 0.067 NA NA
    Cousins Creek 0.396 0.352 0.376 NA
    Sawpit Rd 0.104 0.046 0.077 0.349
    Wallaby Rocks 0.450 0.384 0.421 0.540
    Bees Nest Ridge_13 0.161 0.098 0.132 0.403
    Wingen Maid 0.433 0.376 0.409 0.537
    Bees Nest Ridge_14 0.086 0.025 0.056 0.354


    Second edit:



    str(pwfst)


    returns



    num [1:9, 1:9] NA 0.0922 0.1243 0.3964 0.1038 ...
    - attr(*, "dimnames")=List of 2
    ..$ : chr [1:9] "Bees Nest Ridge_12" "Bees Nest Ridge_15" "Broken Back Trail" "Cousins Creek" ...
    ..$ : chr [1:9] "Bees Nest Ridge_12" "Bees Nest Ridge_15" "Broken Back Trail" "Cousins Creek" ...






    Hopefully that is enough info for someone to be able to help me.
    Thanks,
    Ruth P










    share|improve this question



























      0












      0








      0








      I am using



      pwfst <-stamppFst(gl, nboots=1, percent=95, nclusters=1)
      round(pwfst,3)


      This works perfectly if nboots = 1, but when I try nboots = 3,
      I get the following error:



      Error in round(pwfst, 3) : non-numeric argument to mathematical function


      I want to eventually use nboots = 100



      I have read several posts with



      non-numeric argument to mathematical function


      But none relate to this problem. One post advised advised ensuring I only had the necessary packages loaded. I have done that and no change.



      Has anyone any ideas please?
      thanks.



      EDIT: pwfstis not a list.
      It has this form - there are 5 more columns



                    Bees Nest Ridge_12 Bees Nest Ridge_15 Broken Back Trail Cousins Creek
      Bees Nest Ridge_12 NA NA NA NA
      Bees Nest Ridge_15 0.092 NA NA NA
      Broken Back Trail 0.124 0.067 NA NA
      Cousins Creek 0.396 0.352 0.376 NA
      Sawpit Rd 0.104 0.046 0.077 0.349
      Wallaby Rocks 0.450 0.384 0.421 0.540
      Bees Nest Ridge_13 0.161 0.098 0.132 0.403
      Wingen Maid 0.433 0.376 0.409 0.537
      Bees Nest Ridge_14 0.086 0.025 0.056 0.354


      Second edit:



      str(pwfst)


      returns



      num [1:9, 1:9] NA 0.0922 0.1243 0.3964 0.1038 ...
      - attr(*, "dimnames")=List of 2
      ..$ : chr [1:9] "Bees Nest Ridge_12" "Bees Nest Ridge_15" "Broken Back Trail" "Cousins Creek" ...
      ..$ : chr [1:9] "Bees Nest Ridge_12" "Bees Nest Ridge_15" "Broken Back Trail" "Cousins Creek" ...






      Hopefully that is enough info for someone to be able to help me.
      Thanks,
      Ruth P










      share|improve this question
















      I am using



      pwfst <-stamppFst(gl, nboots=1, percent=95, nclusters=1)
      round(pwfst,3)


      This works perfectly if nboots = 1, but when I try nboots = 3,
      I get the following error:



      Error in round(pwfst, 3) : non-numeric argument to mathematical function


      I want to eventually use nboots = 100



      I have read several posts with



      non-numeric argument to mathematical function


      But none relate to this problem. One post advised advised ensuring I only had the necessary packages loaded. I have done that and no change.



      Has anyone any ideas please?
      thanks.



      EDIT: pwfstis not a list.
      It has this form - there are 5 more columns



                    Bees Nest Ridge_12 Bees Nest Ridge_15 Broken Back Trail Cousins Creek
      Bees Nest Ridge_12 NA NA NA NA
      Bees Nest Ridge_15 0.092 NA NA NA
      Broken Back Trail 0.124 0.067 NA NA
      Cousins Creek 0.396 0.352 0.376 NA
      Sawpit Rd 0.104 0.046 0.077 0.349
      Wallaby Rocks 0.450 0.384 0.421 0.540
      Bees Nest Ridge_13 0.161 0.098 0.132 0.403
      Wingen Maid 0.433 0.376 0.409 0.537
      Bees Nest Ridge_14 0.086 0.025 0.056 0.354


      Second edit:



      str(pwfst)


      returns



      num [1:9, 1:9] NA 0.0922 0.1243 0.3964 0.1038 ...
      - attr(*, "dimnames")=List of 2
      ..$ : chr [1:9] "Bees Nest Ridge_12" "Bees Nest Ridge_15" "Broken Back Trail" "Cousins Creek" ...
      ..$ : chr [1:9] "Bees Nest Ridge_12" "Bees Nest Ridge_15" "Broken Back Trail" "Cousins Creek" ...






      Hopefully that is enough info for someone to be able to help me.
      Thanks,
      Ruth P







      r






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Jan 2 at 21:10







      Ruth P

















      asked Jan 2 at 12:56









      Ruth PRuth P

      64




      64
























          1 Answer
          1






          active

          oldest

          votes


















          1














          The documentation for the stamppFst() function reads: "If nboots<2, no bootstrapping is performed and therefore only a matrix of Fst values is returned." Therefore, when pwfst is a result of an analysis using 1 boot you supply a matrix to the round function, which the round function can handle. In other cases (when nboots >= 2), you supply a list to the round function, which it is not able to handle this way.



          If pwfst is a list, you could run lapply(pwfst, round) so that it runs round on every matrix in the list.






          share|improve this answer
























          • Thanks @Lenny. But pwfst is not a list. I would call it a matrix. Bees Nest Ridge_12 Bees Nest Ridge_15 Broken Back Trail Cousins Creek Bees Nest Ridge_12 NA NA NA NA Bees Nest Ridge_15 0.092 NA NA NA Broken Back Trail 0.124 0.067 NA NA Cousins Creek 0.396 0.352 0.376 NA Sawpit Rd 0.104 0.046

            – Ruth P
            Jan 2 at 19:50













          • Please read the documentation again. The function returns a list consisting of 2 matrices and 1 dataframe in case nboots >= 2.

            – Lennyy
            Jan 3 at 6:43











          • Thanks @Lennyy. I did try lapply(pwfst, round) and got this error: Error in Math.data.frame(list(Population1 = c(1L, 1L, 1L, 1L, 1L, 1L, : non-numeric variable(s) in data frame: Population1, Population2, which I cannot deal with. But, I have realised that by leaving out the rounding command, I get an output, so all is good thanks.

            – Ruth P
            Jan 3 at 20:07














          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%2f54006802%2fhow-to-fix-an-error-message-error-in-roundpwfst-3-non-numeric-argument-to%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          The documentation for the stamppFst() function reads: "If nboots<2, no bootstrapping is performed and therefore only a matrix of Fst values is returned." Therefore, when pwfst is a result of an analysis using 1 boot you supply a matrix to the round function, which the round function can handle. In other cases (when nboots >= 2), you supply a list to the round function, which it is not able to handle this way.



          If pwfst is a list, you could run lapply(pwfst, round) so that it runs round on every matrix in the list.






          share|improve this answer
























          • Thanks @Lenny. But pwfst is not a list. I would call it a matrix. Bees Nest Ridge_12 Bees Nest Ridge_15 Broken Back Trail Cousins Creek Bees Nest Ridge_12 NA NA NA NA Bees Nest Ridge_15 0.092 NA NA NA Broken Back Trail 0.124 0.067 NA NA Cousins Creek 0.396 0.352 0.376 NA Sawpit Rd 0.104 0.046

            – Ruth P
            Jan 2 at 19:50













          • Please read the documentation again. The function returns a list consisting of 2 matrices and 1 dataframe in case nboots >= 2.

            – Lennyy
            Jan 3 at 6:43











          • Thanks @Lennyy. I did try lapply(pwfst, round) and got this error: Error in Math.data.frame(list(Population1 = c(1L, 1L, 1L, 1L, 1L, 1L, : non-numeric variable(s) in data frame: Population1, Population2, which I cannot deal with. But, I have realised that by leaving out the rounding command, I get an output, so all is good thanks.

            – Ruth P
            Jan 3 at 20:07


















          1














          The documentation for the stamppFst() function reads: "If nboots<2, no bootstrapping is performed and therefore only a matrix of Fst values is returned." Therefore, when pwfst is a result of an analysis using 1 boot you supply a matrix to the round function, which the round function can handle. In other cases (when nboots >= 2), you supply a list to the round function, which it is not able to handle this way.



          If pwfst is a list, you could run lapply(pwfst, round) so that it runs round on every matrix in the list.






          share|improve this answer
























          • Thanks @Lenny. But pwfst is not a list. I would call it a matrix. Bees Nest Ridge_12 Bees Nest Ridge_15 Broken Back Trail Cousins Creek Bees Nest Ridge_12 NA NA NA NA Bees Nest Ridge_15 0.092 NA NA NA Broken Back Trail 0.124 0.067 NA NA Cousins Creek 0.396 0.352 0.376 NA Sawpit Rd 0.104 0.046

            – Ruth P
            Jan 2 at 19:50













          • Please read the documentation again. The function returns a list consisting of 2 matrices and 1 dataframe in case nboots >= 2.

            – Lennyy
            Jan 3 at 6:43











          • Thanks @Lennyy. I did try lapply(pwfst, round) and got this error: Error in Math.data.frame(list(Population1 = c(1L, 1L, 1L, 1L, 1L, 1L, : non-numeric variable(s) in data frame: Population1, Population2, which I cannot deal with. But, I have realised that by leaving out the rounding command, I get an output, so all is good thanks.

            – Ruth P
            Jan 3 at 20:07
















          1












          1








          1







          The documentation for the stamppFst() function reads: "If nboots<2, no bootstrapping is performed and therefore only a matrix of Fst values is returned." Therefore, when pwfst is a result of an analysis using 1 boot you supply a matrix to the round function, which the round function can handle. In other cases (when nboots >= 2), you supply a list to the round function, which it is not able to handle this way.



          If pwfst is a list, you could run lapply(pwfst, round) so that it runs round on every matrix in the list.






          share|improve this answer













          The documentation for the stamppFst() function reads: "If nboots<2, no bootstrapping is performed and therefore only a matrix of Fst values is returned." Therefore, when pwfst is a result of an analysis using 1 boot you supply a matrix to the round function, which the round function can handle. In other cases (when nboots >= 2), you supply a list to the round function, which it is not able to handle this way.



          If pwfst is a list, you could run lapply(pwfst, round) so that it runs round on every matrix in the list.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Jan 2 at 13:08









          LennyyLennyy

          3,4552417




          3,4552417













          • Thanks @Lenny. But pwfst is not a list. I would call it a matrix. Bees Nest Ridge_12 Bees Nest Ridge_15 Broken Back Trail Cousins Creek Bees Nest Ridge_12 NA NA NA NA Bees Nest Ridge_15 0.092 NA NA NA Broken Back Trail 0.124 0.067 NA NA Cousins Creek 0.396 0.352 0.376 NA Sawpit Rd 0.104 0.046

            – Ruth P
            Jan 2 at 19:50













          • Please read the documentation again. The function returns a list consisting of 2 matrices and 1 dataframe in case nboots >= 2.

            – Lennyy
            Jan 3 at 6:43











          • Thanks @Lennyy. I did try lapply(pwfst, round) and got this error: Error in Math.data.frame(list(Population1 = c(1L, 1L, 1L, 1L, 1L, 1L, : non-numeric variable(s) in data frame: Population1, Population2, which I cannot deal with. But, I have realised that by leaving out the rounding command, I get an output, so all is good thanks.

            – Ruth P
            Jan 3 at 20:07





















          • Thanks @Lenny. But pwfst is not a list. I would call it a matrix. Bees Nest Ridge_12 Bees Nest Ridge_15 Broken Back Trail Cousins Creek Bees Nest Ridge_12 NA NA NA NA Bees Nest Ridge_15 0.092 NA NA NA Broken Back Trail 0.124 0.067 NA NA Cousins Creek 0.396 0.352 0.376 NA Sawpit Rd 0.104 0.046

            – Ruth P
            Jan 2 at 19:50













          • Please read the documentation again. The function returns a list consisting of 2 matrices and 1 dataframe in case nboots >= 2.

            – Lennyy
            Jan 3 at 6:43











          • Thanks @Lennyy. I did try lapply(pwfst, round) and got this error: Error in Math.data.frame(list(Population1 = c(1L, 1L, 1L, 1L, 1L, 1L, : non-numeric variable(s) in data frame: Population1, Population2, which I cannot deal with. But, I have realised that by leaving out the rounding command, I get an output, so all is good thanks.

            – Ruth P
            Jan 3 at 20:07



















          Thanks @Lenny. But pwfst is not a list. I would call it a matrix. Bees Nest Ridge_12 Bees Nest Ridge_15 Broken Back Trail Cousins Creek Bees Nest Ridge_12 NA NA NA NA Bees Nest Ridge_15 0.092 NA NA NA Broken Back Trail 0.124 0.067 NA NA Cousins Creek 0.396 0.352 0.376 NA Sawpit Rd 0.104 0.046

          – Ruth P
          Jan 2 at 19:50







          Thanks @Lenny. But pwfst is not a list. I would call it a matrix. Bees Nest Ridge_12 Bees Nest Ridge_15 Broken Back Trail Cousins Creek Bees Nest Ridge_12 NA NA NA NA Bees Nest Ridge_15 0.092 NA NA NA Broken Back Trail 0.124 0.067 NA NA Cousins Creek 0.396 0.352 0.376 NA Sawpit Rd 0.104 0.046

          – Ruth P
          Jan 2 at 19:50















          Please read the documentation again. The function returns a list consisting of 2 matrices and 1 dataframe in case nboots >= 2.

          – Lennyy
          Jan 3 at 6:43





          Please read the documentation again. The function returns a list consisting of 2 matrices and 1 dataframe in case nboots >= 2.

          – Lennyy
          Jan 3 at 6:43













          Thanks @Lennyy. I did try lapply(pwfst, round) and got this error: Error in Math.data.frame(list(Population1 = c(1L, 1L, 1L, 1L, 1L, 1L, : non-numeric variable(s) in data frame: Population1, Population2, which I cannot deal with. But, I have realised that by leaving out the rounding command, I get an output, so all is good thanks.

          – Ruth P
          Jan 3 at 20:07







          Thanks @Lennyy. I did try lapply(pwfst, round) and got this error: Error in Math.data.frame(list(Population1 = c(1L, 1L, 1L, 1L, 1L, 1L, : non-numeric variable(s) in data frame: Population1, Population2, which I cannot deal with. But, I have realised that by leaving out the rounding command, I get an output, so all is good thanks.

          – Ruth P
          Jan 3 at 20:07






















          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%2f54006802%2fhow-to-fix-an-error-message-error-in-roundpwfst-3-non-numeric-argument-to%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

          MongoDB - Not Authorized To Execute Command

          in spring boot 2.1 many test slices are not allowed anymore due to multiple @BootstrapWith

          How to fix TextFormField cause rebuild widget in Flutter