bogdan romocea wrote:
> A simple function will do what you want, customize this as needed:
> lprint <- function(lst,prefix)
> {
> for (i in 1:length(lst)) {
> cat(paste(prefix,"$",names(lst)[i],sep=""),"\n")
> print(lst[[i]])
> cat("\n")
> }
> }
> P <- list(A="a",B="b")
> lprint(P,"Prefix")
With
print(list(A="a",B="b"))
it displays
$A
[1] "a"
$B
[1] "b"
I would like to add a common prefix to all the list tags after the $.
Pasting the prefix to the "names" does not work (appear after the $).
For example if the prefix would be "P", it should display:
P$A
[1] "a"
P$B
[1] "b"
I
Prof Brian Ripley wrote:
> On Mon, 10 Jul 2006, Laurent Deniau wrote:
>
>> I have a data frame with named columns and I would like to know if it is
>> possible to retrieve a column name once selected:
>
>
> Not really. df$col1 is a new object which does not know whe
I have a data frame with named columns and I would like to know if it is
possible to retrieve a column name once selected:
print(colnames(df)) # assumes to print "col1" "col2"
print.name(df$col1) # would like to print "col1"
print.name(df$col2) # would like to print "col2"
So what the print.n