Anomoly detection

To reiterate technocrat's advice, it's not clear where you're having trouble. A good way to seek help with relatively self contained R-coding problems like this is with a reproducible example. Have a look at this link if you're not sure what that is or how to make one.

Also, this wording suggests you might be asking for help with a homework problem. Is that the case? A lot of people here teach R, and so are reluctant to help students by just answering their homework for them.

Instead, we like to see what you've tried to do, and understand where specifically you'ee having trouble. Right now it looks like you just posted a full homework question here.

Our homework guide is here: FAQ: Homework Policy

How should one ask a homework question?

  1. Never copy-paste instructions from an assignment (even for online courses).
  2. Explicitly mention the course you are taking and use the homework tag.
  3. Ask your question as a reproducible example (reprex), preferably prepared for posting using the reprex package.

What's the best way to ask a specific homework-related question?

We made a short guide for helping folks pose their R-coding questions here.