Skip Headers

SAS  SPSS  R-PROJECT  S-PLUS  PROC-SQL

통 계
프 로 그 램 비 교

Go to Documentation Home
HOME
Go to Book List
PRO_home
Go to Table of Contents
연구회
Go to Index
자료실
Go to Master Index
R-PROJECT
Go to Feedback page
MAIL

Go to previous page
Previous
Go to next page
Next

17. Graphics


1. SAS
2. SPSS
3. R-PROJECT
4. S-PLUS
5. PROC SQL

 


1. SAS

MAIN

 

* Basic Graphics in SAS;

OPTIONS _LAST_=BACK.mydata; 

* q1 히스토그램.;

PROC GCHART;
     VBAR q1;
RUN;

 

 

* workshop gender Bar 챠트;

PROC GCHART;
     VBAR workshop gender;
RUN;
 

 

* q2 의해 q1 Scatter plot;

PROC GPLOT;
     PLOT q2*q1;
RUN;

 

 

* 모든 변수의 Scatter plot matrix;

PROC INSIGHT data=back.mydata;

     SCATTER workshop q1 q2 q3 q4 * workshop q1 q2 q3 q4;

RUN;

 


2. SPSS

MAIN

 

*Basic Graphics in SPSS using both legacy commands and GPL.

GET FILE="C:\mydata.sav".

* Legacy SPSS statements for histogram of q1.

GRAPH  /HISTOGRAM=q1 .

* GPL statements for histogram of q1.

GGRAPH

  /GRAPHDATASET NAME="graphdataset" VARIABLES=q1 MISSING=LISTWISE

  REPORTMISSING=NO

  /GRAPHSPEC SOURCE=INLINE.

BEGIN GPL

 SOURCE: s=userSource(id("graphdataset"))

 DATA: q1=col(source(s), name("q1"))

 GUIDE: axis(dim(1), label("q1"))

 GUIDE: axis(dim(2), label("Frequency"))

 ELEMENT: interval(position(summary.count(bin.rect(q1))) , shape.interior(

  shape.square))

END GPL.

 

* Legacy SPSS statements for bar chart of gender.

GRAPH  /BAR(SIMPLE)=COUNT BY gender .

 

* GPL statements for bar chart of gender.

GGRAPH

  /GRAPHDATASET NAME="graphdataset" VARIABLES=gender COUNT()[name=

  "COUNT"] MISSING=LISTWISE REPORTMISSING=NO

  /GRAPHSPEC SOURCE=INLINE.

BEGIN GPL

 SOURCE: s=userSource(id("graphdataset"))

 DATA: gender=col(source(s), name("gender"), unit.category())

 DATA: COUNT=col(source(s), name("COUNT"))

 GUIDE: axis(dim(1), label("gender"))

 GUIDE: axis(dim(2), label("Count"))

 SCALE: cat(dim(1))

 SCALE: linear(dim(2), include(0))

 ELEMENT: interval(position(gender*COUNT), shape.interior(shape.square))

END GPL.

  

* Legacy syntax for scatterplot of q1 by q2.

GRAPH   /SCATTERPLOT(BIVAR)=q1 WITH q2.

 

* GPL syntax for scatterplot of q1 by q2.

GGRAPH

  /GRAPHDATASET NAME="graphdataset" VARIABLES=q1 q2 MISSING=LISTWISE

  REPORTMISSING=NO

  /GRAPHSPEC SOURCE=INLINE.

BEGIN GPL

 SOURCE: s=userSource(id("graphdataset"))

 DATA: q1=col(source(s), name("q1"))

 DATA: q2=col(source(s), name("q2"))

 GUIDE: axis(dim(1), label("q1"))

 GUIDE: axis(dim(2), label("q2"))

 ELEMENT: point(position(q1*q2))

END GPL.

* Chart Builder.

GGRAPH

  /GRAPHDATASET NAME="graphdataset" VARIABLES=workshop q1 q2 q3 q4

  MISSING=LISTWISE REPORTMISSING=NO

  /GRAPHSPEC SOURCE=INLINE.

BEGIN GPL

 SOURCE: s=userSource(id("graphdataset"))

 DATA: workshop=col(source(s), name("workshop"))

 DATA: q1=col(source(s), name("q1"))

 DATA: q2=col(source(s), name("q2"))

 DATA: q3=col(source(s), name("q3"))

 DATA: q4=col(source(s), name("q4"))

 TRANS: workshop_label = eval("workshop")

 TRANS: q1_label = eval("q1")

 TRANS: q2_label = eval("q2")

 TRANS: q3_label = eval("q3")

 TRANS: q4_label = eval("q4")

 GUIDE: axis(dim(1.1), ticks(null()))

 GUIDE: axis(dim(2.1), ticks(null()))

 GUIDE: axis(dim(1), gap(0px))

 GUIDE: axis(dim(2), gap(0px))

 ELEMENT: point(position((

  workshop/workshop_label+q1/q1_label+q2/q2_label+q3/q3_label+q4/q4_label)*(

  workshop/workshop_label+q1/q1_label+q2/q2_label+q3/q3_label+q4/q4_label)))

END GPL.

 

* Legacy SPSS statements for scatterplot matrix of all but gender.

* Gender cannot be used until it is recoded numerically.

GRAPH   /SCATTERPLOT(MATRIX)=workshop q1 q2 q3 q4.

execute.

 

* GPL statements for scatterplot matrix of workshop to q4 excluding gender.

* Gender cannot be used in this context.

GGRAPH

  /GRAPHDATASET NAME="graphdataset" VARIABLES=workshop q1 q2 q3 q4

  MISSING=LISTWISE REPORTMISSING=NO

  /GRAPHSPEC SOURCE=INLINE.

BEGIN GPL

 SOURCE: s=userSource(id("graphdataset"))

 DATA: workshop=col(source(s), name("workshop"))

 DATA: q1=col(source(s), name("q1"))

 DATA: q2=col(source(s), name("q2"))

 DATA: q3=col(source(s), name("q3"))

 DATA: q4=col(source(s), name("q4"))

 TRANS: workshop_label = eval("workshop")

 TRANS: q1_label = eval("q1")

 TRANS: q2_label = eval("q2")

 TRANS: q3_label = eval("q3")

 TRANS: q4_label = eval("q4")

 GUIDE: axis(dim(1.1), ticks(null()))

 GUIDE: axis(dim(2.1), ticks(null()))

 GUIDE: axis(dim(1), gap(0px))

 GUIDE: axis(dim(2), gap(0px))

 ELEMENT: point(position((

  workshop/workshop_label+q1/q1_label+q2/q2_label+q3/q3_label+q4/q4_label)*(

  workshop/workshop_label+q1/q1_label+q2/q2_label+q3/q3_label+q4/q4_label)))

END GPL.

 


3. R-PROJECT

MAIN

* 그래픽 데모 예제 참조

  demo(graphics) , demo(persp),

   library(lattice)

  demo(lattice)

* R 그래픽스(김정일,이상호,유충현) 참고

* http://addictedtor.free.fr/graphiques/

* http://www.ggobi.org/rggobi/

mydata<-read.table ("c:/data/mydata.csv",header=TRUE,

  sep=",",row.names="id")

print(mydata)

attach(mydata) #Makes this the default dataset.

 

* 히스토그램;

hist(q1)

 

* Box Plot;

barplot(c(40,60))


 

 

* Box Plot;

barplot(summary(gender))
 

 

# 문장은 workshop factor 아니기 때문에 에러를 발생한다.

barplot(summary(workshop))

 

# Workshop Factor 만들기 위해서 as.factor함수를 이용.

barplot(summary(as.factor(workshop)))

 

# q2 의해 q1 Scatterplot 생성.

plot(q1,q2)

 

# 전체 데이터 프레임의 Scatterplot matrix 생성.

plot(mydata)

 

 


4. S-PLUS

MAIN

 

load(file="c:\\mydata.Rdata")

print(mydata)

attach(mydata) #Makes this the default dataset.

* 히스토그램;

hist(q1)

 

* Box Plot;

barplot(c(40,60))


 

 

* Box Plot;

barplot(summary(gender))
 

 

# 문장은 workshop factor 아니기 때문에 에러를 발생한다.

barplot(summary(workshop))

 

# Workshop Factor 만들기 위해서 as.factor함수를 이용.

barplot(summary(as.factor(workshop)))

 

# q2 의해 q1 Scatterplot 생성.

plot(q1,q2)

 

# 전체 데이터 프레임의 Scatterplot matrix 생성.

splom(~mydata)

 

 


5. PROC SQL

MAIN