grep using a character vector with multiple patterns

In addition to @Marek’s comment about not including fixed==TRUE, you also need to not have the spaces in your regular expression. It should be “A1|A9|A6”. You also mention that there are lots of patterns. Assuming that they are in a vector Then you can create your regular expression directly using paste and collapse = “|”.

What does “The following object is masked from ‘package:xxx'” mean?

The message means that both the packages have functions with the same names. In this particular case, the testthat and assertive packages contain five functions with the same name. When two functions have the same name, which one gets called? R will look through the search path to find functions, and will use the first one that it finds. In this … Read more

lme4 error: boundary (singular) fit: see ?isSingular

Your model did fit, but it generated that warning because your random effects are very small. You can read more about this in this post or the help page Let us look at your data: The effects of PLANT and in combination with Rep is extremely small. Let’s look at the fitted model: This is exactly what happened. So we … Read more

Categories R

readOGR() cannot open file

You could have shown that you have the right path with: perhaps try: or a simpler alternative that is wrapped around that: Update: rgdal has changed a bit and you do not need to separate the path and layer anymore (at least for some formats). So you can do (perhaps still using path.expand) Also, if you … Read more

Categories R

ggplot2 manually specifying colour with geom_line

As stated by @juba in the comments, you should use scale_colour_manual instead of scale_fill_manual. Moreover, you are trying to plot to many lines and errorbars in one plot. They overlap each other to much and it is therefore hard to distuinguish between the lines/errorbars. An example with the use of facetting (and some simplification of your code): this … Read more

Categories R

How to sum a variable by group

Using aggregate: In the example above, multiple dimensions can be specified in the list. Multiple aggregated metrics of the same data type can be incorporated via cbind: (embedding @thelatemail comment), aggregate has a formula interface too Or if you want to aggregate multiple columns, you could use the . notation (works for one column too) or tapply: Using this data:

Categories R

Plot a legend outside of the plotting area in base graphics?

Maybe what you need is par(xpd=TRUE) to enable things to be drawn outside the plot region. So if you do the main plot with bty=’L’ you’ll have some space on the right for a legend. Normally this would get clipped to the plot region, but do par(xpd=TRUE) and with a bit of adjustment you can get a legend as far right … Read more

Categories R