1
[a]                   [b]                   [c]
Chrome            Chrome            Chrome
Chrome            Internet Explorer Chrome
Chrome            Chrome            Chrome
Firefox           Firefox           Chrome
Internet Explorer Chrome            Chrome
Safari            Safari            Chrome

如果这是基本的,我对 SPSS 很抱歉。尝试生成从 a 到 b 的每个选项的频率变化的图形表示(折线图)。然后是a,b,c。

我想,对于每个变量,我需要计算每个选项的百分比,然后绘制它。

任何帮助将不胜感激。

4

1 回答 1

0

生成我认为您想要的内容的简短答案是将您的数据从宽变为长,然后生成摘要图表。下面的例子:

*Making fake data that looks like yours.
input program.
loop #i = 1 to 1000.
    compute caseid = #i.
    compute A = TRUNC(RV.UNIFORM(1,4)).
    compute B = TRUNC(RV.UNIFORM(1,4)).
    compute C = TRUNC(RV.UNIFORM(1,4)).
    end case.
end loop.
end file.
end input program.
dataset name Sim.
value labels A B C
1 'Chrome'
2 'Firefox'
3 'IE'.

*Reshape Wide to long.
VARSTOCASES
/MAKE Browser from A B C
/INDEX Period.

*Now make the summary chart.
GGRAPH
  /GRAPHDATASET NAME="graphdataset" VARIABLES=Period COUNT()[name="COUNT"] Browser
  /GRAPHSPEC SOURCE=INLINE.
BEGIN GPL
 SOURCE: s=userSource(id("graphdataset"))
 DATA: Period=col(source(s), name("Period"), unit.category())
 DATA: COUNT=col(source(s), name("COUNT"))
 DATA: Browser=col(source(s), name("Browser"), unit.category())
 GUIDE: axis(dim(1), label("Period"))
 GUIDE: axis(dim(2), label("Count"))
 GUIDE: legend(aesthetic(aesthetic.color.interior), label("Browser"))
 SCALE: cat(dim(1))
 SCALE: linear(dim(2))
 SCALE: cat(aesthetic(aesthetic.color.interior), include("1.00", "2.00","3.00"))
 ELEMENT: line(position(Period*COUNT), color.interior(Browser), missing.wings())
END GPL.

这产生了这个图表:

在此处输入图像描述

如果您有重复的测量数据(即同一个人浏览多个时间段),您可以在数据中拥有更多的结构,可以绘制图表。一种方法您可以考虑以初始状态为条件的面积图。下面是一个示例,通过一些事后编辑图表产生了这个:

在此处输入图像描述

do if Period = 1.
    compute initial_browser = Browser.
else if Period > 1.
    compute initial_browser = lag(Browser).
end if.
value labels initial_browser
1 'Chrome'
2 'Firefox'
3 'IE'.

GGRAPH
  /GRAPHDATASET NAME="graphdataset" VARIABLES=Period COUNT()[name=
  "COUNT"] initial_browser Browser
  /GRAPHSPEC SOURCE=INLINE.
BEGIN GPL
 SOURCE: s=userSource(id("graphdataset"))
 DATA: Period=col(source(s), name("Period"), unit.category())
 DATA: COUNT=col(source(s), name("COUNT"))
 DATA: initial_browser=col(source(s), name("initial_browser"),unit.category())
 DATA: Browser=col(source(s), name("Browser"), unit.category())
 GUIDE: axis(dim(1), label("Period"))
 GUIDE: axis(dim(2), label("Count"))
 GUIDE: axis(dim(4), label("Initial Browser"), opposite())
 GUIDE: legend(aesthetic(aesthetic.color.interior), label("Browser"))
 SCALE: cat(dim(1))
 SCALE: linear(dim(2), include(0))
 SCALE: cat(dim(4))
 SCALE: cat(aesthetic(aesthetic.color.interior), include("1.00", "2.00",
  "3.00"))
 ELEMENT: area.stack(position(Period*COUNT*1*initial_browser),
  color.interior(Browser), missing.wings())
END GPL.

如果是这种情况,还有很多其他的图表可能性。

于 2013-03-12T13:21:16.337 回答