Code not working during kniting (problem with mutate() )

library(tidyverse)
library(ggplot2)
library(scales)
library(directlabels)
library(reshape2)
library(forecast)
library(readxl)
df <- read_excel("G:/cleaned.xlsx")

df2<-df%>%
 mutate(total_indians= (df2$`Total Male Indians`+df2$`Total Female Indians`))%>%
 mutate(total_chinese= (df2$`Total Male Chinese`+ df2$`Total Female Chinese`))%>%
 mutate(total_malays= (df2$`Total Male Malays`+ df2$`Total Female Malays`))%>%
 mutate(Percentage_change_population = round((((df$`Total Population`- lag(df$`Total Population`))/ lag(df$`Total Population`))*100), digits=2))
df2<-df2%>%
 mutate(chinese_population_change = round((((df2$total_chinese- lag(df2$total_chinese))/ lag(df2$total_chinese))*100), digits=2))%>%
 mutate(indians_population_change = round((((df2$total_indians- lag(df2$total_indians))/ lag(df2$total_indians))*100), digits=2))%>%
 mutate(malays_population_change = round((((df2$total_malays- lag(df2$total_malays))/ lag(df2$total_malays))*100), digits=2))pe or paste code here

error: problem with mutate(), applied to function

corrected by removing df$ from the formula

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.