(no subject)
Some functions create objects for which extractor functions are written to pull out some partial result. I wish to extract partial results from functions without extractor functions: for example, to pass a vector of results to another function.
There isn't a general solution to this problem - it's like saying "I'd like to remove a part from my car engine that doesn't require a special tool. How do I do this?"
Specifically, how would I extract just the contingency table from ftable.
The command str() is your friend for finding how in particular to approach a problem. See ?str, then try:
data(Titanic) zz <- ftable(Titanic) str(zz)
ftable [1:16, 1:2] 0 118 0 4 0 154 0 13 35 387 ... - attr(*, "row.vars")=List of 3 ..$ Class: chr [1:4] "1st" "2nd" "3rd" "Crew" ..$ Sex : chr [1:2] "Male" "Female" ..$ Age : chr [1:2] "Child" "Adult" - attr(*, "col.vars")=List of 1 ..$ Survived: chr [1:2] "No" "Yes" - attr(*, "class")= chr "ftable" This tells you that the ftable object is a matrix-like structure: [1:16, 1:2] with row and column name attributes. To strip the attributes, I'd coerce to a matrix (in this case).
matrix(zz,ncol=ncol(zz))
I'm new at programming in R.
...
Even after looking at V&R S Programming I don't see a general approach.
Get V&R "Modern Applied Statistics with S". It's more what you need to learn R/S. "S Programming" is for when you start seriously programming (as opposed to using) R/S. It's not a beginning book at all. Hope that helps Jason