0

I am doing an introductory R assignment for one of my stats classes, and I am having some difficulty with the mutate function from tidyverse. When I first used it to convert my gender variable to a factor it worked fine, but then when I tried to use it to convert my Platform to a factor and remove null values it for some reason converted my Platform variables (Pandora and Spotify) to Male and Female.

This is my first StackOverflow post, so sorry if my question could have been formatted better. If I can provide any additional information please let me know, I am really stuck on this.

My RStudio Screen

I am not sure what the problem is and I have tried rechecking the code and changing things around multiple times. The Platform variable should show the Pandora and Spotify labels that are in the source data.

  • 1
    Is there any chance that in the `rename` step, there is change of Platform to Gender (In the image, it is not showed). Please show the `str(music.data)` – akrun Nov 01 '22 at 02:42
  • 1
    Generally, please post sample data and code as copy/pasteable text, not as pictures. The code you show does not change `Platform`'s values from Pandora/Spotify to Male/Female. I suggest you check `music.data` - it's likely you introduced the problem earlier. – Gregor Thomas Nov 01 '22 at 02:43
  • Hi Jacob, welcome to SO! Instead of an image, could you please [edit] your post to include (1) the *text* of your code, copy-and-pasted, and (2) your data. To include your data, run `dput(music.data.cleaned)` in R, then copy-and-paste the result in your post. If it's a very large dataset, you can do `dput(head(music.data.cleaned, 25))` to include the first 25 rows. For the future, have a look at [this answer](https://stackoverflow.com/a/5963610/17303805) about how to ask great R questions on SO. – zephryl Nov 01 '22 at 02:48

0 Answers0