You could store your first approach in a function and lapply it to
your by_hour variable:
df <- data.frame(
hour = factor(rep(1:5,4)),
id = factor(rep(c("supply", "demand"), each = 10)),
price= c(5,7,9,11,13,15,17,19,21,23,
20,18,16,14,12,10,8,6,4,2 ),
quantity = c(3,5,7,13,19,31
Just a further suggestion:
vec <- c(3,2,5,0,1)
mat <- t(sapply(vec,">=",1:max(vec)))
ifelse(mat,1,0)
Cheers,
Christoph
2013/10/11 arun :
> Hi,
>
> In the example you showed:
>
> m1<- matrix(0,length(vec),max(vec))
> 1*!upper.tri(m1)
>
> #or
> m1[!upper.tri(m1)] <- rep(rep(1,length(vec)),vec
Dear all,
I want to fit some observations Y to a set of predictor variables X_i. (and
proceed with model selection with support of the second-order AIC
(AICc)...)
I (think I) "know" that the distribution of Y[i] is Gaussian and has a
variance, which is proportional to its value Y[i]. Say:
x1 <- r
3 matches
Mail list logo