For some packages I can see special type of objects. For example I am getting following message when I try to print a dataset from a package.
multitrait
This is an object of class "cross".
It is too complex to print, so we provide just this summary.
RI strains via selfing
No. individuals: 162
......................and other summary information
is (multitrait)
[1] "riself"
I wonder how we can created such object. Are they special lists of dataframe, matrix of vector.
X <- c("A", "B", "C")
Y <- data.frame (A = 1:10, B = 21:30, C = 31:40)
myeq <- c("Y ~ X1 + Y1")
K <- 100
A = 1:20
B = B= 21:40
J <- as.matrix(A,B )
myl1 <- list(J, K)
Now my complex object:
mycomplexobject <- list(X, Y, myeq, K, J, myl1)
mycomplexobject
str(mycomplexobject)
List of 6
$ : chr [1:3] "A" "B" "C"
$ :'data.frame': 10 obs. of 3 variables:
..$ A: int [1:10] 1 2 3 4 5 6 7 8 9 10
..$ B: int [1:10] 21 22 23 24 25 26 27 28 29 30
..$ C: int [1:10] 31 32 33 34 35 36 37 38 39 40
$ : chr "Y ~ X1 + Y1"
$ : num 100
$ : int [1:20, 1] 1 2 3 4 5 6 7 8 9 10 ...
$ :List of 2
..$ : int [1:20, 1] 1 2 3 4 5 6 7 8 9 10 ...
..$ : num 100
is(mycomplexobject)
[1] "list" "vector"
Is there way to make special object and prevent printing whole list instead message like “it is complex to print” and provide summary instead ?
Just set the
classof your object and provide aprintmethod.