Skip to content

Execution of a function

4 messages · hafida, R. Michael Weylandt, arun

#
Hi
bloc d'instructions
}
Error in readLines(file, warn = FALSE) : 'con' is not a connection
Error: no function to return from, jumping to top level

thanks for helping
hafida, univ of algeria 

 




--
View this message in context: http://r.789695.n4.nabble.com/Execution-of-a-function-tp4639424.html
Sent from the R help mailing list archive at Nabble.com.
#
On Tue, Aug 7, 2012 at 11:26 AM, hafida <hafida-06 at hotmail.fr> wrote:
source() takes a file name, not a function name.

Cheers,
Michael
Don't use return() outside of functions.
#
HI,
Suppose, I have a function like this:

fun1<-function(x){
?ifelse(x[1]<0,
?sum(x[min(which(x<0)):(which.max(x>0)-1)]),
sum(x[min(which(x<0)):max(which(x<0))])
)
?}

#And I save it as "aj.fun" (-- filename)
#Then,
function(x){
?ifelse(x[1]<0,
?sum(x[min(which(x<0)):(which.max(x>0)-1)]),
sum(x[min(which(x<0)):max(which(x<0))])
)
?}

a1<-c(-5,-2,4,2,-4,-6,3)
#[1] -7

Hope this helps.
A.K.


----- Original Message -----
From: hafida <hafida-06 at hotmail.fr>
To: r-help at r-project.org
Cc: 
Sent: Tuesday, August 7, 2012 12:26 PM
Subject: [R] Execution of a function

Hi
bloc d'instructions
}
Error in readLines(file, warn = FALSE) : 'con' is not a connection
Error: no function to return from, jumping to top level

thanks for helping
hafida, univ of algeria 






--
View this message in context: http://r.789695.n4.nabble.com/Execution-of-a-function-tp4639424.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
R-help at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
#
HI Arun and all
+ n <- length(X)
+ iX <- order(X)
+ iz <- order(z)
+ e1 <- -(beta)*z[ iz[1:(i - 1)] ]
+ numer <- E[j] - sum( X[ iX[1:(i - 1)] ] * exp(e1) )
+ e2 <- -(beta)*z[ iz[i:n] ]
+ denom <- sum( exp(e2) )
+ numer/denom
+ }
--
View this message in context: http://r.789695.n4.nabble.com/Execution-of-a-function-tp4639424p4639469.html
Sent from the R help mailing list archive at Nabble.com.