Re: [R] Feed list of vectors to vioplot()?

From: Johannes Graumann <johannes_graumann_at_web.de>
Date: Wed, 23 Apr 2008 22:07:29 +0200

Off-list it was pointed out to me that the trivial solution to this would look like this:
myfunction2 <- function(x, ...){
  mylist <- list(x, ...)
  # plenty of "lapply" stuff
  do.call(vioplot,mylist)
}

Thanks for everybodies patience,

Joh

Johannes Graumann wrote:

> <posted & mailed>
>
> Thanks for the very appropriate scolding.
>
> Here's my example (based on "?vioplot"):
> mu<-2
> si<-0.6
> bimodal<-c(rnorm(1000,-mu,si),rnorm(1000,mu,si))
> uniform<-runif(2000,-4,4)
> normal<-rnorm(2000,0,3)
> # Working just fine
> myfunction1 <- function(x, ...){vioplot(x,...)}
> myfunction1(bimodal,uniform,normal)
> # What I (believe to) need
> myfunction2 <- function(x, ...){
> mylist <- list(x, ...)
> # plenty of "lapply" stuff
> vioplot(mylist)
> }
> myfunction2(bimodal,uniform,normal)
> --> Error in min(data) : invalid 'type' (list) of argument
>
> I'm at a loss on how to disentangle "mylist" - unlist just gives me one
> big vector back rather than the 3 I want to have back ...
>
> Thanks for your patience, Joh
>
> jim holtman wrote:
>

>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html and provide commented,
>> minimal, self-contained, reproducible code.
>> 
>> It is hard to provide a solution if we do not understand the problem
>> to be solved.  Sample data would be helpful along with an
>> understanding of what you would expect for output.
>> 
>> On Wed, Apr 23, 2008 at 10:11 AM, Johannes Graumann
>> <johannes_graumann_at_web.de> wrote:
>>>
>>> Johannes Graumann wrote:
>>>
>>> > Hi,
>>> >
>>> > I have a list of vectors and am trying to coerce them into something
>>> > that vioplot will take as groups of data to be plotted independently.
>>> > Can someone nudge me into the right direction?
>>> >
>>> > Thanks, Joh
>>> >
>>> > ______________________________________________
>>> > R-help_at_r-project.org mailing list
>>> > https://stat.ethz.ch/mailman/listinfo/r-help
>>> > PLEASE do read the posting guide
>>> > http://www.R-project.org/posting-guide.html and provide commented,
>>> > minimal, self-contained, reproducible code.
>>>
>>> I'll try less impolite and with more info ...
>>>
>>> I'm writing a function that contains this:
>>>
>>> # function(x, ... , morestuff){}
>>>
>>> which is gathered into a list like so:
>>>
>>> # mylist <- list(x, ...)
>>>
>>> down the line I'd like to output all elements from "mylist" in seperate
>>> vioplots in a single coordiante system. Now I have a hell of a time with
>>> that because vioplot does not accept a list as input but only a
>>> succession of vectors ... how can I now force my list into that form so
>>> a can say
>>>
>>> # vioplot(magicfunction(mylist))
>>>
>>> and get a violin plot for each list-member?
>>>
>>> Thanks for any hint,
>>>
>>>
>>> Joh
>>>
>>> ______________________________________________
>>> R-help_at_r-project.org mailing list
>>> https://stat.ethz.ch/mailman/listinfo/r-help
>>> PLEASE do read the posting guide
>>> http://www.R-project.org/posting-guide.html and provide commented,
>>> minimal, self-contained, reproducible code.
>>>
>> 
>> 
>>

>
> ______________________________________________
> R-help_at_r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html and provide commented,
> minimal, self-contained, reproducible code.


R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Wed 23 Apr 2008 - 20:46:18 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 24 Apr 2008 - 08:30:32 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive