-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcdp_scatterplot.R
62 lines (56 loc) · 1.63 KB
/
cdp_scatterplot.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
cdp_check = function(){
if(!exists('X')) return("No data has been selected")
cond3 = NCOL(X) >= 2
if(!cond3) return("Select two or more variables")
}
cdp_analysis = function(){
# save.image('Rscripts/cdp_scatterplot.RData')
################# MAIN #################
graphname = sprintf("%s.pdf", tempfile())
svg(filename = graphname, width = PLOT_WIDTH, height = PLOT_HEIGTH)
if(exists("GROUP")){
iGROUP = as.integer(factor(GROUP))
vgroups = unique(GROUP)
ngroups = length(vgroups)
cgroups = palette()[1+1:ngroups]
if(ncol(X) > 2){
cpar = par(no.readonly = TRUE)
if(V1){
pairs(X, bg = cgroups[iGROUP], pch = 22, asp=1) #xlim = range(X), ylim = range(X), oma=c(4,4,6,12))
}else{
pairs(X, bg = cgroups[iGROUP], pch = 22, oma=c(4,4,6,12))
}
par(xpd=TRUE)
legend(x="topright", bty = 'n', legend=vgroups,fill=cgroups, title="")
par(cpar)
}else{
if(V1){
plot(X, bg = cgroups[iGROUP], pch = 22, asp=1) #xlim = range(X), ylim = range(X))
}else{
plot(X, bg = cgroups[iGROUP], pch = 22)
}
legend("topright", bty = 'n', legend=vgroups,fill=cgroups, title="")
}
}else{
if(ncol(X) > 2){
if(V1){
pairs(X, bg = 1, pch = 22, asp=1) #xlim = range(X), ylim = range(X))
}else{
pairs(X, bg = 1, pch = 22)
}
}else{
if(V1){
plot(X, bg = 1, pch = 22, asp = 1) #xlim = range(X), ylim = range(X))
}else{
plot(X, bg = 1, pch = 22)
}
}
}
dev.off()
list(
'text' = "",
'dataframe' = list(),
'graph' = graphname,
'new_data' = list()
)
}