1

I have until now been using a variation of an example of rowwise() provided in a previous question successfully but with the dplyr 0.7 update I am getting different output shown below:

    df <- data.frame(A=rnorm(10), B=rnorm(10), C=rnorm(10))

    library(dplyr)
    df %>% rowwise() %>% mutate(Min = min(A, B, C), Max = max(A, B, C))

#             A           B          C       Min      Max
# *       <dbl>       <dbl>      <dbl>     <dbl>    <dbl>
# 1 -0.81771376  0.78083623 -1.2015681 -1.424118 1.422992
# 2  0.21576457  0.21769270  1.4229922 -1.424118 1.422992
# 3 -0.35391619 -0.42959396 -0.7036051 -1.424118 1.422992
# 4 -0.15828301 -1.21686431 -0.8696339 -1.424118 1.422992
# 5  0.33803125 -0.54362240 -0.5093769 -1.424118 1.422992
# 6 -0.32750861 -0.14352295  0.7709994 -1.424118 1.422992
# 7 -1.42411777 -1.22749344 -0.4734610 -1.424118 1.422992
# 8  0.05575431  0.89622715  0.7249636 -1.424118 1.422992
# 9  0.79927939  0.03648687 -1.4104142 -1.424118 1.422992
# 10 -1.41076196 -0.31738310 -0.2915965 -1.424118 1.422992

Where the results were previously the row-wise minimum and maximum they are now the minimum and maximum of each column.

I have checked the dplyr release notes but failed to spot any related points.

Has the use of rowwise() changed (or have redundant uses been removed) in the newest version of dplyr and if so can anyone suggest how I might amend my original code?

Thank you!

MrGraeme
  • 97
  • 1
  • 1
  • 8
  • 3
    Your code works here exactly as intended (with an extra parentheses added) - I get the rowwise minimum and maximum. – ekstroem Jun 22 '17 at 12:43
  • You miss a `)` at your `mutate` call. – www Jun 22 '17 at 12:43
  • `rowwise()` has failed for me sometimes when I load `plyr` or `ggplot2` after loading `dplyr`. Try `rowwise()` with a naive R session. Note: `plyr` `ggplot2` `dplyr` share some dependencies, which seems to cause issues. – CPak Jun 22 '17 at 12:46
  • ekstroem - IS that using the latest version of dplyr? – MrGraeme Jun 22 '17 at 12:47
  • I used `dplyr_0.7.0`. It works as expected. – www Jun 22 '17 at 12:48
  • Yup, you are all correct, it works fine , it was just the order I was loading libraries. It just so happened that I noticed it after updating. Thanks and sorry to waste your time! – MrGraeme Jun 22 '17 at 12:53

0 Answers0