Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

R remove characters in even rows of a specific column

I’m trying to remove the characters in even rows of a specific column.

My dataset looks like this:

name value
apple 3
apple (0,1)
banana 6
banana (-2,6)
cherry 3
cherry (4,6)

And this is what I’m expecting:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

name value
apple 3
(0,1)
banana 6
(-2,6)
cherry 3
(4,6)

Thank you!

>Solution :

You may try:

df$name[!c(TRUE, FALSE)] <- ""

This will assign empty string to even rows of the name column.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading