Today I need to compute the means for some distributions... and there's no easy
way to do it!
I mean (no pun intended), there is (d,p,r,q) for all distributions (like:
dgamma, pgamma, rgamma, qgamma; dchisq, pchisq, rchisq, dchisp; etc), but there
is no "m"-functions, like a mgamma to get the
Peter Dalgaard wrote:
> I don't think so. I'll give you that it should either be the (number of lines
> - 1)*spacing
> or (number of linefeeds)*spacing, but it's correct to count the height of "M"
> only on the top line.
>
> -pd
>
> It is correct as written
>
Ah, ok, I see now. The "line
There might be a minor typographical error in the documentation of the function
strwidth, namely, from
?strwidth
we get:
"Note that the ‘height’ of a string is determined only by the number of
linefeeds ("\n") it contains: it is the (number of linefeeds - 1) times the
line spacing plus the
I have another environment question.
I understand why this works as expected:
f.factory <- function()
{
y <- 2
fname <- paste("plus", y, sep = ".")
f <- function(x) x + y
assign(fname, f, envir = globalenv())
}
f.factory()
plus.2(2) # 4
and I also understand why this does NOT work:
>From the code below:
y <- 1
f1 <- function() {
cat("y =", y, "\n")
}
f2 <- function() {
y <- 2
f1()
}
f3 <- function() {
y <- 3
f <- f1
f()
}
f4 <- function() {
y <- 4
f <- function() { cat("y =", y, "\n") }
f()
}
f1()
f2()
f3()
f4()
Clearly, f1(), f2() and f4() will
shouldn't your last expression be:
if (any(tst)) big.vector.1[tst] - big.vector.2[tst]
Sure, that was a typo.
Also, I know that `%%` does not make sense neither for Inf nor for big
numbers, but `%/%` - since it's only a special case of `/` - should
make sense; it should be equivalent
I've just found an annoyance with the behaviour of %/% which, BTW,
violated the sacred rule that for all a, and non-zero b:
a = b * (a %/% b) + a %% b
Namely, that Inf %/% n is not Inf, but NaN.
Why is this so? It's an annoyance, because in expressions like:
big.vector.1[a, b, c] -
I think these dates are from some historical database, as they are
labeled BC. And the days might refer to some Epoch of ancient
calendars, maybe the Chinese Calendar whose Epoch was 105 BC (at least
if we can trust Wikipedia:
https://en.wikipedia.org/wiki/Chinese_calendar )
Alberto Monteiro
Thanks to Duncan, Hadley and Henrik.
Duncan, I used Rprof and could pinpoint the critical routine that was
doing the memory crash.
Henrik, you got it right: the culprit was a big matrix of integers,
but where some of its fields are filled with -Inf and Inf. This matrix
is global, it's used only
Is there any way to detect which calls are consuming memory?
I run a program whose global variables take up about 50 Megabytes of
memory, but when I monitor the progress of the program it seems to
allocating 150 Megabytes of memory, with peaks of up to 2 Gigabytes.
I know that the global
I just found a curious behaviour of regexp and I'd like to share with y'all.
gsub(^([[:alnum:]\\[\\]]*).*, \\1, array[n] - 10, perl=T) #
works as expected (array[n])
gsub(^([[:alnum:]\\[\\]]*).*, \\1, array[n] - 10, perl=F) #
doesn't work (a)
I didn't find anything in the documentation explain
Is there any equivalent to chartr for numeric values?
Meaning, something like:
numerictr(c(-1, 42, 666), 1:3, numeric.stuff)
that replaces in numeric.stuff (a vector, matrix, etc) all instances
of -1 for 1, 42 for 2 and 666 for 3?
Alberto Monteiro
Replying to self:
Is there any equivalent to chartr for numeric values?
Meaning, something like:
numerictr(c(-1, 42, 666), 1:3, numeric.stuff)
that replaces in numeric.stuff (a vector, matrix, etc) all instances
of -1 for 1, 42 for 2 and 666 for 3?
match does it. Sorry to ask.
Alberto
This is probably very trivial - so I can't find an answer in the help files.
When I have a series x (x[1], x[2], ... x[n]) and I want to construct a
new series y (y[1], y[2], ... y[m]) such that y's are either interpolations
of the x's (when m n) or a weighted mean (when m n), is there
any
14 matches
Mail list logo