Category: status

  • Vim plugin surround Normal mode ds delete a…

    vous pouvez l'essayer Vim plugin surround

    Normal mode
    ———–
    ds – delete a surrounding
    cs – change a surrounding
    ys – add a surrounding
    yS – add a surrounding and place the surrounded text on a new line + indent it
    yss – add a surrounding to the whole line
    ySs – add a surrounding to the whole line, place it on a new line + indent it
    ySS – same as ySs

    Visual mode
    ———–
    s – in visual mode, add a surrounding
    S – in visual mode, add a surrounding but place text on new line + indent it

    http://www.catonmat.net/blog/vim-plugins-surround-vim/

  • http jeromyanglim blogspot ca 2010 05 abbreviations of…

    http://jeromyanglim.blogspot.ca/2010/05/abbreviations-of-r-commands-explained.html

    250+ R commands.
    Often times R users suffer from difficulties finding what commands are available for a specific process.
    This lists 250+ R commands in table.

  • Surround a VIM plugin that surrounds a word…

    Surround, a VIM plugin that surrounds a word or a line.

    http://www.catonmat.net/blog/vim-plugins-surround-vim/

  • Perl Getopt Long The module check wrong argument…

    Perl Getopt::Long.

    The module check wrong argument but does not check when no argument is provided.
    In order to check if there is no argument as well as wrong argument,
    check the argument also.

    GetOptions( 'test=s' => \$option_test )
        or exit(1);
    
    defined($option_test)
        or die("Missing argument -t");
    

    http://www.perlmonks.org/?node_id=789974

  • Auto size of images in Beamer class \usepackage…

    Auto size of images in Beamer class.

    \usepackage{letltxmacro}
    \makeatletter
    \def\maxwidth{\ifdim\Gin@nat@width>\linewidth\linewidth\else\Gin@nat@width\fi}
    \makeatother
    \AtBeginDocument{
      \LetLtxMacro\Oldincludegraphics\includegraphics
      \renewcommand{\includegraphics}[2][]{%
        \Oldincludegraphics[#1,width=\maxwidth]{#2}}
    }
    

    http://tex.stackexchange.com/questions/67434/redefine-includegraphics-for-beamer#comment143600_67434

  • Beamer paper size is smaller than usual paper…

    Beamer paper size is smaller than usual paper size.
    The “paper size” of a beamer presentation is fixed to 128mm times 96mm.

    With this trick, the normal font can be shown nicely.
    But be cautious setting the image size with absolute value.
    or use

    \includegraphics[width=0.6\textwidth]{graphics.pdf}
    

    http://web.mit.edu/8.13/presentations/beameruserguide.pdf

    Citation

  • R color palettes # Basic grDevice rainbow topo…

    R color palettes

    1. Basic grDevice

    rainbow()
    topo.colors()
    terrain.colors()
    heat.colors()

    my.palette <- terrain.colors(100)
    
    1. RColoBrewer package
    display.brewer.all()
    

    my.palette <- brewer.pal(n, name) For example, my.palette <- brewer.pal(9, "Blues") However, the number of colors is limited up to 9, in most colors. Then use this.

    more.color.palette <- colorRampPalette(brewer.pal(9,"Blues"))(100)
    

    http://stackoverflow.com/questions/3832850/color-schemes-in-r
    http://www.compbiome.com/2010/12/r-using-rcolorbrewer-to-colour-your.html

  • RColorBrewer palette names

    RColorBrewer palette names.

  • Change the label of legend not by changing…

    Change the label of legend not by changing the data.

    # data
    grp <- gl(n=4,k=20,labels=c("group a","group b","group c", "group d"))
    value <- runif(n=80, min=10, max=150)
    outcome <- cut(value,2)
    data <- data.frame(grp,value,outcome)
    
    # Option 1
    # breaks should be exactly the same as the levels of the factor
    ggplot(data, aes(grp, fill=outcome)) + geom_bar() +xlab("group") +
        ylab("number of subjects") + 
        scale_fill_discrete("Serologic response", 
                            breaks=c("(12.1,79.7]","(79.7,147]"),   # should be the same as the levels of the factor
                            labels=c("double negative", "positive for a and/or b")
                            )
    
    # Option 2
    # simpler because factor() takes care of the levels of the factor
    ggplot(data, aes(grp, 
             fill=factor(outcome,labels=c("double negative","positive for a")))) + 
        geom_bar() +xlab("group") +ylab("number of subjects") +
        labs(fill="Serologic response")
    
    

    http://stackoverflow.com/questions/7323191/how-do-i-manually-change-the-key-labels-in-a-legend-in-ggplot2

  • R factors levels labels # sample data originally…

    R factors, levels, labels

    # sample data originally numbers
    # 1 = male, 2 = female
    
    people.n <- c(1, 1, 2, 2, 2)
    people.c <- c("male", "male", "female", "female", "female")
    
    # create a factor
    people.n.f <- factor(people.n, levels = c(1, 2), labels = c("male", "female"))
    people.c.f <- factor(people.c, levels = c("male", "female"), labels = c("male", "female"))
    
    # if you want to change the order of the levels, 
    people.n.f <- factor(people.n, levels = c(2, 1), labels = c("female", "male"))
    
    # levels follows alphabetical order if not specified
    # compare this with people.c.f
    factor(people.c)
    
    # without specifying levels and labels
    # the original data will be used
    factor(people.n)
    
    # once used to create a factor, levels and labels are merged.
    # there is no labels attribute in factor.
    # correct
    levels(people.c.f)
    levels(people.c.f) <- c("man", "woman")
    people.c.f
    
    #wrong
    labels(people.c.f)
    labels(people.c.f) <- c("man", "woman")
    

    Conclusion
    By default, factor() order the levels alphabetical order or numerical order.
    If you want to change the sorting order of levels manually, you need to set it when the factor is created.
    It can not be changed later, even though the levels can be changed.

    When creating a factor, the data and the order should be matched as the example.

    factor(people.c, levels = c("male", "female"), labels = c("male", "female")) 
              ^ ---- same data ---------^    ^-------------same order -----^