I am trying to run the below simple function in R studio
a<-testfunc15(state,outcome)
{
st<-state
out<-outcome
print(st)
tempdff<-healthcareoutcome[healthcareoutcome$State==st,]
tempdff
}
When i copy and paste of the R prompt of the R studio ,i get an error :
Error: could not find function "testfunc15"
> {
+
+ st<-state
+ out<-outcome
+ print(st)
+ tempdff<-healthcareoutcome[healthcareoutcome$State==st,]
+ tempdff
+
+ }
Error: object 'state' not found
when i try to source it :source("testfunc15.R") then i get this error :
Error in eval(expr, envir, enclos) : could not find function"testfunc15"
I am saving the file in the same getwd() as other functions ,other functions are working fine. Where am i going wrong ? I couldn't find an answer on stackoverflow though there were many questions with the same description. Please help
testfunc15 <- function(state,outcome){