-
Notifications
You must be signed in to change notification settings - Fork 0
/
.Rhistory
87 lines (87 loc) · 2.97 KB
/
.Rhistory
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
install.packages("optparse")
install.packages("XML")
install.packages("base64enc")
datapath = "E:\\mzkit\\DATA\\nmr\\HMDB00005.nmrML"
nmrMLfiles = datapath
L<-length(nmrMLfiles)
sa <- NULL
snam <- NULL
I=1
i=1
tree <- xmlTreeParse(nmrMLfiles[i])
root <- xmlRoot(tree)
suppressPackageStartupMessages(library("optparse"))
suppressPackageStartupMessages(library("XML"))
print("XML loaded")
suppressPackageStartupMessages(library("base64enc"))
print("base64enc loaded")
tree <- xmlTreeParse(nmrMLfiles[i])
root <- xmlRoot(tree)
SFO1 <- as.double(xmlAttrs(xmlElementsByTagName(root, "irradiationFrequency", recursive = TRUE)[[1]])["value"])
SWH <- as.double(xmlAttrs(xmlElementsByTagName(root, "sweepWidth", recursive = TRUE)[[1]])["value"])
SW <- SWH/SFO1
TD <- as.integer(xmlAttrs(xmlElementsByTagName(root, "DirectDimensionParameterSet", recursive = TRUE)[[1]])["numberOfDataPoints"])
TEMP <- as.double(xmlAttrs(xmlElementsByTagName(root, "sampleAcquisitionTemperature", recursive = TRUE)[[1]])["value"])
RELAXDELAY <- as.double(xmlAttrs(xmlElementsByTagName(root, "relaxationDelay", recursive = TRUE)[[1]])["value"])
SPINNINGRATE <- as.double(xmlAttrs(xmlElementsByTagName(root, "spinningRate", recursive = TRUE)[[1]])["value"])
PULSEWIDTH <- as.double(xmlAttrs(xmlElementsByTagName(root, "pulseWidth", recursive = TRUE)[[1]])["value"])
# Instrument
instrument <- xmlElementsByTagName(root, "instrumentConfiguration", recursive = TRUE)[[1]]
instrument.name <- xmlAttrs(xmlElementsByTagName(instrument,"cvParam")[[1]])["name"]
instrument.probe <- xmlAttrs(xmlElementsByTagName(instrument,"userParam")[[1]])["value"]
what <- "double"
endian <- "little"
sizeof <- 8
compression <- "gzip"
fidData <- xmlElementsByTagName(root, "fidData", recursive = TRUE)[["acquisition.acquisition1D.fidData"]]
fidData
b64string <- gsub("\n", "", xmlValue(fidData))
b64string
byteFormat <- xmlAttrs(fidData)["byteFormat"]
byteFormat
raws <- memDecompress(base64decode(b64string), type=compression)
raws
signal <- readBin(raws, n=length(raws), what=what, size=sizeof, endian = endian)
signal
datapath
signal
td <- length(signal)
rawR <- signal[seq(from = 1, to = td, by = 2)]
rawI <- signal[seq(from = 2, to = td, by = 2)]
rawR
mediar<-mean(as.integer(rawR[c((3*length(rawR)/4):length(rawR))]),na.rm = TRUE)
mediai<--mean(as.integer(rawI[c((3*length(rawR)/4):length(rawR))]),na.rm = TRUE)
mediar
mediai
help(".Call")
help(message)
install.packages("RANN")
require(RANN)
data("iris")
iris_unique <- unique(iris) # Remove duplicates
data <- as.matrix(iris_unique[,1:4])
data
k=10
nearest <- nn2(data, data, k, searchtype = "standard")
nearest
str(nearest)
i = nearest[[1]]
i
i[, -1]
head(i)
head(i[, -1])
Rcpp.package.skeleton("testpack",
example_code=TRUE,
attributes=TRUE,
cpp_files=c("conv1.cpp"))
require(Rcpp)
Rcpp.package.skeleton("testpack",
example_code=TRUE,
attributes=TRUE,
cpp_files=c("conv1.cpp"))
getwd()
setwd("E:\\GCModeller\\src\\runtime\\IronR")
Rcpp.package.skeleton("testpack",
example_code=TRUE,
attributes=TRUE,
cpp_files=c("conv1.cpp"))