This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
getwd() | |
# protein.csv 파일을 읽어서 food 데이터 생성 | |
food <- read.csv("./BigData/protein.csv") | |
# 처음 6개의 관측값을 출력/ 더 많은 관측값을 출력하고 싶으면 head(food, n= 출력하고 싶은 수) | |
# 마지막 6개의 관측값을 출력하고 싶을 때에는 tail(food) / 자기 자신이 선택하고싶으면 food[1:6,] | |
head(food) | |
str(food) | |
# 붉은 고기와 흰고기를 대상으로 군집 | |
# kmeans(데이터,centers =) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# getwd() | |
# setwd("D:/BigData/Source") | |
# getwd() | |
# 1~20까지의 값을 갖는 5행 4열의 행렬 mData생성 | |
mData <- matrix(c(1:20), nrow=5) | |
mData | |
# mData의 1열을 제외한 2~4열의 값을 갖는 행렬 mdData 생성 | |
mdData <- mData[,-1] # 행이라면 반대로 [-1,] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
getwd() | |
#R에서 제공하는 기본 데이터인 iris를 이용하여 분류분석 | |
# fix(iris) | |
str(iris) | |
# 분류분석을 위해서 필요한 라이브러리 설치/로드 | |
#install.packages("party") | |
#library(party) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
getwd() | |
setwd("D:/BigData/Source") | |
# 대부분의 분석 툴은 영문을 기반으로 한다. | |
# 한글은 분석하기 어려움 | |
# 한글을 분석해서 wordCloud 형식으로 출력하기 위한 library를 설치 | |
# 한글 | |
install.packages("KoNLP") | |
# 색상 | |
install.packages("RColorBrewer") | |
#WordCloud |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
getwd() | |
setwd("D:/BigData/source") | |
matrixData <- matrix(c(1:20), nrow=4) | |
matrixData | |
class(matrixData) | |
#matrixData 행렬을 데이터프레임으로 변환 | |
matrixData <- as.data.frame(matrixData) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 현재 작업디렉토리 위치 확인 | |
getwd() | |
# 1일, 2일, 3일, 4일, 5일, 6일, 7일을 데이터로 갖는 벡터데이터 dateInfo 생성 | |
dateInfo <- c("1일","2일","3일","4일","5일","6일","7일") | |
# 07시, 12시, 17시 를 데이터로 갖는 벡터데이터 timeInfo 생성 | |
timeInfo <- c("07시","12시","17시") | |
# 20,19,20,22,23,18,20을 데이터로 갖는 벡터데이터 tempInfo07생성 | |
tempInfo07 <- c(20,19,20,22,23,18,20) | |
# 29,29,28,31,31,27,29를 데이터로 갖는 벡터데이터 tempInfo12생성 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
getwd() | |
## 데이터 불러오기 | |
# csv파일을 일반적으로 불러올때 : read.csv("파일명") | |
csvGrocery<-read.csv("./BigData/grocery.csv") | |
csvGrocery | |
# 데이터 분석시 데이터를 확인 함수 : fix() | |
fix(csvGrocery) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
getwd() | |
# read.table() : 외부파일에서 데이터 프레임으로 값을 가져온다 | |
dfData <- read.table("./BigData/employee.txt") | |
dfData | |
# 데이터에서 열이름과 행이름이 지정된 경우에 해당하는 조건을 지정하여 생성 | |
# read.table(파일명, row.name='행구분 열이름', header=T|F) | |
dfData <- read.table("./BigData/employee.txt",row.names='no',header=T) | |
dfData | |
# 데이터프레임에서 각각의 정보를 선택할 때는 리스트와 동일 | |
dfData$name |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
getwd() | |
# 리스트 생성 : listData | |
listData <- list("홍길동",550000, T) | |
listData | |
v <- c(1:5) | |
m <- matrix(c(1:6), nrow=2) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
setwd("D:/BigData/source") | |
getwd() | |
#전치 행렬 : 행과 열을 바꾼 행렬 | |
m <- matrix(c(1:9),nrow=3) | |
m | |
t(m) | |
m | |
# 하삼각행렬 : lower.tri() |
NewerOlder