Tuesday, April 24, 2012
Plot different characters and colors according to factor on third variable.
Using the example dataset, and starting from running this
I added the following syntax to the Example.Syntax.450.txt file (linked above)
## Two ways to plot based on category in third variable.
plot(NewConf2, NewConf1, pch=as.integer(TwoPlusComputers))
plot(jitter(NewConf2, factor=2), jitter(NewConf1, factor=2), pch=as.integer
(TwoPlusComputers))
coplot (NewConf1 ~ NewConf2 | TwoPlusComputers)
# coplot ( y ~ X | Z)
# y= outcome variable
# X= causal variable
# Z= third variable with categories that cases fall into
# A better way, perhaps
(I copied the general strategy demonstrated on the R blog, here)
AllVars<-data.frame(cbind(
NewConf1,
TwoPlusComputers,
NewConf2,
RecNumbers,
Software,
UseSPSS,
UseExcel,
UseMinitab,
UseStatistica,
UseSAS,
UseR,
UseMplus,
UseFortran,
UseMatLab,
UseStatEase,
UsePython,
UseOther,
computers,
Confidence,
DadaRecConf,
OrgDataExcConf,
CodebookConf,
RdataLoadConf,
ExcelDescConf,
RdescConf,
RexploreConf,
ConsIndexConf,
CorrMatrixConf,
OrgVarRegConf,
InterpRegConf,
ConstGraphConf,
MethoRegStuConf))
Geek <- subset(AllVars, TwoPlusComputers == 1)
NonGeek <- subset(AllVars, TwoPlusComputers == 0)
plot(NewConf1, NewConf2, type='n',
xlab = "Confidence interpreting research",
ylab = "Confidence in research techniques",
main = "Research interpretation predicts technical confidence (Geeks vrs Non)",
col.main = "#444444")
points (jitter(NewConf1) ~ jitter(NewConf2), data = Geek, pch = "G", col = "blue")
points (jitter(NewConf1) ~ jitter(NewConf2), data = NonGeek, pch = "N", col = "red")
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment