R rowMeans()

1 개요[ | ]

R rowMeans()
  • Form Row Means
  • "행별 평균", "가로 평균"

2 모든 열의 평균[ | ]

df <- read.table( header=TRUE, stringsAsFactors=FALSE, text="
english math science
30      60   45
40      70   60
50      80   80
60      90   90
70      90   90
")
df
rowMeans(df)
apply(df, 1, mean)
df$mean <- rowMeans(df)
df
df$mean <- apply(df, 1, mean)
df

3 일부 열의 평균[ | ]

df <- read.table( header=TRUE, stringsAsFactors=FALSE, text="
id english math science
1  30      60   45
2  40      70   60
3  50      80   80
4  60      90   90
5  70      90   90
")
df
df$mean <- rowMeans(df[,2:4])
df
df$mean <- apply(df[,2:4], 1, mean)
df

4 같이 보기[ | ]

5 참고[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}