Question: Can someone please help me with an easy solution for this problem.
E.g. I have a data frame:

```
data<-data.frame(ID=1,Time=1:10,C="A")

```

I want to repeat all rows in the data frame 30 times with a different "ID" for every replicate. E.g. for `ID<-c("1002","1005","1009"...)`
I have gotten up to:

```
new<-data[rep(seq_len(nrow(data)),times=30), ]

```

but I can't figure out how to change the ID for each replicate. Thanks in advance!

Answer: 
Generally, you should only allow access to the internals of a class when necessary. Placing the function outside the class and restricting its scope--either as a static function or within an anonymous namespace, would be best. That way, you're not polluting the global namespace and you're not allowing unnecessary access to class internals.

For example, you can, in the class's cpp file, have:

```
namespace {
   void bar() {.....}
}

```

and that helper function is then available for your class methods in the same cpp file.

Static functions in the cpp file would also have file scope only, but I find the `static` keyword to be confusing when used that way.
> 
> Bar isn't needed anywhere else other than inside foo.
> 
> 
> 

If so then `bar` should be a private member function of class `A` - there is no need to define `bar` in global namespace.

```
static void bar() { ... }  // not needed

```

instead use:

```
void A::bar() { ... } // <- bar should be private member function

```