我试图在嵌套循环中使用foreach包,但是我的内部循环不识别外部的计数器,我错过了什么?
v3 <- search.compounds.by.mass(100.05,0.5)
foreach(j=2:length(v2)) %:% {
foreach(i=1:length(v3), .combine=rbind) %dopar% {
write.table(paste(v3[i], paste(get.reactions.by.compound(v3[i]), collapse=" "), sep=" "), "file1",quote=FALSE, row.names=FALSE, col.names=FALSE, append=TRUE)
write.table(paste(v3[i], paste(get.pathways.by.compounds(v3[i]), collapse=" "), sep=" "), "file2",quote=FALSE, row.names=FALSE, col.names=FALSE, append=TRUE)
v3 <- search.compounds.by.mass(v2[j],0.5)
}
}
Run Code Online (Sandbox Code Playgroud) 我没有网络开发经验,我想用flask为指定字段的表添加数据,这是我的应用程序
from flask import *
from flask import jsonify
app = Flask(__name__)
@app.route('/page_test')
def page_test():
meas = {"MeanCurrent": 0.05933, "Temperature": 15.095, "YawAngle": 0.0, "MeanVoltage": 0.67367, "VoltageDC": 3.18309, "PowerSec": 0.06923, "FurlingAngle": -0.2266828184, "WindSpeed": 1.884, "VapourPressure": 1649.25948, "Humidity": 0.4266, "WindSector": 0, "AirDensity": 1.23051, "BarPressure": 1020.259, "time": "2015-04-22 20:58:28", "RPM": 0.0, "ID": 1357}
return jsonify(meas)
if __name__ == "__main__":
app.run(debug=True)
Run Code Online (Sandbox Code Playgroud)
这是我的 html (templates/view.html)
<script type="text/javascript" charset="utf8" src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script type="text/javascript" charset="utf8" src="https://cdn.datatables.net/1.10.16/js/jquery.dataTables.min.js"></script>
<script type="text/javascript" charset="utf8" src="https://cdn.datatables.net/buttons/1.5.1/js/dataTables.buttons.min.js"></script>
<script type="text/javascript" charset="utf8" src="https://cdn.datatables.net/select/1.2.5/js/dataTables.select.min.js"></script>
<script type="text/javascript" charset="utf8" src="https://editor.datatables.net/extensions/Editor/js/dataTables.editor.min.js"></script> …Run Code Online (Sandbox Code Playgroud) 我有以下功能
fun <- cxxfunction(
signature(x="numeric", y="numeric",N="interger", w="numeric", p="numeric"),
plugin="RcppArmadillo",
includes=c("#include <stdlib.h>", "#include <cmath>","#include <numeric>","#include <algorithm>","#include <vector>"),
body='
using namespace Rcpp;
RNGScope scope;
NumericVector xa(x);
NumericVector ya(y);
int Na = as<int>(N);
int n_xa = xa.size(), n_ya = ya.size();
arma::mat wa = Rcpp::as<arma::mat>(w);
Rcpp::NumericMatrix n(p); //one column to each x[i]/y
NumericVector limite(n_xa);
arma::mat z(n_ya, n_xa);
arma::mat beta(n_ya, n_xa);
arma::colvec one(xa.begin(), xa.size());
arma::colvec betaM(ya.begin(), ya.size());
arma::colvec betaP(ya.begin(), ya.size());
arma::colvec Prob(ya.begin(), ya.size());
arma::colvec betaC(ya.begin(), ya.size());
z.col(0) = arma::zeros<arma::mat>(n_ya, 1);
NumericVector nV(n_ya);
NumericVector nT(n_ya);
int …Run Code Online (Sandbox Code Playgroud)