Sure -2*log(x) can be negative, and it can outweigh the k*npar term. Just do:
curve(-2*log(x)+2, 0.1, 10) # for AIC with npar = 1
abline(h=0, v=exp(1), lty=3)
However, that only happens for x exp(1) or even bigger if npar 1. I
think Olivier's real question is: do we believe in likelihoods 1
It's always seemed to me that 'mean' behaved as expected, and 'max' et al
were peculiar. If you passed 2 or more vectors to a function would you
really expect it to concatenate them before doing it's proper job? I'd
rather expect it to behave like 'pmax' and compare them element by element.
? par# then scroll down to look at 'las'
You probably want
par(las=1)
HTH, Mike.
akki wrote:
hi,
When I do a graph. the values on y axe are vertical position. How can I
put
the values in horizontal position?
thanks
[[alternative HTML version deleted]]
apply(mydata,2,nelem,... passes the columns of mydata _one_by_one_ to nelem,
so nelem only sees a vector, and complains if it's expecting a 2d object.
Try this:
nelem-function(x) nlevels(factor(x))
apply(mydata[,mycol.index],2,nelem)
HTH, Mike.
Sébastien-18 wrote:
Dear R users,
I am
Your problem is with ifelse, not with cat.
First clue is that
ifelse(TRUE,{print(yes)},{print(no)}) # results in yes being printed
TWICE. Try this:
tmp - ifelse(TRUE,{print(yes)},{print(no)}) # one yes
tmp # another yes
Try:
print(print(yes)) # prints yes and returns yes invisibly. This
Help on this is in
?plotmath
You can use
ylab = expression(Y Label(m^2))
Use par(mar..) to increase the margin width, and then mtext to place y axis
label:
y - 1:10
x - rnorm(10,5,2000)
par(mar = c(5,6,4,2) + 0.1)
plot(x ~ y,
ylab = ,
las = 1,
type = n,
bty = n
)
Try something like this:
x - c(1,2,6,8,13,0,5,10, runif(10) * 100)
tmp - x %/% 5 + 1
bin.names - paste((0:19) * 5, (1:20) * 5, sep=-)
data.frame(Start = x, Binned_Start = bin.names[tmp])
This assumes you want (eg.) 5 in the 5-10 bin, not the 0-5 bin. You may also
want to make Binned_Start into
You might find the 'arm' package useful. For a good introduction to
heirarchical modeling, using 'arm' and also WinBUGS and R2WinBUGS, read
Gelman, A; J Hill 2007. Data analysis using regression and
multilevel/hierarchical models. Cambridge University Press.
Cheers, Mike.
Ali raza-4 wrote:
I think it would help if the tcl/tk manuals were added to the RGui Help
menu. Why google when they are on your hard drive already?
Cheers, Mike
Mike Prager wrote:
Alberto Monteiro [EMAIL PROTECTED] wrote:
How on Earth can I know what are the arguments of any of the functions of
the
I use something like Gavin's solution for functions which are not used too
often. The problem with using 'source' is that the user environment gets
cluttered.
I 'save' the most useful functions to a single file (MMmisc.Rda), put it
in the HOMEPATH directory (use Sys.getenv(HOMEPATH) to find
You can investigate what's gone wrong after the loop has failed by looking
at the values of i, k, p, and t. Although d[(d[,(i+1)]%in%1),1] produces a
vector, k has only one element. Same with p. Should then be obvious why the
t.test produces an error.
The problem is with the [i] index for k and
The simplest solution in this case would be:
(x[[1]] + x[[2]])/2
But that approach would get messy with 2 matrices in your list. Maybe
change your list to an array, then use 'apply':
n - length(x)
y - array(unlist(x), c(3,2,n))
apply(y, 1:2, mean)
HTH, Mike
Weiwei Shi wrote:
one of my
Take a look at Help Manuals (in PDF) An Introduction to R, section 10.3.
R will recognise the 2nd argument as 'values' iff you define your function
as:
myfun - function(theta, values, X)
You can use
if(missing(values)) {
values - some.expression(X)
}
to deal with cases where the user
Looking at the data, maybe what you need is an array:
array(c(A, B), c(5,6,2), dimnames=list(rownames(A),
colnames(A), c(obs,pred)))
This allows you to keep the names and 'supernames'.
This will work if A and B are matrices, not data frames, so you may have to
use 'as.matrix' first.
HTH,
Thanks, Henrik, but 'foo' doesn't do what I want:
x - some stuff
second - more stuff
foo(first=x, second)
[1] first
Brian's right:
...he wants the argument name if there is one otherwise the
deparsed argument value, but clarification would be helpful.
The function using this compares
Thanks very much to all of you. It looks like 'match.call' is the key, and
both Brian's and Gabor's solutions work fine. --- Mike.
--
View this message in context:
http://www.nabble.com/Getting-names-of-objects-passed-with-%22...%22-tf3850318.html#a10913978
Sent from the R help mailing list
Sorry, I responded a bit too hastily last night, without testing the two
functions properly.
Brian's is shorter but I think the one in my post is a bit more robust:
Indeed! 'f1' only works if at least one of the arguments is named. Otherwise
'nm' is NULL and 'nchar(nm[i])' fails. 'f2' seems to
Is there a tidy way to get the names of objects passed to a function via the
... argument?
rbind/cbind does what I want:
test.func1 - function(...) {
nms - rownames(rbind(..., deparse.level=1))
print(nms)
}
x - some stuff
second - more stuff
test.func1(first=x, second)
[1] first second
library(tcltk)
tt - tktoplevel()
done - tclVar(0)
but - tkbutton(tt, text=OK, command=function() tclvalue(done) - 1)
tkpack(but)
tkwait.variable(done)
works as fine as long as I click the OK. However, if I close
the window (by clicking in the X), R enters into an infinite loop
and
19 matches
Mail list logo