0

Don't know if I'm getting the syntax wrong or not. I've already downloaded the dplyr package and tidyverse package.

The code below is what I wrote:

Watch_time_hour <- mutate(twitchdata,Watch_time_hours == Watchtime(Minutes)/60)

Below is the error message I get from typing in this code.

Problem while computing ..1 = Watch_time_hours == Watchtime(Minutes)/60. Caused by error in mask$eval_all_mutate(): ! object 'Watch_time_hours' not found

stefan
  • 90,330
  • 6
  • 25
  • 51
Sakouna
  • 1
  • 1
  • Try with `Watch_time_hours = Watchtime(Minutes)/60` using just one equal sign. – stefan Sep 19 '22 at 20:21
  • @stefan I get a new error with this code. Error in mutate(): ! Problem while computing Watch_time_hours = Watchtime(Minutes)/60. Caused by error in Watchtime(): ! could not find function "Watchtime" Watchtime(minutes) is an existing column in the data frame twtichdata – – Sakouna Sep 19 '22 at 20:44
  • In R a **A syntactically valid name consists of letters, numbers and the dot or underline characters and starts with a letter or the dot not followed by a number.** As your variable name includes `()` you have to wrap it in backticks "`". – stefan Sep 19 '22 at 20:46
  • @stefan I found out how to use the mutate function by renaming "Watch time(Minutes)" to WatchTime.Minutes and it worked. Then I found out you can use mutate to create another column named Watch time(Hours), but I still cannot do the calculation with the name Watch time(Hours). It gives me an error saying "! non-numeric argument to binary operator" when I put it in the backtics. Code that gives error - twitchdata_update <- mutate(twitchdata_update,'Watch Time(Minutes)' = 'Watch Time(Hours)'*60). Should I just keep WatchTime.Minutes then rename the column after I'm finished using calculations? – Sakouna Sep 19 '22 at 23:11

0 Answers0