R on MacOS Error: vector memory exhausted (limit reached?)

For those using Rstudio, I’ve found that setting Sys.setenv(‘R_MAX_VSIZE’=32000000000), as has been suggested on multiple StackOverflow posts, only works on the command line, and that setting that parameter while using Rstudio does not prevent this error: Error: vector memory exhausted (limit reached?) After doing some more reading, I found this thread, which clarifies the problem … Read more

Error: could not find function “%>%”

You need to load a package (like magrittr or dplyr) that defines the function first, then it should work. The pipe operator %>% was introduced to “decrease development time and to improve readability and maintainability of code.” But everybody has to decide for himself if it really fits his workflow and makes things easier. For more information on magrittr, click here. Not using … Read more

ggplot2 line chart gives “geom_path: Each group consist of only one observation. Do you need to adjust the group aesthetic?”

you only have to add group = 1 into the ggplot or geom_line aes(). For line graphs, the data points must be grouped so that it knows which points to connect. In this case, it is simple — all points should be connected, so group=1. When more variables are used and multiple lines are drawn, the grouping … Read more

ggplot2 line chart gives “geom_path: Each group consist of only one observation. Do you need to adjust the group aesthetic?”

You only have to add group = 1 into the ggplot or geom_line aes(). For line graphs, the data points must be grouped so that it knows which points to connect. In this case, it is simple — all points should be connected, so group=1. When more variables are used and multiple lines are drawn, the grouping … Read more

ggplot2 error : Discrete value supplied to continuous scale

Evidently, you can’t have different color aesthetics for two different geoms. As a workaround, use a fill aesthetic for the points instead. This means you have to use a point marker style that has a filled interior (see ?pch and scroll down for the available point styles). Here’s a way to do that: Adding colour=NA … Read more

$ operator is invalid for atomic vectors for dataframe R

The problem is relatively simple. You have If we break this down you’ll see the problem: You create an empty data frame and assign it to the object team_seed You create a matrix by column-binding the vectors playoff_teams, seed_col, and BPI_col. You assign this matrix to the object team_seed, thus obliterating the empty data frame you created in the first line. R just overwrote … Read more

R Error in x$ed : $ operator is invalid for atomic vectors

From the help file about $ (See ?”$”) you can read: $ is only valid for recursive objects, and is only discussed in the section below on recursive objects. Now, let’s check whether x is recursive A recursive object has a list-like structure. A vector is not recursive, it is an atomic object instead, let’s check Therefore you get an … Read more

Reasons for using the set.seed function

The need is the possible desire for reproducible results, which may for example come from trying to debug your program, or of course from trying to redo what it does: These two results we will “never” reproduce as I just asked for something “random”: These two, however, are identical because I set the seed: There is … Read more