The RapidMiner community is on read-only mode until further notice. Technical support via cases will continue to work as is. For any urgent licensing related requests from Students/Faculty members, please use the Altair academic forum here.

# "R Script"

Can any body help with writing R Scripts?

I have RM v.5.3.005 and R v.2.15.2

Tried to use "Execute Script (R)" operator with this code (kernel regression estimator):

x<-input[1]

y<-input[2]

H <- function(z) {

if (abs(z)<=1)

return((cos(pi*z)+1)/2)

else

return(0)

}

ys <- function(t,x,y,cs) {

m <- length(t)

n <- length(x)

K <- c(1)

result <- c(1)

for (i in 1:m)

{

for (j in 1:n)

K <- H((x-t

I have RM v.5.3.005 and R v.2.15.2

Tried to use "Execute Script (R)" operator with this code (kernel regression estimator):

x<-input[1]

y<-input[2]

H <- function(z) {

if (abs(z)<=1)

return((cos(pi*z)+1)/2)

else

return(0)

}

ys <- function(t,x,y,cs) {

m <- length(t)

n <- length(x)

K <- c(1)

result <- c(1)

for (i in 1:m)

{

for (j in 1:n)

K <- H((x-t

*)/cs)*

denominator <- sum(K)

if (denominator==0)

resultdenominator <- sum(K)

if (denominator==0)

result

*<- 0*

else

{

numerator <-0

for (j in 1:n)

{numerator <- numerator + y*K}

resultelse

{

numerator <-0

for (j in 1:n)

{numerator <- numerator + y*K}

result

*<- numerator/denominator*

}

}

return (result)

}

output<-c(x,y,ys(x,x,y,0.5))

I ran process and got nothing as a result. Reading log got this line:

Feb 16, 2013 12:59:07 PM INFO: Execute Script (R): 1: package 'mlr' is not available (for R version 2.15.2)

So i believe that might be the problem

P.S. Executing the same code in RM's R console everything is OK.}

}

return (result)

}

output<-c(x,y,ys(x,x,y,0.5))

I ran process and got nothing as a result. Reading log got this line:

Feb 16, 2013 12:59:07 PM INFO: Execute Script (R): 1: package 'mlr' is not available (for R version 2.15.2)

So i believe that might be the problem

P.S. Executing the same code in RM's R console everything is OK.

Tagged:

0

## Answers

2Contributor II've read some threads about similar problems and changed my code into this:

x<-Data$a1

y<-Data$a2

H <- function(z) {

if (abs(z)<=1)

return((cos(pi*z)+1)/2)

else

return(0)

}

ys <- function(t,x,y,cs) {

m <- length(t)

n <- length(x)

K <- c(1)

result <- c(1)

for (i in 1:m)

{

for (j in 1:n)

K <- H((x-t

)/cs)denominator <- sum(K)

if (denominator==0)

result

<- 0else

{

numerator <-0

for (j in 1:n)

{numerator <- numerator + y*K}

result

<- numerator/denominator

}

}

return (result)

}

output<-data.frame(x,y,ys(x,x,y,0.5))

Good luck and "make love not war"!!! ;D