> setClass("interval",representation(min="numeric",max="numeric")) [1] "interval" > getClass("interval") Class "interval" [in ".GlobalEnv"] Slots: Name: min max Class: numeric numeric > a <- new("interval",min=2,max=3) > a An object of class "interval" Slot "min": [1] 2 Slot "max": [1] 3 > x <- vector("list",2) > x [[1]] NULL [[2]] NULL > T <- data.frame(u=x,v=x) > T data frame with 0 columns and 0 rows > # 17. december 2011 # http://rwiki.sciviews.org/doku.php?id=tips:data-frames:list_in_data.frame > df <- data.frame (normal.column = "a", + the.list = I(list ("1st.row" = list ("x" = 8, "unit" = "mm"), + "2nd.row" = "blabla") )) > df normal.column the.list 1st.row a 8, mm 2nd.row a blabla > > T <- data.frame(u = c(7,4), v = I(list( "prva"=a, "druga"=a ))) > T Error in as.character.default(<S4 object of class "interval">) : no method for coercing this S4 class to a vector > A <- c(4,5,6); B <- c(7,1,3) > T <- data.frame(u = c(7,4), v = I(list(A,B))) > T u v 1 7 4, 5, 6 2 4 7, 1, 3 > T[2,2] [[1]] [1] 7 1 3 > Z <- data.frame(u = c(7,4), v = I(list( "prva"=a, "druga"=a ))) > Z[2,1] [1] 4 > Z[2,2] $druga An object of class "interval" Slot "min": [1] 2 Slot "max": [1] 3 > b <- new("interval",min=5,max=9) > Z[2,2] <- b > Z[2,2] $druga An object of class "interval" Slot "min": [1] 5 Slot "max": [1] 9 > dim(Z) [1] 2 2