mosaic plots:
assocplot (graphics)
Cohen-Friendly association plot indicating deviations from independence of rows and columns in a 2-dimensional contingency tables.
assocplot(x, col = c("black", "red"), space = 0.3,
main = NULL, xlab = NULL, ylab = NULL)
mosaicplot (graphics)
Plots a mosaic on the current graphics device.
mosaicplot(x, main = deparse(substitute(x)),
sub = NULL, xlab = NULL, ylab = NULL,
sort = NULL, off = NULL, dir = NULL,
color = NULL, shade = FALSE, margin = NULL,
cex.axis = 0.66, las = par("las"),
type = c("pearson", "deviance", "FT"), ...)
## S3 method for class 'formula':
mosaicplot(formula, data = NULL, ...,
main = deparse(substitute(data)), subset,
na.action = stats::na.omit)
mosaic (vcd)
Plots (extended) mosaic displays.
## Default S3 method:
mosaic(x, condvars = NULL,
split_vertical = NULL, direction = NULL, spacing = NULL,
spacing_args = list(), gp = NULL, expected = NULL, shade = NULL,
highlighting = NULL, highlighting_fill = grey.colors, highlighting_direction = NULL,
zero_size = 0.5, zero_split = FALSE, zero_shade = NULL,
zero_gp = gpar(col = 0), panel = NULL, main = NULL, sub = NULL, ...)
## S3 method for class 'formula'
mosaic(formula, data, highlighting = NULL,
..., main = NULL, sub = NULL, subset = NULL, na.action = NULL)
e.g. mosaic(Freq~Var3+Var2 | Var1, data=y, shade=T, zero_size=0, zero_shade=T, legend=T, labeling_args=list(set_varnames=c(Var1='Gruppe',Var2='aktiv', Var3='Gespräche'),set_labels=list(Var3=c('nein', 'ja'), Var1=c('WKG','IVG','keine')), rep=T))
An easy way to make a treemap
my personal notepad - for all the things I used to write on pieces of paper ( which where never seen again esp. when I needed them ) ...
Thursday, April 28, 2011
Friday, April 8, 2011
String operations in R
search and replace functions:
replace first occurrence:
- sub(pattern, replacement, x, ignore.case = FALSE)
and replace all occurences:
- gsub(pattern, replacement, x, ignore.case = FALSE)
e.g.
sub("ich", "wir", "ich Ich ICH") --------> "wir Ich ICH"
sub("ich", "wir", "ich Ich ICH", ignore.case=T) --------> "wir Ich ICH"
gsub("ich", "wir", "ich Ich ICH", ignore.case=T)--------> "wir wir wir"
additional:
useful packages:
- gsubfn -> Homepage
replace first occurrence:
- sub(pattern, replacement, x, ignore.case = FALSE)
and replace all occurences:
- gsub(pattern, replacement, x, ignore.case = FALSE)
e.g.
sub("ich", "wir", "ich Ich ICH") --------> "wir Ich ICH"
sub("ich", "wir", "ich Ich ICH", ignore.case=T) --------> "wir Ich ICH"
gsub("ich", "wir", "ich Ich ICH", ignore.case=T)--------> "wir wir wir"
additional:
useful packages:
- gsubfn -> Homepage
Wednesday, April 6, 2011
Changing the order of Factors (in plots)
use reorder
-> Here is the example from the internal help:
bymedian <- with(InsectSprays, reorder(spray, count, median))
boxplot(count ~ bymedian, data = InsectSprays,
xlab = "Type of spray", ylab = "Insect count",
main = "InsectSprays data", varwidth = TRUE,
col = "lightgray")
reorder(spray,count,median) reorders the factor levels of InsectSprays$spray (the first argument of reorder), not the factor itself;
the third argument of reorder - some aggregate function - operates on the column InsectSprays$count (the second argument of reorder) and defines therefore the new order.
In the example above the median of InsectSprays$count for each group of InsectSprays$spray is calculated, and the levels are reordered ascending according to the medians of each group.
look at the differences:
> InsectSprays$spray
[1] A A A A A A A A A A A A B B B B B B B B B B B B C C C C C C C C C C C C D D
[39] D D D D D D D D D D E E E E E E E E E E E E F F F F F F F F F F F F
Levels: A B C D E F
> with(InsectSprays, reorder(spray,count,median))
[1] A A A A A A A A A A A A B B B B B B B B B B B B C C C C C C C C C C C C D D
[39] D D D D D D D D D D E E E E E E E E E E E E F F F F F F F F F F F F
attr(,"scores")
A B C D E F
14.0 16.5 1.5 5.0 3.0 15.0
Levels: C E D A F B
> with(InsectSprays, reorder(spray,count,min))
[1] A A A A A A A A A A A A B B B B B B B B B B B B C C C C C C C C C C C C D D
[39] D D D D D D D D D D E E E E E E E E E E E E F F F F F F F F F F F F
attr(,"scores")
A B C D E F
7 7 0 2 1 9
Levels: C E D A B F
you can also use it in the definition of graphics:
library(lattice)
picture<-barchart(reorder(name, Freq) ~ Freq | iv, groups=dropout, data=zahlen, xlab='', stack=T, auto.key=list(text=c('Aktiv','dropout'), columns=2))
If you want to change the order of a factor without an aggregating function (e.g. if the levels have a natural order like "tiny, normal, big") read the post Creating Factors
-> Here is the example from the internal help:
bymedian <- with(InsectSprays, reorder(spray, count, median))
boxplot(count ~ bymedian, data = InsectSprays,
xlab = "Type of spray", ylab = "Insect count",
main = "InsectSprays data", varwidth = TRUE,
col = "lightgray")
reorder(spray,count,median) reorders the factor levels of InsectSprays$spray (the first argument of reorder), not the factor itself;
the third argument of reorder - some aggregate function - operates on the column InsectSprays$count (the second argument of reorder) and defines therefore the new order.
In the example above the median of InsectSprays$count for each group of InsectSprays$spray is calculated, and the levels are reordered ascending according to the medians of each group.
look at the differences:
> InsectSprays$spray
[1] A A A A A A A A A A A A B B B B B B B B B B B B C C C C C C C C C C C C D D
[39] D D D D D D D D D D E E E E E E E E E E E E F F F F F F F F F F F F
Levels: A B C D E F
> with(InsectSprays, reorder(spray,count,median))
[1] A A A A A A A A A A A A B B B B B B B B B B B B C C C C C C C C C C C C D D
[39] D D D D D D D D D D E E E E E E E E E E E E F F F F F F F F F F F F
attr(,"scores")
A B C D E F
14.0 16.5 1.5 5.0 3.0 15.0
Levels: C E D A F B
> with(InsectSprays, reorder(spray,count,min))
[1] A A A A A A A A A A A A B B B B B B B B B B B B C C C C C C C C C C C C D D
[39] D D D D D D D D D D E E E E E E E E E E E E F F F F F F F F F F F F
attr(,"scores")
A B C D E F
7 7 0 2 1 9
Levels: C E D A B F
you can also use it in the definition of graphics:
library(lattice)
picture<-barchart(reorder(name, Freq) ~ Freq | iv, groups=dropout, data=zahlen, xlab='', stack=T, auto.key=list(text=c('Aktiv','dropout'), columns=2))
If you want to change the order of a factor without an aggregating function (e.g. if the levels have a natural order like "tiny, normal, big") read the post Creating Factors
Trouble installing modules from CPAN
all the settings are done - and all should be ok - but it still does not work:
delete the folder .cpan from your home directory - and try again!
delete the folder .cpan from your home directory - and try again!
VBA-Error "Run-time error'-2147467259 (80004005)': Method 'Add of object 'CommandBar Controls' failed".
You have a faulting add-in. Go to Office Button>Excel Options...>Add-ins and
uncheck all then add one at a time back in and re-start excel when the issue
comes back,that's your issue.
--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
nick_hodgeTAKETHISOUT
from here.
uncheck all then add one at a time back in and re-start excel when the issue
comes back,that's your issue.
--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
nick_hodgeTAKETHISOUT
from here.
Subscribe to:
Posts
(
Atom
)