-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmiscell1a.R
More file actions
33 lines (32 loc) · 1.06 KB
/
Copy pathmiscell1a.R
File metadata and controls
33 lines (32 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
lstObjects <- function(envir= .GlobalEnv, target.class)
{
objlist <- ls(envir=envir)
objclass <- sapply(objlist, function(objName) class(get(objName, envir=envir))[1])
data.frame(Name = I(objlist)[objclass==target.class], Class = I(objclass)[objclass==target.class])
}
make.frame <- function(dat,objs)
{
data <- get(dat)
projs <- lapply(objs,get)
projdim <- dim(projs[[1]])[2]
fac <- nrow(data)
a <- sapply(projs,FUN=function(x) data %*% x)
b1 <- numeric(length(a))
dim(b1) <- c(fac,length(objs)*projdim)
for(i in 1:ncol(a))
{
tmp <- a[,i]
dim(tmp) <- c(fac,projdim)
b1[,(1+(i-1)*projdim):(i*projdim)] <- tmp
}
colnames(b1) <- 1:ncol(b1)
b2 <- b1
xnames <- paste('x',1:(ncol(b1)),sep='')
ynames <- paste('y',1:(ncol(b1)),sep='')
colnames(b1)[seq(1,ncol(b1),2)] <- xnames[1:(ncol(b1)/2)]
colnames(b1)[seq(2,ncol(b1),2)] <- ynames[1:(ncol(b1)/2)]
colnames(b2)[seq(1,ncol(b1),2)] <- xnames[(1+ncol(b1)/2):ncol(b1)]
colnames(b2)[seq(2,ncol(b1),2)] <- ynames[(1+ncol(b1)/2):ncol(b1)]
b <- cbind(b1,b2)
return(b)
}