1

I would like to combine the paste and print functions. This is the best I can do so far:

pp <- function(...) {
  s<-paste0(list(...), sep="")
}
foo<-"foo"
s<-paste0(foo,2,"bar",sep="")
print(s)
s2<-pp(foo,2,"bar")
print(s2) # how to remove spaces and quotes so it is like s?

Edit 1: Got it to work. Thank you:

pp <- function(...) {
  s<-paste0(list(...), collapse='')
  print(s)
}

Edit 2: Seems like this is a similar to an older question of mine. I ended up with:

pn <- function(format="", ...) { # print
    s=sprintf(fmt=format,...)
    cat(s)
}
p <- function(format="", ...) { # priint line
    s=pn(format,...)
    cat(s,"\n")
}
x=1
y=2.3
z="4"
pn("x: %d, y: %f, z: %s",x,y,z)
pn()
pn("end")
p()

which seems to behave like what I am use to.

Ray Tayek
  • 9,841
  • 8
  • 50
  • 90

0 Answers0