Friday, April 29, 2011

R farts: Get with it.

As a set up for some more complicated environmental manipulations, .GlobalEnv is a pre-defined reference to the global environment (in the R sense).

With is a function which constructs a local environment from a data argument, and lets you evaluate an expression within that environment.  It returns only the value of the evaluated expression. 

The combination of these two lets you construct data frames with derived objects without polluting the global environment with junk temporary variables.  For example:
df <- data.frame( x = runif(100) )
df <- with( data = df, expr = {
   y = 2*x+1
   z = 3*y^2+1
   df <- data.frame(x = x, y = y, z = z )
   return(df)
})
Even better, if you have some variables pre-calculated in the global environment, you can pull them in using the .GlobalEnv reference:

df <- data.frame( x = runif(100) )
df <- with( data = df, expr = {
   y = 2*x+1
   z =.GlobalEnv$oftenUsedFunction(y)
   df <- data.frame(x = x, y = y, z = z )
   return(df)
})
I probably have pages and pages of R scripts which are somewhat repetitive.  Just not repetitive enough to qualify for a function.  I'm still looking for how to organize them better, but this is a start.

Thursday, April 21, 2011

Crackpot Bumps Up NY Times Ratings

NY Times front page online:
Magazine Preview
The Crash and Burn of an Autism Guru
Andrew Wakefield, condemned by the press and the medical establishment, still believes in a link between autism and vaccines.
The man participated in a campaign to inflate the risk of vaccination which has resulted in outbreaks of measles and other preventable diseases around the world.  His conduct while participating in this campaign was outrageous by all of the standards that researchers are supposed to abide by.  The crazy man yelling on the street corner in Berkeley has a much more relevant opinion on autism and vaccines.  The CDC might be an even better place to ask.  You know, people with actual credibility and relevance.

NY Times, please be a little choosier about what gets front page coverage.  Thanks PZ for pointing out the crazy.

Saturday, April 16, 2011

Friday, April 1, 2011

You can't argue with a beautiful voice


"Anger", oh really?

This is a nytimes.com headline:

Afghan Mob Kills 10 Foreign United Nations Workers

KABUL, Afghanistan — The protesters, angered by a Koran burning in Florida on Mar. 20., attacked a U.N. office in Mazar-i-Sharif.
I'm sorry, but this is premeditated mob murder.  This has nothing to do with anger.  They were whipped up by irresponsible religious figures at the mosque and set loose on an poorly guarded compound.  The story states:
The attack began when hundreds of demonstrators, some of them armed, poured out of mosques after Friday Prayer and headed to the headquarters of the United Nations in the northern city of Mazar-i-Sharif.
To imagine that this was provoked by some cracked up Florida pastor's burning of a few Korans is giving these people far too little credit.  Somebody wanted the UN out and they found an excuse.  The ugly thing is that people are so easy to whip into a frenzy.  Maybe the NY Times consider writing headlines that don't just monkey the American prejudice towards Afghanistan as the land of religious insanity?  Pretty please?

Sunday, March 27, 2011

I start all my talks this way.

That's one way to say "we own the place."

Saturday, March 26, 2011

William Cronon and the Open Records Request

This story is being beaten to death everywhere but I think Cronon is in a pretty good position.  He came out to publicly argue that the public records request was legal but against the spirit of the law.  The University's Chancellor has said they would comply with the law, but that they are required to weigh the request versus the academic freedom and student privacy issues.  For the Republican party of Wisconsin it's a fishing expedition gone bad.  One thing that strikes me about it as frustrating is the abuse of language.  For example, take this press release:
For Immediate Release
Contact: Katie McCallum, Communications Director (608) 257-4765
March 25, 2011

In response to Professor William Cronin’s deplorable tactics in seeking to force the Republican Party of Wisconsin to withdraw a routine open records request, Executive Director Mark Jefferson released the following statement:
When did public discourse become a deplorable tactic?  If they're scared of that I'm not sure these people can handle an academic.  Next thing you know he might ask them hard questions, like what's in the constitution.
“Like anyone else who makes an open records request in Wisconsin, the Republican Party of Wisconsin does not have to give a reason for doing so.
Ok.  They don't want to engage in a public discussion until they have some dirt to fling.  Fair enough.
“I have never seen such a concerted effort to intimidate someone from lawfully seeking information about their government.
Let's be honest, the Republican party of Wisconsin is not "someone", and Cronon is not the government.  If they're intimidated by Cronon's firm but gentle statements about his rights and his view of their request, they really need to find a different business.  How can a dominant political party actually get away with playing victim... (!?)
“Further, it is chilling to see that so many members of the media would take up the cause of a professor who seeks to quash a lawful open records request. 
The media report on things.  Horror!  "Chilling" is the word you use when the government, or some other powerful entity destroys people's careers for political purposes.  When someone counters your political fishing expedition by publicizing it on their blog I would not call that "Chilling".  
The Left is far more aggressive in this state than the Right in its use of open records requests, yet these rights do extend beyond the liberal left and members of the media.
You poor baby, the Left and the Media are out to get you.
“Finally, I find it appalling that Professor Cronin seems to have plenty of time to round up reporters from around the nation to push the Republican Party of Wisconsin into explaining its motives behind a lawful open records request,
Does Mark Jefferson realize that just because they have the power to do something doesn't make it an ethical, moral, or even smart course of action?  This worries me.
but has apparently not found time to provide any of the requested information.
Honey, that's what the University legal and IT departments are for.  Cronon needs to take care of other stuff, like writing environmental history.
 “We look forward to the University’s prompt response to our request and hope those who seek to intimidate us from making such requests will reconsider their actions.”
No no no, Mr. Jefferson, you've got it all wrong.  When a professor asks you to explain yourself they're not intimidating you.  They're just asking you to fire a few neurons and make a coherent statement.  It's scary at first, but it'll turn out ok!
Republican Party of Wisconsin | 148 East Johnson St. | Madison, Wisconsin 53703
p: 608.257.4765 | f: 608.257.4141| e: info@wisgop.org
Go Dr.Cronon!  I'm sorry you have to deal with the ugliness of modern politics, but I'm pleased to see that you are striking terror into the hearts of political operatives everywhere with your gentle application of civil discourse.