@@ -111,7 +111,7 @@ NumericVector xx(y.begin(), y.end());
111
111
NumericVector xx =
112
112
NumericVector::create(1.0, 2.0, 3.0, 4.0);
113
113
NumericVector yy =
114
- NumericVector::create(Named[ "foo"] = 1.0,
114
+ NumericVector::create(Named( "foo") = 1.0,
115
115
_["bar"] = 2.0);
116
116
// _ short for Named
117
117
```
@@ -434,17 +434,18 @@ double zz = Rf_rnorm(0, 2);
434
434
# Environment
435
435
436
436
``` cpp
437
- // Obtain an R environment
438
- Environment stats ("package: stats ");
439
- Environment env( 2 ); // by position
440
-
441
437
// Special environments
442
438
Environment::Rcpp_namespace ();
443
439
Environment::base_env ();
444
440
Environment::base_namespace ();
445
441
Environment::global_env ();
446
442
Environment::empty_env ();
447
443
444
+ // Obtain an R environment
445
+ Environment stats ("package: stats ");
446
+ Environment env( 2 ); // by position
447
+ Environment glob = Environment::global_env();
448
+
448
449
// Extract function from specific environment
449
450
Function rnorm = stats[ "rnorm"] ;
450
451
@@ -457,7 +458,7 @@ std::string x = glob["x"];
457
458
glob.assign( "foo" , 3 );
458
459
int foo = glob.get( "foo" );
459
460
int foo = glob.find( "foo" );
460
- CharacterVector names = glob.ls()
461
+ CharacterVector names = glob.ls(TRUE )
461
462
bool b = glob.exists( "foo" );
462
463
glob.remove( "foo" );
463
464
0 commit comments