Copy HTML to Run R Code ExampleAbout This Page
This page displays HTML code you can use to embed a live demonstration of the R Statistics Program for political science research.
These live online examples are easy to use and are great for teaching online classes.
<!-- The Start of multipleLineCharts.txt R Demo Code -->
<!-- Copy and paste this snippet into your web page -->
<!-- Modify border, width, and height attributes of the iframe as necessary -->
<iframe border=0 width=100% height=1200 src="https://rdrr.io/snippets/embed/?code=%23++Chapter+5%3A+Making+Controlled+Comparisons%0Alibrary%28poliscidata%29++%23+Loads+R+companion+package+in+session%0A%0A%23+MULTIPLE+LINE+CHARTS%0A%0A%23+First+we+need+to+tranform+DV+and+update+the+gssD%0A%23+Retrieve+level+names+of+variable+to+graph.%0Alevels%28gss%24grass%29+%0A%23+Create+the+indicator+in+the+non-design+dataset%2C+multiplied+times+100.+++++++++++++++++++++++++%0Agss%24grass.legal%3Das.numeric%28gss%24grass%3D%3D%22LEGAL%22%29+%0Agss%24grass.legal%3D100%2Agss%24grass.legal%0A%23+Run+svydesign%2C+updating+gssD+to+include+the+new+indicator.%0AgssD+%3D+svydesign%28id%3D%7E1%2C+data%3Dgss%2C+weights%3D%7Ewtss%29%0A%0A%23+Multiple+line+chart%2C+controlled+comparison%0AiplotC%28%7Egrass.legal%2C%7Eattend3%2Bkids%2CgssD%2Cgrass.legal%7Ekids%2Battend3%2C%0A+++++++xlab%3D%22Relgious+attendance%22%2C%0A+++++++ylab%3D%22Percent+favoring+legalization%22%2C%0A+++++++main%3Dlist%28%22Percentage+Favoring+Marijuana+Legalization%5Cn+by+Religious+%0A+++++++++++++++++Attendance+and+Kids%22%2Ccex%3D1%29%29%0A%0A%23+the+code+below+layers+on+top+of+line+chart+created+above%0Alegend%28%22topright%22%2C+++%23Locates+the+legend+in+the+plotting+area%0A+++++++legend%3Dc%28%22No%22%2C%22Yes%22%29%2C+%23Labels+the+categories%0A+++++++lty%3Dc%281%2C2%29%2C+++++++++++%23Make+sure+the+lin+types+match+the+legend+labels%0A+++++++lwd%3D2%2C+%09%09+++++++++%23Specifies+the+same+line+weight+shown+in+the+graph%0A+++++++title%3D%22Does+R+have+kids%3F%22%2C%0A+++++++inset%3D0.1%2C+%09+++++++++%23Specifies+distance+from+the+plot+borders%0A+++++++bty%3D%22n%22%29++++++++++++++%23Suppresses+the+box+around+the+legend"></iframe>
<!-- End of multipleLineCharts.txt R Demo Code -->