当前代码:
[HttpPost]
public JsonResult Listar2()
{
var search = Request.Form.GetValues("search[value]")?[0];
var list = db.Students;
if (!string.IsNullOrEmpty(search))
{
list = list.Where(m => m.name.ToLower().Contains(search.ToLower()) || m.class.ToLower().Contains(search.ToLower()));
}
var draw = Request.Form.GetValues("draw")?[0];
var start = Request.Form.GetValues("start")?[0];
var length = Request.Form.GetValues("length")?[0];
var width = length != null ? Convert.ToInt32(length) : 0;
var skip = start != null ? Convert.ToInt32(start) : 0;
var totalRecords = list.Count();
var resultFinal = list.Skip(skip).Take(width).ToList();
return Json(new
{
data = resultFinal,
draw,
recordsFiltered = totalRecords,
recordsTotal = totalRecords
});
}
使用上面的代码,我试图集中精力让data$light <- ifelse(data$cigs == 1:5, 1, 0)
仅将{{1}中的ifelse
到1
的值1
分配给5
( cigs
是每天抽烟的香烟数量,范围从cigs
到0
)。
答案 0 :(得分:0)
尝试%in%
data$light <- ifelse(data$cigs %in% c(1:5), 1, 0)
或等效地
data$light <- ifelse(data$cigs >=1& data$cigs <=5, 1, 0)