<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>C L Snyder</title>
	<atom:link href="http://www.clsnyder.com/WordPress/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.clsnyder.com/WordPress</link>
	<description>Kaizen with Sprezzatura</description>
	<lastBuildDate>Sun, 20 May 2012 10:51:59 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>R statistics</title>
		<link>http://www.clsnyder.com/WordPress/2012/04/06/r-statistics/</link>
		<comments>http://www.clsnyder.com/WordPress/2012/04/06/r-statistics/#comments</comments>
		<pubDate>Fri, 06 Apr 2012 22:15:17 +0000</pubDate>
		<dc:creator>clsnyder</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[R Statistics]]></category>

		<guid isPermaLink="false">http://www.clsnyder.com/WordPress/?p=22396</guid>
		<description><![CDATA[R statistics &#8211; basic data analysis with automation To read in excel files library ( gdata ) # Note the forward slash on windows # Set the working directory setwd(&#8220;C:/Documents and Settings/csnyder/Desktop/My Dropbox/Projects/NEC/Data/&#8221;) # Check it (WD]]></description>
			<content:encoded><![CDATA[<p>R statistics &#8211; basic data analysis with automation</p>
<p>To read in excel files<br />
	<code>library ( gdata )</code><br />
	# Note the forward slash on windows<br />
	# Set the working directory<br />
	setwd(&#8220;C:/Documents and Settings/csnyder/Desktop/My Dropbox/Projects/NEC/Data/&#8221;)<br />
	# Check it<br />
	(WD <- getwd())<br />
	#mdat <- read . xls ( &#8220;C:/Documents and Settings/csnyder/Desktop/My Dropbox/Projects/NEC/Data/yourfile.xls&#8221;)<br />
	# mdat <- read . xls ( &#8220;yourfile.xls&#8221;)<br />
	# Attach it if you wish<br />
	attach(mdat)</p>
<p>Set some identifiers<br />
	# mdat <- &#8220;my_data_frame&#8221; # If not already labeled appropriately<br />
	# miv <- &#8220;my_independent_variable&#8221; # This is the focus of your study<br />
	# This (below) does not work!<br />
	miv <-  names(Term)</p>
<p>	# What are the continuous variables?<br />
	# Create a subset dataframe with only these variables and the independent variable<br />
	mdat_continV <- subset ( mdat [ , c ( "Term" , "BWt" , "EGA" , "AgeatOp" , "AgeFirstFed" , "DaysatDx" , "LOS" , "Apgar1" , 'Apgar5' )])<br />
	View ( mdat_continV ) </p>
<p>	# Only the complete cases (no NA&#8217;s anywhere) &#8211; may skip this<br />
	# mdat_continV <-mdat_continV[complete.cases(mdat_continV),] </p>
<p>Create some functions &#8211;  T-test<br />
	# Create a ttest function:<br />
	library ( plyr )<br />
	tt <- function ( x ) t . test ( x ~ Term , data = mdat_continV)<br />
	# One test is easy &#8211; supply the parameter to the function:  tt(mdat$EGA)<br />
	# Use the colwise function in plyr<br />
	# colwise(function)(dataframe[c("col1", "col2")])<br />
	# Now, get the col names, skipping the first 2:<br />
	# names(mdat_continV)[-(1:3)]<br />
	colwise ( tt )( mdat_continV [ names ( mdat_continV )[-( 1 : 3 )]])<br />
	# The &#8216;code&#8217; to read these results is<br />
	# 1 &#8211; t value<br />
	# 2 &#8211; degrees of freedom<br />
	# 3 &#8211;  p value<br />
	# 4 &#8211; 95% confidence interval<br />
	# 5 &#8211; sample means compared (grp 0 and grp 1)<br />
	# 6 &#8211; ?<br />
	# 7 &#8211; 2-sided or 1-sided T test<br />
	# 9 &#8211; dependent  variable by independent variable</p>
<p>	# Here is another method to do apply t.test to several columns (cols 8 and 9 are the EGA and Bwt:<br />
	sapply(mdat[,8:9], FUN=tt) # returns a matrix<br />
	# The same function with this nomenclature can be used:<br />
	sapply(mdat[c("BWt", "EGA")], FUN=tt) # returns a matrix</p>
<p>Create some functions &#8211; Cross-tab and chi squared</p>
<p>	# Function for chisq test:<br />
	csq_test <- function (x){<br />
	  mresult <- xtabs(~Term+x, data = mdat, sparse = FALSE, exclude = c(NA, NaN), drop.unused.levels = FALSE)<br />
	  print(mresult)<br />
	  summary(mresult)<br />
	}<br />
	csq_test(Survived)</p>
<p>Create some graphics &#8211; Plot one continuous variable against another </p>
<p>	# Define the plotting function<br />
	library (plyr)<br />
	Library(ggplot2)<br />
	# Form is: my_plot_fxn <- function(.col) ggplot(my_df) +<br />
	# geom_point(aes_string(x=&#8221;column_name_of_independ_variable&#8221;, y=.col))<br />
	plotone <- function ( .col ) ggplot ( mdat ) +<br />
	geom_point ( aes_string ( x = &#8220;DaysatDx&#8221; , y = .col ))<br />
	# Call the function with a list of the names of the<br />
	# columns you want<br />
	l.ply ( names ( mdat )[ c ( 8:9 , 11 )] , plotone ,  .print = T ) </p>
<p>Create some graphics &#8211; Make a series of boxplots</p>
<p>	library ( reshape2 )<br />
	graphcls <- function (mdat_continV) {<br />
	  mdat_continV.m <- melt (mdat_continV , id.vars = &#8220;Term&#8221; )<br />
	  ggplot (mdat_continV.m , aes ( x = factor ( Term ) , y = value , colour = variable )) +<br />
	    geom_boxplot () +<br />
	    ylab ( &#8220;Total Differences&#8221; )<br />
	}<br />
	# call the function with col 1 (term=your independent factor variable) and whatever col you need<br />
	# ignore the NAs by taking only the subset without them:<br />
	# mmdd <- subset(mdat_continV, subset= (Term <5 &#038; DaysatDx < 90))<br />
	graphcls ( mdat_continV [ c ( 1 , 3 )])<br />
	graphcls ( mdat_continV [ c ( 1 , 7 )])<br />
	graphcls ( mdat_continV [ c ( 1 , 6 )]) </p>
<p>Create some graphics &#8211; Make a series of boxplots (alternative)</p>
<p>	library ( ggplot2 )<br />
	# This plot will work, but the NA&#8217;s are unsightly<br />
	# qplot ( factor ( Term ) , EGA , data = mdat , geom = &#8220;boxplot&#8221; )<br />
	# Eliminate the NA&#8217;s<br />
	# qplot ( factor ( Term ) , EGA , data = subset ( mdat , ! is.na ( EGA )) , geom = &#8220;boxplot&#8221; )<br />
	# Better: Same Plot but more fine control; colour outliers and label the axis<br />
	p <- ggplot ( subset ( mdat , ! is na ( EGA )) , aes ( factor ( Term ) , BWt ))<br />
	p + geom_boxplot ( outlie .colour = &#8220;red&#8221; , outlier.size = 3 ) + xlab ( &#8220;Term&#8221; )<br />
	# It is possible to create a plot inside a function, and simply call the function with the appropriate variable. Here &#8220;Term&#8221; is the<br />
	# independent binary variable<br />
	# Remove any NA&#8217;s in the independent variable:<br />
	mdat <- subset ( mdat , ! is.na ( Term )<br />
	mplot <- function ( x ) {<br />
	qplot ( factor ( Term ) , x , data = mdat , geom = &#8220;boxplot&#8221; )<br />
	}<br />
	mplot ( mdat$LOS )</p>
<p>Cleaning up imported data</p>
<p>	# Any empty rows after the import?<br />
	# What are they? (in form c(empty_row_start:empty_row_end)<br />
	# Delete empty rows at the end<br />
	mdat <- mdat [- c( 492:495 ) , ] </p>
<p>	# What are the column names?<br />
	names ( mdat )<br />
	# What are the column names, skipping the first 3 columns?<br />
	names ( yourdf )[-( 1:3 )] </p>
<p>	# What if the column names need to be changed? This changes the name of col 2<br />
	colnames ( yourdf )[2] <- &#8220;newname&#8221; </p>
<p>	# How many different values are in the rows of a specific column?<br />
	table ( mdat$YearDx )<br />
	# or, another way:<br />
	xtabs (~ YearDx , data = mdat ) </p>
<p>	# To do a more extensive cross-tabulation:<br />
	xtabs (~ YearDx + EGA + Survived , data = mdat ) </p>
<p>	# How many NA values are  there in each column?<br />
	library ( plyr )<br />
	nmissing <- function ( x ) sum ( is.na ( x ))<br />
	table ( colwise ( nmissing )( mdat ))<br />
	# How do we deal with the NA values?<br />
	# Format is newdf <- olddf[complete.cases(olddf[, c("col_name1", "col_name2")]),]<br />
	# for NAs in a single column: newdf<-olddf[complete.cases(olddf[,"co_name1"]),]<br />
	mdat1 <- mdat [ complete.cases ( mdat [ , c( "Term" , "BWt" , "EGA" )]) , ] </p>
<p>	# Bad data &#8211; we find there is an &#8220;F&#8221; instead of a &#8220;0&#8243; for gender:<br />
	mdat $ Sex [ mdat $ Sex == "F" ] <- 0 </p>
<p>	# Ignore the rows with NA for Term:<br />
	mdat <- subset ( mdat , ! is.na ( Term )) </p>
<p>Reviewing summary variables</p>
<p>	# To find the mean of the numerical columns, grouped by whether or not they are M/F or another binary variable<br />
	ddply ( mdat , .(Term) , colwise ( mean))<br />
	# Suppose you want to test various numerical (continuous) columns of data based on whether or not the baby is Term (0,1):<br />
	# This can be done with plyr, using colwise:<br />
	# Now, apply it to many columns with the colwise function<br />
	colwise ( tt )( mdat [ c ( "BWt" , "EGA" )])<br />
	# This is the best way to do it<br />
	sapply ( mdat [ , 8 : 9 ] , FUN = summary ) # returns a matrix </p>
<p>	# What was the mean birthweight for term vs non term babies?<br />
	ddply ( mdat , &#8220;Term&#8221; , function ( mdat ) mean ( mdat$BWt , na.rm = T ))<br />
	# What were the number of survivors for term vs non term babies?<br />
	ddply ( mdat , &#8220;Term&#8221; , function ( mdat ) sum ( mdat$Survived , na.rm = T )) </p>
<p>	library ( reshape2 )<br />
	# This will make 3 columns &#8211; the name of the two identifiers (Term and EGA), and the measured result (EGA)<br />
	melt ( mdat , &#8220;Term&#8221; , c ( &#8220;EGA&#8221; ) , na . rm = T ) </p>
<p>	# How many term infants versus non term?<br />
	myx <- arrange ( count ( mdat , &#8220;Term&#8221; ) , desc ( freq ))<br />
	myx </p>
<p>	# What is the mean and sd for various values with term or non term infants?<br />
	aggregate ( EGA ~ Term , data = mdat , FUN = function ( x ) c ( M = mean ( x ) , SD = sd ( x ))) </p>
<p>General</p>
<p>	# What example data is available?<br />
	data () </p>
<p>	# Eliminate any rows with missing or NA data in the col of choice:<br />
	mdat2<-mdat[complete.cases(mdat1[,"BreastFed"]),]<br />
	View(mdat2)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.clsnyder.com/WordPress/2012/04/06/r-statistics/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Protected: Left Upper Lobectomy Tutorial</title>
		<link>http://www.clsnyder.com/WordPress/2012/03/28/left-upper-lobectomy-tutorial/</link>
		<comments>http://www.clsnyder.com/WordPress/2012/03/28/left-upper-lobectomy-tutorial/#comments</comments>
		<pubDate>Wed, 28 Mar 2012 21:01:05 +0000</pubDate>
		<dc:creator>clsnyder</dc:creator>
				<category><![CDATA[Pediatric Surgery]]></category>
		<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://www.clsnyder.com/WordPress/?p=22359</guid>
		<description><![CDATA[There is no excerpt because this is a protected post.]]></description>
			<content:encoded><![CDATA[<form action="http://www.clsnyder.com/WordPress/wp-pass.php" method="post">
<p>This post is password protected. To view it please enter your password below:</p>
<p><label for="pwbox-22359">Password:<br />
<input name="post_password" id="pwbox-22359" type="password" size="20" /></label><br />
<input type="submit" name="Submit" value="Submit" /></p></form>
]]></content:encoded>
			<wfw:commentRss>http://www.clsnyder.com/WordPress/2012/03/28/left-upper-lobectomy-tutorial/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Weight loss calculator &#8211; realistic version</title>
		<link>http://www.clsnyder.com/WordPress/2012/02/20/weight-loss-calculator-realistic-version/</link>
		<comments>http://www.clsnyder.com/WordPress/2012/02/20/weight-loss-calculator-realistic-version/#comments</comments>
		<pubDate>Mon, 20 Feb 2012 16:25:45 +0000</pubDate>
		<dc:creator>clsnyder</dc:creator>
				<category><![CDATA[Miscellaneous]]></category>

		<guid isPermaLink="false">http://www.clsnyder.com/WordPress/?p=22011</guid>
		<description><![CDATA[From http://bwsimulator.niddk.nih.gov/]]></description>
			<content:encoded><![CDATA[<p>From http://bwsimulator.niddk.nih.gov/</p>
<p><img src="http://www.clsnyder.com/WordPress/wp-content/uploads/2012/02/Screen-Shot-2012-02-20-at-10.23.26-AM.png"></p>
]]></content:encoded>
			<wfw:commentRss>http://www.clsnyder.com/WordPress/2012/02/20/weight-loss-calculator-realistic-version/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Links from Excel</title>
		<link>http://www.clsnyder.com/WordPress/2012/02/18/links-from-excel/</link>
		<comments>http://www.clsnyder.com/WordPress/2012/02/18/links-from-excel/#comments</comments>
		<pubDate>Sat, 18 Feb 2012 22:45:46 +0000</pubDate>
		<dc:creator>clsnyder</dc:creator>
				<category><![CDATA[Miscellaneous]]></category>

		<guid isPermaLink="false">http://www.clsnyder.com/WordPress/?p=21968</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<p><iframe width="402" height="346" frameborder="0" scrolling="no" src="http://r.office.microsoft.com/r/rlidExcelEmbed?su=3275705230703185395&#038;Fi=SD2D75A48D48F3CDF3!108&#038;ak=t%3d0%26s%3d0%26v%3d!AHNyidkrshGb6c4&#038;kip=1&#038;wdAllowInteractivity=False&#038;wdHideGridlines=True&#038;wdHideHeaders=True&#038;wdDownloadButton=True"></iframe></p>
]]></content:encoded>
			<wfw:commentRss>http://www.clsnyder.com/WordPress/2012/02/18/links-from-excel/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Great Brett Victor Talk</title>
		<link>http://www.clsnyder.com/WordPress/2012/02/15/great-brett-victor-talk/</link>
		<comments>http://www.clsnyder.com/WordPress/2012/02/15/great-brett-victor-talk/#comments</comments>
		<pubDate>Thu, 16 Feb 2012 01:15:49 +0000</pubDate>
		<dc:creator>clsnyder</dc:creator>
				<category><![CDATA[Inspiration]]></category>

		<guid isPermaLink="false">http://www.clsnyder.com/WordPress/?p=21950</guid>
		<description><![CDATA[Bret Victor &#8211; Inventing on Principle from CUSEC on Vimeo.]]></description>
			<content:encoded><![CDATA[<p><iframe src="http://player.vimeo.com/video/36579366?byline=0" width="400" height="225" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>
<p><a href="http://vimeo.com/36579366">Bret Victor &#8211; Inventing on Principle</a> from <a href="http://vimeo.com/cusec">CUSEC</a> on <a href="http://vimeo.com">Vimeo</a>.</p></p>
]]></content:encoded>
			<wfw:commentRss>http://www.clsnyder.com/WordPress/2012/02/15/great-brett-victor-talk/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Concatenate multiple word (or other format) files into another format</title>
		<link>http://www.clsnyder.com/WordPress/2012/02/14/concatenate-multiple-word-or-other-format-files-into-another-format/</link>
		<comments>http://www.clsnyder.com/WordPress/2012/02/14/concatenate-multiple-word-or-other-format-files-into-another-format/#comments</comments>
		<pubDate>Wed, 15 Feb 2012 03:21:41 +0000</pubDate>
		<dc:creator>clsnyder</dc:creator>
				<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://www.clsnyder.com/WordPress/?p=21945</guid>
		<description><![CDATA[Concatenate Here is an easy way to concatenate multiple word (or other format) files into another format &#8211; in this case, text. cd to the directory containing the files Run the following from the command line: textutil -cat txt -title &#8230; <a href="http://www.clsnyder.com/WordPress/2012/02/14/concatenate-multiple-word-or-other-format-files-into-another-format/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<h4 id="concatenate">Concatenate</h4>
<p>Here is an easy way to concatenate multiple word (or other format) files into another format &#8211; in this case, text. </p>
<ol>
<li>
<p>cd to the directory containing the files</p>
</li>
<li>
<p>Run the following from the command line:</p>
</li>
</ol>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">textutil -cat txt -title &quot;Several Files&quot; -output merged.txt *.doc</pre></div></div>

<ol>
<li>
<p>This uses <em>textutil</em> to bring together (cat) all *.doc files in the directory (folder) and output them as merged.text in the same directory</p>
</li>
<li>
<p><a href="http://hints.macworld.com/article.php?story=20050621010532552&amp;lsrc=osxh">Link to textutil</a></p>
</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://www.clsnyder.com/WordPress/2012/02/14/concatenate-multiple-word-or-other-format-files-into-another-format/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Php test</title>
		<link>http://www.clsnyder.com/WordPress/2012/02/14/php-test/</link>
		<comments>http://www.clsnyder.com/WordPress/2012/02/14/php-test/#comments</comments>
		<pubDate>Tue, 14 Feb 2012 23:45:57 +0000</pubDate>
		<dc:creator>clsnyder</dc:creator>
				<category><![CDATA[Miscellaneous]]></category>

		<guid isPermaLink="false">http://www.clsnyder.com/WordPress/?p=21941</guid>
		<description><![CDATA[hi]]></description>
			<content:encoded><![CDATA[<p>hi</p>
]]></content:encoded>
			<wfw:commentRss>http://www.clsnyder.com/WordPress/2012/02/14/php-test/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Pectus Clinic Update</title>
		<link>http://www.clsnyder.com/WordPress/2012/02/14/pectus-clinic-update/</link>
		<comments>http://www.clsnyder.com/WordPress/2012/02/14/pectus-clinic-update/#comments</comments>
		<pubDate>Tue, 14 Feb 2012 21:43:46 +0000</pubDate>
		<dc:creator>clsnyder</dc:creator>
				<category><![CDATA[Pediatric Surgery]]></category>

		<guid isPermaLink="false">http://www.clsnyder.com/WordPress/?p=21931</guid>
		<description><![CDATA[Review of Pectus Center Demographics There were 213 visits, of which 110 were new patient visits. The patients were primarily loco-regional, with a few exceptions: Pectus Referral Map A ‘live’ version of this map can be seen at this link. &#8230; <a href="http://www.clsnyder.com/WordPress/2012/02/14/pectus-clinic-update/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<h3>Review of Pectus Center</h3>
</p>
<h4>Demographics</h4>
<p>There were 213 visits, of which 110 were new patient visits. The patients were primarily loco-regional, with a few exceptions:</p>
<p><a href="http://www.clsnyder.com/WordPress/2012/02/14/pectus-clinic-update/pectusclinic/" rel="attachment wp-att-21933"><img src="http://www.clsnyder.com/WordPress/wp-content/uploads/2012/02/PectusClinic-300x136.png" alt="" title="PectusClinic" width="300" height="136" class="alignleft size-medium wp-image-21933" /></a>
<p>
Pectus Referral Map </p>
<p>A ‘live’ version of this map can be seen at this <a href="http://batchgeo.com/map/2eac267ec58fd416dc6f029c89be0747">link</a>.</p>
<h4>Overview</h4>
<p>The mean age for new patients was 13.1 years; 13.4 for PC (Pectus Carinatum) and 12.8 for PE (Pectus Excavatum).   </p>
<p>The overall M:F ratio was 87:23 (3.7:1). For PC the gender ratio was 2.4:1, and for PE 8:1. </p>
<p>Mean BMI overall was 18.8.  </p>
<p>62 patients were classified as a PC variant, and 36 as PE.   </p>
<p>Mean age at onset/recognition of the deformity was 9.5 years for PC and 1.7 years for PE (overall mean was 6.6 years).   </p>
<p>FH was positive in 9/62 PC patients and 15/36 PE patients.   </p>
<p>Haller index for the PE patients was a mean of 3.6, and the CI (Corrective Index) was 27.4. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.clsnyder.com/WordPress/2012/02/14/pectus-clinic-update/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to get data from an external JSON file &#8211; PHP</title>
		<link>http://www.clsnyder.com/WordPress/2012/02/11/how-to-get-data-from-an-external-json-file-php/</link>
		<comments>http://www.clsnyder.com/WordPress/2012/02/11/how-to-get-data-from-an-external-json-file-php/#comments</comments>
		<pubDate>Sat, 11 Feb 2012 15:36:49 +0000</pubDate>
		<dc:creator>clsnyder</dc:creator>
				<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://www.clsnyder.com/WordPress/?p=21912</guid>
		<description><![CDATA[1 2 3 4 5 6 //assign the file contents to the array myJsonInput $myJsonInput = file_get_contents&#40;&#34;/Path/test.json&#34;&#41;; //Use json_decode to &#34;Take a JSON encoded string and convert it into a PHP variable&#34; $json_arr=json_decode&#40;$myJsonInput,true&#41;; //Create an empty array, $myLinks, to put &#8230; <a href="http://www.clsnyder.com/WordPress/2012/02/11/how-to-get-data-from-an-external-json-file-php/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[
<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">//assign the file contents to the array myJsonInput</span>
<span style="color: #000088;">$myJsonInput</span> <span style="color: #339933;">=</span> <span style="color: #990000;">file_get_contents</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/Path/test.json&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">//Use json_decode to &quot;Take a JSON encoded string and convert it into a PHP variable&quot;</span>
<span style="color: #000088;">$json_arr</span><span style="color: #339933;">=</span><span style="color: #990000;">json_decode</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$myJsonInput</span><span style="color: #339933;">,</span><span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">//Create an empty array, $myLinks, to put the links in (in this example of pinboard bookmarks)</span>
<span style="color: #000088;">$mylinks</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>The test.json file is of the form:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #009900;">&#123;</span><span style="color: #0000ff;">&quot;data&quot;</span><span style="color: #339933;">:</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#123;</span><span style="color: #0000ff;">&quot;description&quot;</span><span style="color: #339933;">:</span> <span style="color: #0000ff;">&quot;blah blah&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;href&quot;</span><span style="color: #339933;">:</span><span style="color: #0000ff;">&quot;http://google.com&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;tags&quot;</span><span style="color: #339933;">:</span><span style="color: #0000ff;">&quot;Search, News&quot;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span><span style="color: #009900;">&#123;</span><span style="color: #0000ff;">&quot;description&quot;</span><span style="color: #339933;">:</span> <span style="color: #0000ff;">&quot;more blah&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;href&quot;</span><span style="color: #339933;">:</span><span style="color: #0000ff;">&quot;http://nyt.com&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;tags&quot;</span><span style="color: #339933;">:</span><span style="color: #0000ff;">&quot;News&quot;</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#125;</span></pre></td></tr></table></div>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">//Now, loop through the array to extract k:v pairs:</span>
<span style="color: #666666; font-style: italic;">//Note that &quot;data&quot; is the name of the container in the json file</span>
<span style="color: #666666; font-style: italic;">//The variable $link is basically a row of data</span>
<span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$json_arr</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'data'</span><span style="color: #009900;">&#93;</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$link</span><span style="color: #009900;">&#41;</span> 
<span style="color: #009900;">&#123;</span>
	<span style="color: #666666; font-style: italic;">//Create an associative array ('hash', 'dictionay') pairing the description with the hyperlink in this case</span>
    <span style="color: #000088;">$mylinks</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$link</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'description'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$link</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'href'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
    <span style="color: #666666; font-style: italic;">//Put the results in a table:</span>
    <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;tr&gt;&lt;td&gt;'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'&lt;a href=&quot;'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$link</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'href'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'&quot;&gt;'</span><span style="color: #339933;">,</span><span style="color: #000088;">$link</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'description'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'&lt;/a&gt;'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'&lt;/td&gt;&lt;td&gt;'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$link</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'tags'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'&lt;/td&gt;&lt;/tr&gt;&lt;p&gt;'</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p><strong>Links</strong><br />
<a href="http://php.net/manual/en/function.json-decode.php" title="json decode" target="_blank">json_decode</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.clsnyder.com/WordPress/2012/02/11/how-to-get-data-from-an-external-json-file-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Twitter Weekly Updates for 2012-01-22</title>
		<link>http://www.clsnyder.com/WordPress/2012/01/22/twitter-weekly-updates-for-2012-01-22/</link>
		<comments>http://www.clsnyder.com/WordPress/2012/01/22/twitter-weekly-updates-for-2012-01-22/#comments</comments>
		<pubDate>Sun, 22 Jan 2012 08:54:00 +0000</pubDate>
		<dc:creator>clsnyder</dc:creator>
				<category><![CDATA[Twitter]]></category>
		<category><![CDATA[Tweet]]></category>

		<guid isPermaLink="false">http://www.clsnyder.com/WordPress/2012/01/22/twitter-weekly-updates-for-2012-01-22/</guid>
		<description><![CDATA[My fitbit #fitstats for 1/14/2012: 5,118 steps and 2.5 miles traveled. http://t.co/HU7SOQmq # My fitbit #fitstats for 1/15/2012: 5,071 steps and 2.5 miles traveled. http://t.co/HU7SOQmq # jQuery UI Bootstrap 0.2 Released: http://t.co/Dkh73TTW # http://t.co/KEkyLSv7 # http://t.co/pnuOkMZw # Filament Group’s Open &#8230; <a href="http://www.clsnyder.com/WordPress/2012/01/22/twitter-weekly-updates-for-2012-01-22/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<ul class="aktt_tweet_digest">
<li>My fitbit #<a href="http://search.twitter.com/search?q=%23fitstats" class="aktt_hashtag">fitstats</a> for 1/14/2012: 5,118 steps and 2.5 miles traveled. <a href="http://t.co/HU7SOQmq" rel="nofollow">http://t.co/HU7SOQmq</a> <a href="http://twitter.com/clsnyder/statuses/158579492040867841" class="aktt_tweet_time">#</a></li>
<li>My fitbit #<a href="http://search.twitter.com/search?q=%23fitstats" class="aktt_hashtag">fitstats</a> for 1/15/2012: 5,071 steps and 2.5 miles traveled. <a href="http://t.co/HU7SOQmq" rel="nofollow">http://t.co/HU7SOQmq</a> <a href="http://twitter.com/clsnyder/statuses/158926770001821696" class="aktt_tweet_time">#</a></li>
<li>jQuery UI Bootstrap 0.2 Released:  <a href="http://t.co/Dkh73TTW" rel="nofollow">http://t.co/Dkh73TTW</a> <a href="http://twitter.com/clsnyder/statuses/159872070052876288" class="aktt_tweet_time">#</a></li>
<li><a href="http://t.co/KEkyLSv7" rel="nofollow">http://t.co/KEkyLSv7</a> <a href="http://twitter.com/clsnyder/statuses/160078903497596929" class="aktt_tweet_time">#</a></li>
<li><a href="http://t.co/pnuOkMZw" rel="nofollow">http://t.co/pnuOkMZw</a> <a href="http://twitter.com/clsnyder/statuses/160190750523539456" class="aktt_tweet_time">#</a></li>
<li>Filament Group’s Open Source Code Repositories:  <a href="http://t.co/wiDFHn31" rel="nofollow">http://t.co/wiDFHn31</a> <a href="http://twitter.com/clsnyder/statuses/160590497038082048" class="aktt_tweet_time">#</a></li>
<li>CSS3: The Multi Column Layout and How it Will Change Web Design <a href="http://t.co/2jaHvXxe" rel="nofollow">http://t.co/2jaHvXxe</a> via @<a href="http://twitter.com/zite" class="aktt_username">zite</a> <a href="http://twitter.com/clsnyder/statuses/160873744829648896" class="aktt_tweet_time">#</a></li>
<li><a href="http://t.co/QSxhz0on" rel="nofollow">http://t.co/QSxhz0on</a> via @<a href="http://twitter.com/zite" class="aktt_username">zite</a> <a href="http://twitter.com/clsnyder/statuses/160874546277265408" class="aktt_tweet_time">#</a></li>
</ul>
<p class="aktt_credit">Powered by <a href="http://alexking.org/projects/wordpress">Twitter Tools</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.clsnyder.com/WordPress/2012/01/22/twitter-weekly-updates-for-2012-01-22/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

