0

I want to practice this tutorial https://www.guru99.com/r-k-means-clustering.html but I stuck with this code

rescale_df <- df % > %
 mutate(price_scal = scale(price),
     hd_scal = scale(hd),
     ram_scal = scale(ram),
     screen_scal = scale(screen),
     ads_scal = scale(ads),
     trend_scal = scale(trend)) % > %
 select(-c(price, speed, hd, ram, screen, ads, trend))

Error in df % > % mutate(price_scal = scale(price), hd_scal = scale(hd),  : 
  could not find function "% > %"
r2evans
  • 141,215
  • 6
  • 77
  • 149
Champ
  • 1
  • 1
  • 5
    can you load the package `library(dplyr)`. Not clear whether you have spaces or not. It should be `%>%` and not `% > %` – akrun Apr 28 '20 at 18:21
  • 3
    In R, many operators can deal with arbitrary spaces *around* them, such as `+` and `/`; however, functions and "special" operators need to be complete without spaces within them. Just like you would not expect to be able to do `read . csv("file.csv")`, you cannot do `% in %` or `% > %`. – r2evans Apr 28 '20 at 18:23
  • 2
    @r2evans it happens when they. are copying code directly from a pdf or other sources which changes the format. Sometimes, the quotes are also fancy quotes and iif we don't pay that much attention to the characters, it can take some time to debug – akrun Apr 28 '20 at 18:25

0 Answers0