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 analyzeDeathPenaltyOpinions.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+Explore+contents+of+variable+in+dataset%0A%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%0Alibrary%28%22poliscidata%22%29%0A%23+You+need+to+load+the+poliscidata+package+each+time+at+the+start+of+each+session%2Fscript.%0A%23+You+should+also+always+set+a+working+directory%2C+but+this+demo+script+is+running+on+a+remote+server.%0A%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%0A%0A%23+Explore+specific+variable+in+the+NES+dataset%3A+opinions+about+death+penalty.%0A%23+The+deathpen+variable+is+the+370th+variable%2Fcolumn+in+our+NES+dataset%2C+so+it+is+nes%5B%2C370%5D%0A%23+Rather+than+reference+by+column+number%2C+it+is+much+easier+to+reference+it+by+name.%0A%23+To+keep+the+output+simple%2C+we+are+only+viewing+first+20+observations.%0A%23+The+levels%28%29+command+shows+you+all+the+unique+values+of+a+variable.%0Acat%28%22First+20+responses+to+death+penalty+question+in+the+dataset%3A%5Cn%22%29%0Anes%24deathpen%5B1%3A20%5D%0A%0Acat%28%22%5Cn%5CnLevels+of+the+variable+values%3A%5Cn%22%29%0Alevels%28nes%24deathpen%29%0A%0A%23+Describe+national+opinions+about+the+death+penalty+using+table+and+figure.%0A%23+Use+sample+weights+so+the+statistics+are+nationally+representative.%0Acat%28%22%5Cn%5CnFrequency+Distribution+Table%3A%5Cn%22%29%0AfreqC%28nes%24pid_x%2C+nes%24wt%29"></iframe>
<!-- End of analyzeDeathPenaltyOpinions.txt R Demo Code -->