在Vector中替换大于x的值

时间:2017-10-08 12:53:02

标签: replace

我从许多不同的报告中收集数据,有些报告使用不同因子基础上的测量值。

所以矢量看起来像这样:

a <- c("1.5", "1.8", "2.1", "3.4", "4100", "5.1", "6.3", "7.9", "8700", "8.9", "9.0", "11.7")

我想将大于100的数字除以1000.

看另一个我试过的例子

a[a>100] <- a/1000

但这似乎并没有存储正确的结果。任何建议都得到了很好的收获。

1 个答案:

答案 0 :(得分:0)

您使用什么语言? 在大多数动态语言中,你可以做这样的事情

//blueprint for each new entry in the db
var schema = new Schema({
    imagePath: {type:String, required: true},
    title: {type:String, required: true},
    uploads:{type:String},
    description:{type:String}

});

module.exports = function classmodule (){
    this.title = title; 
    this.description = description;
};
// export my mongo model to create my product 
module.exports = mongoose.model('Subject', schema);

你需要调整语法,但通常看起来像这样。

相关问题