i am creating a simple function but getting error, any solution for this
newfreq <- function(data,cut_var,var){
T0<-table(data[[cut_var]],data[[var]])
T1<-as.data.frame.matrix(T0)
T1[,"Revenue"]<-row.names(T1)
T1
}
Error in Function:newfreq <- function(data, cut_var, var) { :
object 'Function' not found
I tested your code and it works (doesn't error) at least.
perhaps your session has spoiled, and restarting it would help you.
newfreq <- function(data,cut_var,var){
T0<-table(data[[cut_var]],data[[var]])
T1<-as.data.frame.matrix(T0)
T1[,"Revenue"]<-row.names(T1)
T1
}
newfreq(head(iris),"Species","Petal.Length")
# 1.3 1.4 1.5 1.7 Revenue
# setosa 1 3 1 1 setosa
# versicolor 0 0 0 0 versicolor
# virginica 0 0 0 0 virginica
i have tried restarting rstudio but still getting the same error
Do you get the error, when you define newfreq, or when you call it with parameters?
gc() worked for me thanks it work now
system
Closed
6
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.