There are two ways to do this. The first is to use invisible
as shown by @SenorO. The more complicated way is to create a new class and override the print method. If you create a new class, then every time the object gets printed, only the mean will show up:
print.myclass<-function(x){
cat("Mean is:",x$mean ,"\n")
}
fun <- function(x){
mean <- mean(x)
sd <- sd(x)
ret<-list(sd = sd, mean = mean)
class(ret)<-"myclass"
ret
}
You can still access the values in the class as if it were a list, and if you want the actual underlying list, call unclass:
> x<-fun(rnorm(100))
> x
Mean is: -0.03470428
> x$mean
[1] -0.03470428
> x$sd
[1] 0.9950132
> unclass(x)
$sd
[1] 0.9950132
$mean
[1] -0.03470428