Displaying 5 results from an estimated 5 matches for "i_d".
Did you mean:
_id
2006 May 22
13
How is this possible?
...following code works, when run through
the WEBrick server I get a "You have a nil object where you didn''t
expect it!"
class Competition < ActiveRecord::Base
has_many :comp_dates, :order=>:position
def initial_date
comp_dates.first
end
def display_dates
i_d = initial_date
if i_d.nil?
return "unknown"
else
return i_d.month
end
end
i_d should never be nil, in the first place; but how on earth does the
i_d.month calls get reached when i_d is nil?
--
Posted via http://www.ruby-forum.com/.
2009 Nov 22
1
How to make a matrix of a number of factors?
...matrix of factors. I'm
wondering if there is a way to make it more general so that I can have
any number of factors (not necessarily 5).
a=3
b=4
c=5
d=6
e=7
A=1:a
B=1:b
C=1:c
D=1:d
E=1:e
X=matrix(nr=a*b*c*d*e,nc=5)
for(i_a in 1:a-1) {
for(i_b in 1:b-1) {
for(i_c in 1:c-1) {
for(i_d in 1:d-1) {
for(i_e in 1:e-1) {
X[(((i_a * b + i_b) * c + i_c) * d + i_d) * e + i_e + 1, ] =
c(i_a+1, i_b+1, i_c+1, i_d+1, i_e+1)
}
}
}
}
}
print(X)
2009 Nov 22
1
Why F value and Pr are not show in summary() of an aov() result?
...ue and Pr?
Rscript multi_factor.R
> a=3
> b=4
> c=5
> d=6
> e=7
>
> A=1:a
> B=1:b
> C=1:c
> D=1:d
> E=1:e
>
> X=matrix(nr=a*b*c*d*e,nc=5)
> colnames(X)=LETTERS[1:5]
>
> for(i_a in 1:a-1) {
+ for(i_b in 1:b-1) {
+ for(i_c in 1:c-1) {
+ for(i_d in 1:d-1) {
+ for(i_e in 1:e-1) {
+ X[(((i_a * b + i_b) * c + i_c) * d + i_d) * e + i_e + 1, ]
= c(i_a+1, i_b+1, i_c+1, i_d+1, i_e+1)
+ }
+ }
+ }
+ }
+ }
>
> Y=matrix(nr=a*b*c*d*e,nc=1)
> for(i in 1:(a*b*c*d*e)) {
+ fa=X[i,'A']
+ fb=X[i,...
2010 Nov 18
0
On efficiency, Vectorize and loops
...imension of X
a<-0 # Lower bound
b<-1 # Upper bound
p<-5 # [See Bathia, Yao, Ziegelmann p. 5)
#######################################
# Building the error function 'epsilon'
#######################################
# Building the vector process 'Z' (which is a iiN(0,I_d) vector process)
# Time varies columnwise
Z<-matrix(rnorm(10*n),nrow=10,ncol=n)
# Defining the deterministic base functions 'zeta'
zeta<-function(u,i){
sqrt(2)+sin(pi*i*u)
}
zeta2<-function(i){force(i);
function(u){
sqrt(2)+sin(pi*outer(i,u))
}
}
zeta3<-function(u,i...
2023 May 17
4
suprising behaviour of tryCatch()
Hello,
I run a fisher.test() in a loop, with the issue that some of the data will not be useable. To protect the loop I used tryCatch but:
sexsnp = rep(NA, 1750)
for(i in 1:1750){tryCatch(sexsnp[i] = fisher.test(table(data[,3], data[,i + 38]))$p, error = function(e) print(NA))}
Error: unexpected '=' in "for(i in 1:1750){tryCatch(sexsnp[i] ="
But this works:
for(i in