1

Okay, I know I hate these types of questions as well. However, yesterday this command was working. Today, it is not. I have made changes to my code but at this point it would take so much editing to find out what changes were made, I figured I might as well as here to see if anybody had encountered this problem before.

I am using libraries plyr and dplyr together.

My data looks like this:

> X
        UIID diff edits like memory technical
    1: E2913    1     3    4      1         3
    2: E2939    2     4    1      2         4
    3:  E336    3     4    2      3         4
    4: E2808    3     4    3      1         4
    5: E2684    4     4    2      3         4
   ---                                       
17466: E3147    3     2    2      2         4
17467: E3101    3     2    2      3         3
17468: E3062    3     2    2      2         3
17469: E3051    3     2    2      2         3
17470: E3035    2     2    2      2         3

I use the following command to calculate values collapsed at the UIID level:

summarise(group_by(X, UIID), count=n(), sd_diff=sd(diff, na.rm=TRUE))

Returning:

Error in n() : This function should not be called directly

Removing the n() and running again I get

>summarise(group_by(Rev, UIID), sd_diff  =sd(diff, na.rm=TRUE))
    sd_diff
1   0.988

This is also a problem. I think I should be getting a different sd_diff for every different UIID value. I apologize if this situation seems to be a completely unique problem to me.

Francis Smart
  • 3,316
  • 5
  • 27
  • 54
  • 3
    It looks like `plyr::summarise` shadows `dplyr::summarise` somewhere in your code. Could you try using namespaced call `dplyr::summarise(group_by(X, UIID), count=n(), sd_diff=sd(diff, na.rm=TRUE))` and see if problem persists? – zero323 Jun 28 '15 at 20:25
  • Bingo! `dplyr::summarise` did it. Thank so much! – Francis Smart Jun 28 '15 at 20:28

0 Answers0