I need to make some changes to the data frame to be able to create a visual that I want, but I'm stuck. Down below is how the data frame looks like. What I want to do is to make a new variable named 'article'. The values of this variable will be sum_pageviews of the 'Article Based' values from the 'Page' column. Likewise, another variable will be 'info', and its values will be sum_pageviews from 'Informational Based' in Page variable. Then the length of the data frame will be 8 in the end without the repetitiveness of department, and that's what I want to see.
Image down below is how new dataframe is supposed to be look like. I entered on Excel, but I'd like to know code in R.
--> I think I should start with
sum_views%>%group_by(department)%>%mutate
then ifelse or case_when statement, but no idea. Please let me know the codes. Thanks in advance


Aucun commentaire:
Enregistrer un commentaire