/
2manipulate-packageIndex12 2manipulate-packageIndex12

2manipulate-packageIndex12 - PDF document

marina-yarberry
marina-yarberry . @marina-yarberry
Follow
349 views
Uploaded On 2015-08-30

2manipulate-packageIndex12 - PPT Presentation

manipulatepackageInteractivePlotsforRStudio DescriptionInteractiveplottingfunctionsforusewithinRStudioDetailsThemanipulatefunctionacceptsaplottingexpressionandasetofcontrolsegsliderpickercheckb ID: 118925

manipulate-packageInteractivePlotsforRStudio DescriptionInteractiveplottingfunctionsforusewithinRStudio.DetailsThemanipulatefunctionacceptsaplottingexpressionandasetofcontrols(e.g.slider picker checkb

Share:

Link:

Embed:

Download Presentation from below link

Download Pdf The PPT/PDF document "2manipulate-packageIndex12" is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.


Presentation Transcript

2manipulate-packageIndex12 manipulate-packageInteractivePlotsforRStudio DescriptionInteractiveplottingfunctionsforusewithinRStudio.DetailsThemanipulatefunctionacceptsaplottingexpressionandasetofcontrols(e.g.slider,picker,checkbox,orbutton)whichareusedtodynamicallychangevalueswithintheexpression.Whenavalueischangedusingitscorrespondingcontroltheexpressionisautomaticallyre-executedandtheplotisredrawn.Forexample,tocreateaplotthatenablesmanipulationofaparameterusingaslidercontrolyoucouldusesyntaxlikethis:manipulate(plot(1:x),x=slider(1,10))Afterthiscodeisexecutedtheplotisdrawnusinganinitialvalueof1forx.Amanipulatorpanelisalsoopenedadjacenttotheplotwhichcontainsaslidercontrolusedtochangethevalueofxfrom1to10.Examples##Notrun:##Createaplotwithamanipulatormanipulate(plot(1:x),x=slider(5,10))##Usingmorethanoneslidermanipulate(plot(cars,xlim=c(x.min,x.max)),x.min=slider(0,15),x.max=slider(15,30))##Filteringdatawithapickermanipulate(barplot(as.matrix(longley[,factor]),beside=TRUE,main=factor),factor=picker("GNP","Unemployed","Employed"))##Createapickerwithlabelsmanipulate(plot(pressure,type=type),type=picker("points"="p","line"="l","step"="s"))##Toggleboxplotoutlierdisplayusingcheckboxmanipulate(boxplot(Freq~Class,data=Titanic,outline=outline), 4checkbox},bins=slider(1,20,step=1,initial=5,label="Bins"),resetSeed=button("ResetSeed"))##End(Notrun) checkboxCreateacheckboxcontrol DescriptionCreateacheckboxcontroltoenablemanipulationoflogicalplotvariables.Usagecheckbox(initial=FALSE,label=NULL)ArgumentsinitialInitialvalueforcheckbox.Mustbelogical(defaultstoFALSE).labelDisplaylabelforcheckbox.Defaultstothevariablenameifnotspecied.ValueAnobjectofclass"manipulator.checkbox"whichcanbepassedtothemanipulatefunction.SeeAlsomanipulate,slider,picker,buttonExamples##Notrun:##Usingcheckboxesforbooleanparametersmanipulate(plot(cars,axes=axes,ann=label),axes=checkbox(TRUE,"DrawAxes"),label=checkbox(FALSE,"DrawLabels"))##Toggleboxplotoutlierdisplayusingcheckboxmanipulate(boxplot(Freq~Class,data=Titanic,outline=outline),outline=checkbox(FALSE,"Showoutliers"))##End(Notrun) ManipulatorCustomState7axes=checkbox(TRUE,"DrawAxes"),label=checkbox(FALSE,"DrawLabels"))##End(Notrun) ManipulatorCustomStateModifymanipulatorstate DescriptionThesefunctionsallowthestorageofcustomstatevariablesacrossmultipleevaluationsofmanipula-torexpressions.Thesefunctionsareusefulifthemanipulateexpressionisacustomfunction(ratherthanahighlevelplottingfunctionlikeplot)whichrequiresreadingandwritingofpersistentvalues.UsagemanipulatorSetState(name,value)manipulatorGetState(name)ArgumentsnameAchraracterstringholdingastatevariablename.valueAnobjectholdingastatevalue.ValuemanipulatorGetStatereturnsacustomstatevaluewhichwaspreviouslysetbymanipulatorSetState(orNULLifthespeciednameisnotfound).SeeAlsomanipulateExamples##Notrun:##setcustomstatevariablemanipulatorSetState("last",x)##getcustomstatevariablelastmanipulatorGetState("last")if(!is.null(last)){#dosomethinginteresting}##End(Notrun) picker9DescriptionCreateapickercontroltoenablemanipulationofplotvariablesbasedonasetofxedchoices.Usagepicker(...,initial=NULL,label=NULL)Arguments...Argumentscontainingobjectstobepresentedaschoicesforthepicker(oralistcontainingthechoices).Ifanelementisnamedthenthenameisusedtodisplayitwithinthepicker.Ifanelementisnotnamedthenitisdisplayedwithinthepickerusingas.character.initialInitialvalueforpicker.Valuemustbepresentinthelistofchoicesspecied.Ifnotspecieddefaultstotherstchoice.labelDisplaylabelforpicker.Defaultstothevariablenameifnotspecied.ValueAnobjectofclass"manipulator.picker"whichcanbepassedtothemanipulatefunction.SeeAlsomanipulate,slider,checkbox,buttonExamples##Notrun:##Filteringdatawithapickermanipulate(barplot(as.matrix(longley[,factor]),beside=TRUE,main=factor),factor=picker("GNP","Unemployed","Employed"))##Createapickerwithlabelsmanipulate(plot(pressure,type=type),type=picker("points"="p","line"="l","step"="s"))##Pickerwithgroupsmanipulate(barplot(as.matrix(mtcars[group,"mpg"]),beside=TRUE),group=picker("Group1"=1:11,"Group2"=12:22,"Group3"=23:32))##Histogramw/pickertoselecttyperequire(lattice)require(stats) slider11Examples##Notrun:##Createaplotwithaslidermanipulate(plot(1:x),x=slider(5,10))##Usemultipleslidersmanipulate(plot(cars,xlim=c(x.min,x.max)),x.min=slider(0,15),x.max=slider(15,30))##Specifyacustominitialvalueforaslidermanipulate(barplot(1:x),x=slider(5,25,initial=10))##Specifyacustomlabelforaslidermanipulate(barplot(1:x),x=slider(5,25,label="Limit"))##Specifyastepvalueforaslidermanipulate(barplot(1:x),x=slider(5,25,step=5))##End(Notrun)

Related Contents


Next Show more