>RE::VISION CRM

R 데이터 분석

애플과 삼성 구글트렌드 값 비교

YONG_X 2015. 6. 29. 09:10

#==============

read.csv("")
applesam<-read.csv

("applesamsung20150628.csv")
str(applesam)

# converting date types
http://www.statmethods.net/input/dates.h

tml

names(applesam)[1] <- "datetimeStr"
applesam$dateD <- as.Date(substr

(applesam$datetimeStr,1,10))
head(applesam,3)

ncomp <- nrow(applesam)-1
tmp<- applesam$dateD[2:nrow(applesam)]-applesam$dateD[1:ncomp] 
$dateD[1:ncomp] 

applesam$apple<-as.numeric(applesam

$apple)
applesam$samsung<-as.numeric(applesam

$samsung)

length(applesam$apple) ; length

(applesam$samsung)

plot(applesam$apple,applesam$samsung)

require(sqldf)

applesam_d <- sqldf("select dateD, avg

(apple) as avg_app, 
avg(samsung) as avg_sams,
count(*) as cnt
from applesam
group by dateD" )

str(applesam_d)

head(applesam_d,2) ; tail(applesam_d,2)

plot(applesam_d$avg_app,applesam_d

$avg_sams)

tmp1 <- applesam_d[order(applesam_d

$dateD),]

yrange<-range(applesam_d$avg_app, 

applesam_d$avg_sams )

yrange <- c(0,100)
plot(applesam_d$avg_app,ylim=yrange,  

type="b", col=2)
lines(applesam_d$avg_sams,type="b", 

col=3)

# lines(applesam_d$avg_sams*0,type="b", 

col=4)

# lines(100-(applesam_d

$avg_sams*0),type="b", col=5)


#--------- plotting details ------

yrange <- c(0,100)
plot(applesam$apple,ylim=yrange,  

type="b", col=2)
lines(applesam$samsung,type="b", col=3)


applesamsung20150628.csv
0.0MB