我有一个名为dx的矩阵:
a b c d e f g h
cat 0 0 0 0 0 0 0 0
dog 1 0 1 0 0 0 0 1
fish 1 1 1 0 0 0 0 0
egg 0 0 0 0 0 0 0 0
如何删除像猫和蛋一样全部为零的行。这样我才能最终得到这个 -
a b c d e f g h
dog 1 0 1 0 0 0 0 1
fish 1 1 1 0 0 0 0 0
答案 0 :(得分:2)
您可以尝试这样的事情:
m<-matrix(c(1,1,1,0,
0,0,0,0,
1,0,1,0,
0,0,0,0,
1,1,1,1),ncol=4,byrow=T)
m[rowSums(abs(m))!=0,]
答案 1 :(得分:0)
public void Configuration(IAppBuilder app)
{
app.UseHandlerAsync((req, res) =>
{
Console.Clear();
foreach (var item in req.Headers)
{
Console.WriteLine(item.Key + ":" );
foreach (var item1 in item.Value)
{
Console.Write(item1);
}
}
//res.Headers.AcceptRanges.Add("bytes");
//result.StatusCode = HttpStatusCode.OK;
//result.Content = new StreamContent(st);
//result.Content.Headers.ContentLength = st.Length;
res.Headers.Add("ContentType" ,new string[]{"application/octet-stream"});
res.SendFileAsync(Directory.GetCurrentDirectory() + @"\1.mp3");
// res.ContentType = "text/plain";
return res.WriteAsync("Hello, World!");
});
}