Skip to main content

Questions tagged [r-faq]

The r-faq tag is created to group a limited number of questions discussing problems that come up regularly on the R tag. It is not the official FAQ on R for SO, but should serve as an interesting source of information on common problems.

53 votes
4 answers
35k views

What does |> (pipe greater than) mean in R?

I have recently come across the code |> in R. It is a vertical line character (pipe) followed by a greater than symbol. Here is an example: mtcars |> head() What is the |> code doing?
Ian Campbell's user avatar
  • 24.5k
120 votes
5 answers
18k views

What are the differences between R's native pipe `|>` and the magrittr pipe `%>%`?

In R 4.1 (May 2021) a native pipe operator was introduced that is "more streamlined" than previous implementations. I already noticed one difference between the native |> and the magrittr ...
sieste's user avatar
  • 8,817
13 votes
1 answer
14k views

How should I deal with "'someFunction' is not an exported object from 'namespace:somePackage'" error? [closed]

I have this error: 'someFunction' is not an exported object from 'namespace:somePackage' Does anyone know how to solve it?
zx8754's user avatar
  • 55.3k
16 votes
1 answer
5k views

How to order data by value within ggplot facets

I have the following data frame: library(tidyverse) tdat <- structure(list(term = c("Hepatic Fibrosis / Hepatic Stellate Cell Activation", "Cellular Effects of Sildenafil (Viagra)", "Epithelial ...
littleworth's user avatar
  • 5,119
17 votes
1 answer
1k views

Create a group index for values connected directly and indirectly

I would like to generate indices to group observations based on two columns. But I want groups to be made of observation that share, at least one observation in commons. In the data below, I want to ...
Malta's user avatar
  • 1,963
64 votes
3 answers
179k views

How to debug "contrasts can be applied only to factors with 2 or more levels" error?

Here are all the variables I'm working with: str(ad.train) $ Date : Factor w/ 427 levels "2012-03-24","2012-03-29",..: 4 7 12 14 19 21 24 29 31 34 ... $ Team ...
Troy's user avatar
  • 703
13 votes
1 answer
19k views

`lm` summary not display all factor levels

I am running a linear regression on a number of attributes including two categorical attributes, B and F, and I don't get a coefficient value for every factor level I have. B has 9 levels and F has ...
Karen Roberts's user avatar
21 votes
1 answer
3k views

What are primitive, internal, builtin, and special functions? [closed]

I have seen that some functions that call C-code are described as primitive, internal, builtin, or special. What are these functions?
Richie Cotton's user avatar
107 votes
2 answers
250k views

What does "The following object is masked from 'package:xxx'" mean?

When I load a package, I get a message stating that: "The following object is masked from 'package:xxx' For example, if I load testthat then assertive, I get the following: library(testthat) ...
Richie Cotton's user avatar
39 votes
5 answers
42k views

dplyr left_join by less than, greater than condition

This question is somewhat related to issues Efficiently merging two data frames on a non-trivial criteria and Checking if date is between two dates in r. And the one I have posted here requesting if ...
rajvijay's user avatar
  • 1,691
30 votes
7 answers
77k views

R: How to split a data frame into training, validation, and test sets?

I'm using R to do machine learning. Following standard machine learning methodology, I would like to randomly split my data into training, validation, and test data sets. How do I do that in R? I ...
stackoverflowuser2010's user avatar
57 votes
4 answers
46k views

How do I get a list of built-in data sets in R?

Can someone please help how to get the list of built-in data sets and their dependency packages?
mockash's user avatar
  • 1,350
19 votes
1 answer
3k views

Issue when passing variable with dollar sign notation ($) to aes() in combination with facet_grid() or facet_wrap()

I am doing some analysis in ggplot2 at the moment for a project and by chance I stumbled across some (for me) weird behavior that I cannot explain. When I write aes(x = cyl, ...) the plot looks ...
Christoph's user avatar
  • 575
48 votes
4 answers
108k views

Read SAS sas7bdat data into R

What options does R have for reading files in the native SAS format, sas7bdat, into R? The NCES Common Core, for example, contains an extensive repository of data files saved in this format. For ...
123 votes
10 answers
99k views

Get filename without extension in R

I have a file: ABCD.csv The length before the .csv is not fixed and vary in any length. How can I extract the portion before the .csv?
Matrix.cursor's user avatar

15 30 50 per page
1
2 3 4 5
17