[R] Applying a function to all combinations of factors

2005-03-02 Thread Marc Belisle
Is there a way to apply a function, say cor(), to each combination of some number of variables, and this, without using loops? For example, I have day, hour, var1 and var2. How could I compute cor(var1,var2) for each day*hour combination and obtain a matrix with day, hour and the cor value for

[R] dnorm() lead to a probability 1

2003-10-31 Thread Marc Belisle
Howdee, One of my student spotted something I can't explain: a probability 1 vs a normal probability density function. dnorm(x=1, mean=1, sd=0.4) [1] 0.9973557 dnorm(x=1, mean=1, sd=0.39) [1] 1.022929 dnorm(x=1, mean=1, sd=0.3) [1] 1.329808 dnorm(x=1, mean=1, sd=0.1) [1] 3.989423