# Why don't the comments appear in the function?

7 messages
Open this post in threaded view
|

## Why don't the comments appear in the function?

 I have made a list in which each element is a function.   If I print individual elements of the list, then the function code is shown along with embedded comments.  However, if I print the list or sublist, then the function code is shown without comments.   Why (and how) are the comments hidden? >flist[[3]] function(y,brackets,rates){         # Calculates before-tax income required to realized value y         ints<-c(0,cumsum(diff(brackets)*rates[1:(length(rates)-1)]))-brackets*rates         x<-(y+ints)/(1-rates)         x[sum(x>brackets)] } >flist[3] \$btv function (y, brackets, rates) {     ints <- c(0, cumsum(diff(brackets) * rates[1:(length(rates) -         1)])) - brackets * rates     x <- (y + ints)/(1 - rates)     x[sum(x > brackets)] } I am running R 3.3.2 on Mac OS X  10.10.5 Mik Bickis ______________________________________________ [hidden email] mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code.
Open this post in threaded view
|

## Re: Why don't the comments appear in the function?

 I do not see this behavior. f <- function(x){    ## a comment    2 } g <- list(a =2, fun =f) > g \$a [1] 2 \$fun function(x){    ## a comment    2 } > g[[2]] function(x){    ## a comment    2 } > g[2] \$fun function(x){    ## a comment    2 } Cheers, Bert Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) On Mon, Nov 25, 2019 at 7:03 AM <[hidden email]> wrote: > I have made a list in which each element is a function.   If I print > individual elements of the list, then the function code is shown along > with embedded comments.  However, if I print the list or sublist, then the > function code is shown without comments.   Why (and how) are the comments > hidden? > > >flist[[3]] > function(y,brackets,rates){ >         # Calculates before-tax income required to realized value y > > ints<-c(0,cumsum(diff(brackets)*rates[1:(length(rates)-1)]))-brackets*rates >         x<-(y+ints)/(1-rates) >         x[sum(x>brackets)] > } > > > >flist[3] > \$btv > function (y, brackets, rates) > { >     ints <- c(0, cumsum(diff(brackets) * rates[1:(length(rates) - >         1)])) - brackets * rates >     x <- (y + ints)/(1 - rates) >     x[sum(x > brackets)] > } > > I am running R 3.3.2 on Mac OS X  10.10.5 > > Mik Bickis > > ______________________________________________ > [hidden email] mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help> PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html> and provide commented, minimal, self-contained, reproducible code. >         [[alternative HTML version deleted]] ______________________________________________ [hidden email] mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code.
Open this post in threaded view
|

## Re: Why don't the comments appear in the function?

 Different version of R perhaps?   Or is there something in my environment or "preferences" that is different? Here's what I get with your example. >  f <- function(x){ +     ## a comment +     2 +  } > g <- list(a =2, fun =f) > g \$a [1] 2 \$fun function (x) {     2 } > g[[2]] function(x){     ## a comment     2  } > g[1] \$a [1] 2 Mik > I do not see this behavior. > > f <- function(x){ >    ## a comment >    2 > } > > g <- list(a =2, fun =f) > >> g > \$a > [1] 2 > > \$fun > function(x){ >    ## a comment >    2 > } > >> g[[2]] > function(x){ >    ## a comment >    2 > } >> g[2] > \$fun > function(x){ >    ## a comment >    2 > } > > Cheers, > Bert > > Bert Gunter > > "The trouble with having an open mind is that people keep coming along and > sticking things into it." > -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) > > > On Mon, Nov 25, 2019 at 7:03 AM > <[hidden email]> wrote: > I have made a list in which each element is a function.   If I print > individual elements of the list, then the function code is shown along > with embedded comments.  However, if I print the list or sublist, then the > function code is shown without comments.   Why (and how) are the comments > hidden? > >>flist[[3]] > function(y,brackets,rates){ >         # Calculates before-tax income required to realized value y >         ints<-c(0,cumsum(diff(brackets)*rates[1:(length(rates)-1)]))-brackets*rates >         x<-(y+ints)/(1-rates) >         x[sum(x>brackets)] > } > > >>flist[3] > \$btv > function (y, brackets, rates) > { >     ints <- c(0, cumsum(diff(brackets) * rates[1:(length(rates) - >         1)])) - brackets * rates >     x <- (y + ints)/(1 - rates) >     x[sum(x > brackets)] > } > > I am running R 3.3.2 on Mac OS X  10.10.5 > > Mik Bickis > > ______________________________________________ > [hidden email] mailing list -- To > UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help> PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html> and provide commented, minimal, self-contained, reproducible code. > ______________________________________________ [hidden email] mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code.
Open this post in threaded view
|

## Re: Why don't the comments appear in the function?

Open this post in threaded view
|