-1

I am interested to look at the source code of match in R. I follow "Compiled code built into the R interpreter" in this answer. This leads me to match.c in Winston Chang's github mirror and I failed to find the code in the file.

Could someone points out where is the source code of base::match in match.c? or am I looking at the wrong file? Thank you.

one
  • 3,121
  • 1
  • 4
  • 24
  • It's [do_match](https://github.com/wch/r-source/blob/7719da74fa0ee8134ae48a9a9b8a955130650484/src/main/unique.c#L1490) in file unique.c. – Rui Barradas Jun 06 '23 at 15:42
  • As descried in the duplicate, if you want to find a function in the source, look in the src/main/names.c file to find the function name in C. That can be found here. https://github.com/wch/r-source/blob/trunk/src/main/names.c#L263 do the function is called `do_match` and you can use github to search of that function name in the rest of the code. – MrFlick Jun 06 '23 at 15:44

2 Answers2

0

Here is the relevant function. It is called from here

fmic_
  • 2,281
  • 16
  • 23
  • 3
    A useful way to find this oneself is to run `pryr::show_c_source(.Internal(match(x)))` – joran Jun 06 '23 at 15:34
  • 1
    I would recommend against linking to anything in github. A better link is to the official CRAN source , currently https://cran.r-project.org/src/base/R-4/R-4.3.0.tar.gz – Carl Witthoft Jun 06 '23 at 15:39
  • @CarlWitthoft Do you really recommend downloading the entire R source code to browse the source? The GitHub view, while not official, is very nice. It has searching functionality and allows you to click on symbols and see all the references to the objects. Plus online you have access to "git blame" so you can see when parts of the file may have changed. – MrFlick Jun 06 '23 at 15:48
  • @MrFlick It's not that huge a D/L . Always better to go with the "real thing" than risk a mismatch that fouls up one's research. You could always install Git on your machine to get the search/link capabilities, btw – Carl Witthoft Jun 06 '23 at 16:57
  • Well, the git history wouldn't be in R-4.3.0.tar.gz because the "real" version control is all in SVN. If you want function linking you'd need to configure your IDE to support C compiling and I'm guessing that's not the setup that most R users have configured. I guess I'm just surprised that would be your first recommendation. I agree it's the most accurate; I just always use the github clone because it's way more convenient for me. But to each their own. – MrFlick Jun 06 '23 at 17:03
0

A better link is to the official CRAN source , currently 4.3.0 In general, as new releases appear, just go to the main page,

Carl Witthoft
  • 20,573
  • 9
  • 43
  • 73