[英]How to not include row name when using rowMeans for dataframe in R
temp = as.data.frame(t(marks))
rownames(temp) = c("John", "Mary", "Mark", "June", "Claire", "Anthony")
names(temp) = c("Module1", "Module2","Module3","Module4","Module5")
rowMeans(temp["June",])
rowMeans 的 output 包括行名,有什么辦法不包括。 我只想要價值。 當前的 output 是
June
87.2
我們可以使用unname
unname(rowMeans(temp["June",]))
或者另一個選項是as.vector
,它也剝離了屬性
as.vector(rowMeans(temp["June",]))
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.