0
A
回答
0
这可以通过使用ncol()和max()函数来完成,如图所示。一旦获得列索引号,可以提取如下:
X = matrix (1:12, nrow = 4, ncol=3)
#Let soln be the solution vector that stores the corresponding maximum value of each column
soln=c()
#Traverse the matrix column-wise
for (i in 1:ncol(X))
{
#Extract all rows of the ith column and find the maxiumum value in the same column
soln[i]= max(X[,i])
print(soln[i])
}
#Print the solution as a vector
soln
此外,类似的问题被回答here,不使用for循环(通过使用apply()函数)。
相关问题
- 1. 我怎样才能获得rsquare出ANOVA在R中
- 2. 我怎样才能得到
- 3. 我怎样才能得到
- 4. 我怎样才能获得JSON值
- 5. 我怎样才能获得actionName在ActionFilter
- 6. 我怎样才能获得访问Android
- 7. 我怎样才能获得价值? Odoo
- 8. 我怎样才能获得文本QTableWidgetItem
- 9. 我怎样才能获得列表框
- 10. 我怎样才能获得的java.awt.geom
- 11. 我怎样才能获得值“111”
- 12. 我怎样才能找到在R
- 13. 我怎样才能
- 14. 我怎样才能
- 15. 我怎样才能
- 16. 我怎样才能
- 17. 我怎样才能在我的程序中获得_GLOBAL_OFFSET_TABLE_地址?
- 18. 怎样才能获得一个列表?
- 19. 怎样才能获得价值PreferenceFragment
- 20. 我怎样才能得到Parsley.js
- 21. 我怎样才能得到Queryable.Join的MethodInfo
- 22. 我怎样才能得到父组件
- 23. 我怎样才能得到一个TD
- 24. 我怎样才能得到的数字
- 25. 我怎样才能得到statechange
- 26. 我怎样才能得到这些值
- 27. 我怎样才能得到其他表
- 28. 我怎样才能得到一个RejectedExecutionException
- 29. 我怎样才能得到NSScrollView尊重
- 30. 我怎样才能得到一个PortletRequest
非常感谢你,Sukriti – Elwakdy