francogrex wrote: > Hi, 2 questions: > > Question 1: example of what I currently do: > > for(i in 1:6){sink("temp.txt",append=TRUE) > dput(i+0) > sink()} > x=scan(file="temp.txt") > print(prod(x)) > file.remove("C:/R-2.5.0/temp.txt") > > But how to convert the output of the loop to a vector that I can manipulate > (by prod or sum etc), without having to write and append to a file?
So, do you want the file at the end or not? If not: x <- 1:6 prod(x) and if this is really the solution you want, the please read the posting guide and the manuals before posting again. > Question 2: > >> deriv(~gamma(x),"x") > > expression({ > .expr1 <- gamma(x) > .value <- .expr1 > .grad <- array(0, c(length(.value), 1), list(NULL, c("x"))) > .grad[, "x"] <- .expr1 * psigamma(x) > attr(.value, "gradient") <- .grad > .value > }) > > BUT > >> deriv3(~gamma(x),"x") > Error in deriv3.formula(~gamma(x), "x") : Function 'psigamma' is not in the > derivatives table > > What I want is the expression for the second derivative (which I believe is > trigamma(x), or psigamma(x,1)), how can I obtain that? By using some algebraic software (rather than a numeric one) or contributing complete derivatives tables for the next R release. Uwe Ligges ______________________________________________ R-help@stat.math.ethz.ch 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.