"R colMeans()"의 두 판 사이의 차이

4번째 줄: 4번째 줄:


<syntaxhighlight lang='r' notebook>
<syntaxhighlight lang='r' notebook>
mydf <- read.table( header=TRUE, stringsAsFactors=FALSE, text="
df <- read.table( header=TRUE, stringsAsFactors=FALSE, text="
English Math
English Math
     30  60
     30  60
11번째 줄: 11번째 줄:
     60  90
     60  90
")
")
mydf
df
</syntaxhighlight>
</syntaxhighlight>
<syntaxhighlight lang='r' notebook>
<syntaxhighlight lang='r' notebook>
colMeans(mydf)
colMeans(df)
</syntaxhighlight>
</syntaxhighlight>
<syntaxhighlight lang='r' notebook>
<syntaxhighlight lang='r' notebook>
sapply(mydf, mean)
sapply(df, mean)
</syntaxhighlight>
</syntaxhighlight>
<syntaxhighlight lang='r' notebook>
<syntaxhighlight lang='r' notebook>
apply(mydf, 2, mean)
apply(df, 2, mean)
</source>
</source>



2021년 4월 13일 (화) 22:44 판

1 개요

R colMeans()
  • Form Column Means
df <- read.table( header=TRUE, stringsAsFactors=FALSE, text="
English Math
     30   60
     40   70
     50   80
     60   90
")
df
colMeans(df)
sapply(df, mean)

<syntaxhighlight lang='r' notebook> apply(df, 2, mean) </source>

2 같이 보기

3 참고

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