我正在创建三个新列,并尝试根据其他两列中的值填充它们。新列为“0-5”,“5-15”和“15-30”。首先,我想知道单元格是否在这些范围内,根据列的上限和下限,所以我创建了用'y'填充它们的规则(对于是)。现在,如果存在y,我想用值列中的相应数字替换y。我被困在这一部分。我也想知道是否有一种更容易的方法直接填写“0-5”,“5-15”和“15-30”列,基于上/下列的“值”中的数字而没有首先放入“y”。
x y upper lower 0-5 5-15 15-30 value
378828.1 1682697.2 2 12 y y NA 4.04
378828.1 1682697.2 12 37 NA y y 1.00
381625.6 1684852.5 0 63 y y y 1.96
388660.2 1704566.9 5 18 NA y y 2.65
答案 0 :(得分:0)
我们可以使用Alamofire.request(URL_SCAN_ID, method: .post, parameters: ScanParameters, encoding: JSONEncoding.default) .responseJSON
{
response in
//printing response
print(response.request!)
print(response.response!)
print(response.data!)
print(response.result)
print(response.error)
//getting the json value from the server
let value = response.result.value
print(value!)
let json = JSON(value!)
let productdesc0:JSON = json["productdesc"]
let productdescString = productdesc0.string
self.performSegue(withIdentifier: "ScanInfo", sender: productdescString)
func prepareForSegue(segue: UIStoryboardSegue, sender: Any){
if (segue.identifier == "ScanInfo"){
let destinationVC = segue.destination as! ScanInfoViewController
destinationVC.productdescription01 = productdescString!
print("oeiii",sender)
}
}
包以及dplyr
函数来完成此操作:
match
library(dplyr)
dat %>%
rowwise() %>%
mutate(`0-5` = ifelse(any(match(lower:upper, 0:4)), value, NA),
`5-15` = ifelse(any(match(lower:upper, 5:14)), value, NA),
`15-30` = ifelse(any(match(lower:upper, 15:29)), value, NA))
x y upper lower value `0-5` `5-15` `15-30`
<dbl> <dbl> <int> <int> <dbl> <dbl> <dbl> <dbl>
1 378828.1 1682697 2 12 4.04 4.04 4.04 NA
2 378828.1 1682697 12 37 1.00 NA 1.00 1.00
3 381625.6 1684853 0 63 1.96 1.96 1.96 1.96
4 388660.2 1704567 5 18 2.65 NA 2.65 2.65