1

I looked at the object returned by Sys.getenv() and found that it's of type character and class Dlist. Its structure is

 'Dlist' Named chr [1:94] "C:\\ProgramData" ...
 - attr(*, "names")= chr [1:94] "ALLUSERSPROFILE" "APPDATA" "asl.log" "ChocolateyInstall" ...

There is no function exported by the base package that seems to create such objects.

BroVic
  • 979
  • 9
  • 26

1 Answers1

2

This clearly demonstrates the extreme flexibility of R's S3 objects. While I was typing my question, it occurred to me to look at the definition of Sys.getenv(). There we find this segment

# ...
if (isFALSE(names)) 
  v[sort.list(n)]
else {
  v <- structure(v, names = n)
  structure(class = "Dlist", v[sort.list(n)])
}
# ...

where v is the vector with the list of environment variables. It can be seen that when the vector is a named one, the function arbitrarily constructs it as an S3 object of class Dlist.

BroVic
  • 979
  • 9
  • 26