I am trying to feed a list to latex to use with SWeave, and the list comes from contents(). Since it is a list, a caption and label are generated by latex.list - these are not overridden by setting the parameters (such as caption='myCaption', label='myLabel'). I must clearly be missing something - is there no way to set a caption or label with the latex() function when the object is a list? Thanks. - Mike
J Michael Dean <mdean77 <at> comcast.net> writes:> > I am trying to feed a list to latex to use with SWeave, and the list > comes from contents(). Since it is a list, a caption and label are > generated by latex.list - these are not overridden by setting the > parameters (such as caption='myCaption', label='myLabel'). > > I must clearly be missing something - is there no way to set a caption > or label with the latex() function when the object is a list? >library(Hmisc) dfr <- data.frame(x=rnorm(20),y=sample(c('male','female'),20,TRUE)) cnt <- contents(dfr) latex(cnt,label="tab:mytab",caption="This is a caption") Works for me, even if I do not know what the output is good for. Dieter
Thanks, Dieter, for your response shown below. library(Hmisc) dfr <- data.frame(x=rnorm(20),y=sample(c('male','female'),20,TRUE)) cnt <- contents(dfr) latex(cnt,label="tab:mytab",caption="This is a caption") The problem is that I only want to display cnt[1] - I am simply making a table that shows the structure of a dataframe, and I do not want the variable levels from contents. > class(cnt) [1] "contents.data.frame" > class(cnt[1]) [1] "list" When I execute your example, it does work, but if I change it to latex(cnt[1]...) then the caption and label do not work because latex.list() is executed. - Mike