Skip to content

Instantly share code, notes, and snippets.

@dialektike
Last active June 30, 2016 11:52
Show Gist options
  • Save dialektike/9653708704f3d76d91c9f68f054d7c36 to your computer and use it in GitHub Desktop.
Save dialektike/9653708704f3d76d91c9f68f054d7c36 to your computer and use it in GitHub Desktop.
R에서 데이터 프래임을 만들고 정렬하고, 열 이름을 바꾸는 방법
> A <- c("apple", "fineApple")
> A
[1] "apple" "fineApple"
> B <- c(100 ,200)
> testing <- data.frame(A,B)
> testing
A B
1 apple 100
2 fineApple 200
> library(plyr)
> arrange(testing, A)
A B
1 apple 100
2 fineApple 200
> arrange(testing, desc(A))
A B
1 fineApple 200
2 apple 100
> names(testing)
[1] "A" "B"
> names(testing)[2]
[1] "B"
> names(testing)[2] <- c("BB")
> names(testing)[2]
[1] "BB"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment