[R] list subsets & passing parameters question.
Thomas W Blackwell
tblackw at umich.edu
Fri Sep 19 15:27:31 CEST 2003
Eryk -
Question 1: Square brackets work, just the same as for
vectors, and return a (smaller or larger) list object.
The new thing with lists, not available (or needed) with
vectors, is double square brackets, which return one list
element as itself, not enclosed in a list.
See help("Subscript").
Question 2: No, I don't think there's a way to pass a
whole string of parameters without some kind of complicated
eval(parse(...)) syntax (which I've never tried to use myself).
I will comment that the REASON I have never tried to use
this is that I am running R inside of emacs, so it's much
easier to edit the buffer and modify and re-run a command
than it would be to figure out some fancy syntactic way of
doing it.
- tom blackwell - u michigan medical school - ann arbor -
On Fri, 19 Sep 2003, Wolski wrote:
> Hi!
>
> Is there a way to get a subset of a list?
> I looking for some function like the function available for arrays and dataframe.
>
> x<-1:10
> x[-c(1,2)] for arrays
>
> or
> x<-data.frame(a=1,b=2)
> subset(x,select=-a)
>
> But one for a list
> x<-list(a=1,a=2)
> subset(x,select=-a)
>
> The second problem i have are that i want to store parmeters to the plot.default function in a list. eg.: pars<-list(xlim=c(0,100),xlab="irrelevant" , ylab="incredible important").
> and call the plot.default function with this list as parameters.
>
> I know that there are the way with eval(parse(text = paste("plot.default",........
>
> Is there a different one?
>
> Eryk
>
> Dipl. bio-chem. Eryk Witold Wolski @ MPI-MG Dep. Vertebrate Genomics
> Ihnestrasse 73 14195 Berlin 'v'
> tel: 0049-30-84131285 / \
> mail: wolski at molgen.mpg.de ---W-W----
More information about the R-help
mailing list