Error in creating R-UDF
I am trying to create a R-UDF in Vertica which will the extract the coefficients from the summary of regression that I run. However the following error comes up- ERROR 0: the getPrototype(1) and getReturntype(2) method must have matching number of returnTypes
coefficient<- function(x) {
library(survival)
library(peperr)
data1<- as.data.frame(x)
fit<- coxph(Surv(time_survived,censor)~total_6703+total_6704+press_200+press_400, data=data1)
sum_pb<- summary(fit)
sum_pb1<- sum_pb$coefficients[1:4]
sum_pb2<- as.data.frame(sum_pb1)
names<- c("coeff_6703", "coeff_6704","coeff_press200","coeff_press400")
sum_pb3<- cbind(sum_pb2, names)
sum_pb4<- as.data.frame(sum_pb3)
sum_pb4
}
netFactory<-function()
{
list(name=coefficient,udxtype=c("transform"),intype=c("any"),outtype=c("float"),outtypecallback=netReturnType)
}
netReturnType<-function(x)
{
ret=data.frame(datatype=rep(NA,1),length=rep(NA,1),scale=rep(NA,1),name=rep(NA,1))
ret[1,1]="float"
ret[1,4]="coefficients"
ret[2,1]="varchar"
ret[2,4]="coeff_names"
ret
}
What does this error refer to? How can i correct this?