library(RcppOctave)
.CallOctave("version")
loader <- OctaveFunction("
function [DF] = readMatfile()
  clear
  load('leukemia.mat')
  DF = whos();
end")
ld <- loader()
names(ld)
ld$name
ld$size
ld$bytes
ld$class
df <- data.frame(ld$name, ld$bytes, ld$class)
retVar <- OctaveFunction("
function [var] = readMatfile()
  clear
  load('leukemia.mat')
  DF = whos();
  var = geneinfo;
end")

retVar()
size <- ld$size
sapply(size, `[[`, 1)
sapply(size, `[[`, 2)
paste(sapply(size, `[[`, 1), sapply(size, `[[`, 2), sep = "x")
# convert to data frame
sz <- paste(sapply(ld$size, `[[`, 1), sapply(ld$size, `[[`, 2), sep = "x")
df <- data.frame(name = ld$name, size = sz, bytes = ld$bytes, class = ld$class)
df
library(RcppOctave)

o.loader <- OctaveFunction("
function [struct] = readMatfile(mfile)
  load(mfile)
  clear mfile;
  struct = whos();
end
")

matInfo <- function(matFile) {
  ld <- o.loader(matFile)
  sz <- paste(sapply(ld$size, `[[`, 1), sapply(ld$size, `[[`, 2), sep = "x")
  df <- data.frame(name = ld$name, size = sz, bytes = ld$bytes, class = ld$class)
  return(df)
}
matfilepath <- paste(project.extdata, "forearm.mat", sep = "/")
# old <- o.loader(matfilepath)
ld <- o.loader(matfilepath)
#sapply(ld$size, `[[`, 1)
#sapply(ld$size, `[[`, 2)
# typeof(ld$size)
#ld$size
#length(ld$size)
if (typeof(ld$size) == 'list') {
  sz <- paste(sapply(ld$size, `[[`, 1), sapply(ld$size, `[[`, 2), sep = "x")
} else {
  sz <- paste(sapply(ld$size, `[[`, 1), collapse = "x")
}
sz    # numeric

df <- data.frame(name = ld$name, size = sz, bytes = ld$bytes, class = ld$class)
matfilepath <- paste(project.extdata, "leukemia.mat", sep = "/")
# old <- o.loader(matfilepath)
ld <- o.loader(matfilepath)
#sapply(ld$size, `[[`, 1)
#sapply(ld$size, `[[`, 2)
typeof(ld$size)       # if there is more than one element
ld$size
length(ld$size)
mat <- paste(project.extdata, "geyser.mat", sep = "/")
# l2 <- ldr(mat)
matInfo(mat)
source(paste(project.R, "functions.R", sep = "/"))
matfile <- "ethanol.mat"

matfilepath <- paste(project.extdata, matfile, sep = "/")
mf <- matInfo(matfilepath)
mf

matList <- readMatfile(matfile)
names(matList)

mf$name[1]   # Compression
Compression <- matList[[mf$name[1]]]

mf$name[2]   # Equivalence
Equivalence <- matList[[mf$name[2]]]

NOx <- matList[[mf$name[3]]]

comment <- matList[[mf$name[4]]]
matfile <- "galaxy.mat"

matfilepath <- paste(project.extdata, matfile, sep = "/")
mf <- matInfo(matfilepath)
mf

matList <- readMatfile(matfile)
names(matList)
matfile <- "geyser.mat"

matfilepath <- paste(project.extdata, matfile, sep = "/")
mf <- matInfo(matfilepath)
mf

matList <- readMatfile(matfile)

geyser <- matList$geyser
savetoRda(geyser, file = "geyser.rda")
matfile <- "forearm.mat"

matfilepath <- paste(project.extdata, matfile, sep = "/")
mf <- matInfo(matfilepath)
mf

matList <- readMatfile(matfile)
# names(matList)
forearm <- matList$forearm
savetoRda(forearm, file = "forearm.rda")
matfile <- "leukemia.mat"

matfilepath <- paste(project.extdata, matfile, sep = "/")
mf <- matInfo(matfilepath)
mf

matList <- readMatfile(matfile)

geneinfo <- matList %>%
  map_df
matfile <- "galaxy.mat"

matfilepath <- paste(project.extdata, matfile, sep = "/")
mf <- matInfo(matfilepath)
mf

matList <- readMatfile(matfile)

EastWest <- matList$EastWest
NorthSouth <- matList$NorthSouth
Velocity <- matList$Velocity

savetoRda(EastWest, NorthSouth, Velocity, file = "galaxy.rda")
matList %>%
  map_dbl(length)
name <- mf$name         # get the names from the Octave object
setNames(matList, name) # assign names in name to objects in matList


AlfonsoRReyes/martinezEDA documentation built on May 5, 2019, 4:54 a.m.