[R] remove

Bert Gunter bgunter.4567 at gmail.com
Sun Feb 12 06:36:21 CET 2017


Basic stuff!

Either subscripting or ?subset.

There are many good R tutorials on the web. You should spend some
(more?) time with some.

Cheers,
Bert


Bert Gunter

"The trouble with having an open mind is that people keep coming along
and sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )


On Sat, Feb 11, 2017 at 9:02 PM, Val <valkremk at gmail.com> wrote:
> Hi all,
> I have a big data set and want to  remove rows conditionally.
> In my data file  each person were recorded  for several weeks. Somehow
> during the recording periods, their last name was misreported.   For
> each person,   the last name should be the same. Otherwise remove from
> the data. Example, in the following data set, Alex was found to have
> two last names .
>
> Alex   West
> Alex   Joseph
>
> Alex should be removed  from the data.  if this happens then I want
> remove  all rows with Alex. Here is my data set
>
> df <- read.table(header=TRUE, text='first  week last
> Alex    1  West
> Bob     1  John
> Cory    1  Jack
> Cory    2  Jack
> Bob     2  John
> Bob     3  John
> Alex    2  Joseph
> Alex    3  West
> Alex    4  West ')
>
> Desired output
>
>       first  week last
> 1     Bob     1   John
> 2     Bob     2   John
> 3     Bob     3   John
> 4     Cory     1   Jack
> 5     Cory     2   Jack
>
> Thank you in advance
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list