Displaying 4 results from an estimated 4 matches for "tofigh".
2012 Oct 09
2
plot.new() and grid functions in multipage pdfs
Hi,
when using the grid package, I've come across this weird behaviour
where a call to plot.new() will start a new page for a multi-page pdf,
but then the margins will somehow behave strangely for all but the
first page: here is some code:
pdf("test.pdf"); plot.new(); grid.rect(gp = gpar(fill="blue"));
plot.new(); grid.rect(gp = gpar(fill="blue")); dev.off()
2012 Feb 07
2
predict.naiveBayes() bug in e1071 package
...iveBayes function, you currently do:
L <- exp(L)
L / sum(L) # this is what is returned
you can instead use
sapply(L, function(lp) {1 / sum(exp(L - lp))})
the above comes from the following equality:
x / (x + y + z) = 1 / (1 + exp(log(y) - log(x)) + exp(log(z) - log(x)))
Best wishes,
/Ali Tofigh
2010 Mar 12
2
Redirect/pipe output to less
I'm using R under Linux. Since the help function in R can use the
program less to display text, I'd like to know if it is possible for a
user to do the same. It would be very helpful to be able to view large
objects (matrices/dataframes etc) using less. This is preferable to
redirecting output to file or to clutter the workspace with too much
output. I have tried to use functions pipe and
2012 Apr 24
1
returning functions inside lapply
This has been asked before, but I just cannot figure out why lapply
should behave this way given that R uses lazy evalution. Even after
reading (or at least trying to read) parts of the R language
definition.
> f <- function(x) {function() {x}}
> a <- list(f(1), f(2), f(3))
> a[[1]]() # as expected
[1] 1
> a[[2]]() # as expected
[1] 2
> a[[3]]() # as expected
[1] 3
> b