Why is View() capitalized, anyway?

And down the rabbit hole we go.
R
Author
Published

December 7, 2023

Over on BlueSky, David John Baker asks:

Post from David John Baker on BlueSky: Why is does the  `View()` function in R start with a capital V? I have no idea why. Does this have to do with functions that are not just dealing with some sort of standard output? #rstats

My first thought on reading this was that View() in RStudio is built to mask the View() function from utils, and so capitalizes the V because utils capitalized the V. Things are the way they are because they are the way they are, yet again.

But of course, that’s not the actual question – not only did David specify he’s talking about the function in R, not in RStudio, but of course someone decided that utils should capitalize the View() function as well. And this is weird! There are not that many functions in base R that start with a capital letter:

getOption("defaultPackages") |> 
  setdiff("datasets") |> 
  vapply(\(x) paste0("package:", x), character(1)) |> 
  ls() |> 
  strsplit("") |> 
  Filter(f = \(x) x[[1]] %in% LETTERS) |> 
  vapply(paste0, character(1), collapse = "")
 [1] "Rprof"               "Rprofmem"            "RShowDoc"           
 [4] "RSiteSearch"         "Rtangle"             "RtangleFinish"      
 [7] "RtangleRuncode"      "RtangleSetup"        "RtangleWritedoc"    
[10] "RweaveChunkPrefix"   "RweaveEvalWithOpt"   "RweaveLatex"        
[13] "RweaveLatexFinish"   "RweaveLatexOptions"  "RweaveLatexSetup"   
[16] "RweaveLatexWritedoc" "RweaveTryStop"       "Stangle"            
[19] "Sweave"              "SweaveHooks"         "SweaveSyntaxLatex"  
[22] "SweaveSyntaxNoweb"   "SweaveSyntConv"      "URLdecode"          
[25] "URLencode"           "View"               

These functions all follow one of three patterns:

Update:

A few minutes after publishing, Konrad Rudolph points out on Mastodon that there are plenty of functions in the base package itself that are capitalized and don’t match these rules:

ls("package:base") |> 
  strsplit("") |> 
  Filter(f = \(x) x[[1]] %in% LETTERS) |> 
  vapply(paste0, character(1), collapse = "")
 [1] "Arg"                     "Conj"                   
 [3] "Cstack_info"             "Encoding"               
 [5] "Encoding<-"              "F"                      
 [7] "Filter"                  "Find"                   
 [9] "I"                       "Im"                     
[11] "ISOdate"                 "ISOdatetime"            
[13] "La_library"              "La_version"             
[15] "La.svd"                  "LETTERS"                
[17] "Map"                     "Math.data.frame"        
[19] "Math.Date"               "Math.difftime"          
[21] "Math.factor"             "Math.POSIXt"            
[23] "Mod"                     "NCOL"                   
[25] "Negate"                  "NextMethod"             
[27] "NROW"                    "OlsonNames"             
[29] "Ops.data.frame"          "Ops.Date"               
[31] "Ops.difftime"            "Ops.factor"             
[33] "Ops.numeric_version"     "Ops.ordered"            
[35] "Ops.POSIXt"              "Position"               
[37] "R_compiled_by"           "R_system_version"       
[39] "R.home"                  "R.version"              
[41] "R.Version"               "R.version.string"       
[43] "Re"                      "Recall"                 
[45] "Reduce"                  "RNGkind"                
[47] "RNGversion"              "Summary.data.frame"     
[49] "Summary.Date"            "Summary.difftime"       
[51] "Summary.factor"          "Summary.numeric_version"
[53] "Summary.ordered"         "Summary.POSIXct"        
[55] "Summary.POSIXlt"         "Sys.chmod"              
[57] "Sys.Date"                "Sys.getenv"             
[59] "Sys.getlocale"           "Sys.getpid"             
[61] "Sys.glob"                "Sys.info"               
[63] "Sys.localeconv"          "Sys.readlink"           
[65] "Sys.setenv"              "Sys.setFileTime"        
[67] "Sys.setLanguage"         "Sys.setlocale"          
[69] "Sys.sleep"               "Sys.time"               
[71] "Sys.timezone"            "Sys.umask"              
[73] "Sys.unsetenv"            "Sys.which"              
[75] "T"                       "UseMethod"              
[77] "Vectorize"              

One of those is Filter(), which I literally used in the original code chunk and somehow didn’t notice started with a capital letter.

These functions fall into a number of other groups – functions for working with complex numbers, for functional programming and recursion, for setting and getting system information and variables, group generic functions, and a few proper nouns and acronyms like “C” and “RNG”. It’s still not common – 77 out of 1268 objects in the base namespace start with a capital letter – but it’s more common than in recommended packages.

< / update >

But even with that said, View() is the only function in recommended packages that starts with a capital letter that’s not named after a proper noun.1 And it’s been weird for a long time. The original version of the function was also capitalized when it was added by Professor Brian D Ripley way back in 2007:

Commit by Prof. Brian D Ripley on Feb 19 2007, adding the capitalized `View()` function.

Now here’s where we enter the world of wild speculation. Because if we look at the documentation for View(), we can see that this function is meant to “Invoke a Data Viewer”, with “Data Viewer” capitalized like a proper noun in both the function title and description:

The rd documentation file for `View()`. Notably, the Description field capitalizes the phrase Data Viewer.

This isn’t a universal style. If we look for instance at the documentation for edit(), which pre-dates View(),2 we can see that “text editor” is capitalized in the title but not in the description:

The rd documentation file for `edit()`. Notably, the Description field _does not_ capitalize the phrase text editor.

So this makes me suspect that Data Viewer here is being used as a proper noun. This wouldn’t be a unique usage; for instance, the RStudio user guide also describes its viewer as a Data Viewer, capitalized, and a search for “Data Viewer” suggests the phrase is capitalized something like 2/3 of the time on public websites. I have absolutely no knowledge of the tech jargon of 2007, or of the proper styling of “data viewer”,3 but it does seem like it’s sometimes a proper noun.

So, to wildly speculate just a little further: is View() capitalized because “Viewer” was capitalized, at least back in 2007?

Now, here’s a decent piece of evidence against this conjecture: the details section of the View() documentation, added at the same time as the title and description,4 doesn’t capitalize the phrase “data viewer”:

The details section of the `View()` documentation. Data viewer is not capitalized.

That said, this is also not unique. That same RStudio user guide also sometimes writes “data viewer” in lowercase, though in most of the guide it’s treated as a proper noun.

So there’s one guess: maybe View() is capitalized because, like the functions starting with R and S and URL, it’s named after a proper noun. Things are the way they are because they are the way they are, yet again.

If anyone knows more, though – or feels like asking Professor Ripley – please drop me a line. I’d love to know the actual answer.

Footnotes

  1. Merriam-Webster calls “URL” a noun, even if it originated as an acronym, get out of my comments.↩︎

  2. Though I’m not sure who originally wrote it; I get a bit lost in the VCS logs from before base functions were split into sub-packages.↩︎

  3. And I assume these two things are related!↩︎

  4. And the function itself; all of this documentation is also still in the official help file.↩︎