R

ph
Admin (토론 | 기여)님의 2017년 7월 31일 (월) 12:34 판 (→‎a)
(차이) ← 이전 판 | 최신판 (차이) | 다음 판 → (차이)
이동: 둘러보기, 검색

Functions

quantile

> quantile(duration, c(.32, .57, .98)) 
   32%    57%    98% 
2.3952 4.1330 4.9330

CDF

empirical cdf : ecdf

plot(ecdf(data))

https://www.r-bloggers.com/exploratory-data-analysis-2-ways-of-plotting-empirical-cumulative-distribution-functions-in-r/ https://onlinecourses.science.psu.edu/stat464/node/84

factor to numeric

as.numeric(as.character( data ))

or

as.numeric(as.matrix( data ))

http://stackoverflow.com/questions/24187629/how-to-convert-factor-to-float-without-losing-precision-in-r

Exporting data

write.table(mydata, "c:/mydata.txt", sep="\t")
library(xlsx)
write.xlsx(mydata, "c:/mydata.xlsx")

http://www.statmethods.net/input/exportingdata.html

R language definition

operator등 reference찾아보기 좋다.

Frequency Table

table

or

> library(plyr)
> y = count(mtcars, 'gear')
> y
       gear      freq
1      3         15
2      4         12
3      5         5
> class(y)
[1] "data.frame"

https://www.r-bloggers.com/how-to-get-the-frequency-table-of-a-categorical-variable-as-a-data-frame-in-r/

The result of the previous expression

.Last.value

https://stackoverflow.com/a/4784004/766330 아래와 같이 해두고 써도 좋다고.

lv <- function() .Last.value