Adventures with Comcast: Part ohnoesnotanotherone in an ongoing series

October 31, 2009 · Posted in R bloggers · Comments Off 
Regular readers of this blog (yes, both of you!) may remember the computer/broadband/ directory that this post appears in as the collection of my Comcastic (yeah right) experiences with my ISP.

But I think this week may top everything. I'll just try to jot down some notes before I forget all the gory details:

  • On Tuesday, I edited one of the internal nvram configuration variables of my trusted wrt54g router in order to add the older daughter's shiny new iPod Touch to the set of 'permitted' MAC addresses. This router, running a custom Linux variant called OpenWRT had essentially not been upgraded since I first installed it, and still required a quick reboots after updating of configuration values. However, that worked fairly flawelessly for 4 1/2 years. Until Tuesday.
  • Upon reboot, I got what appeared to be an invalid network setup from the cable modem. IP and Gateway assigned , but no DNS and no ability to ping anywhere. Crap. So I fiddled with this all evening, including a service call to Comcast but to no avail. When a laptop was directly plugged into the cable modem, it got correct settings albeit on a completely different subnet. So for the next day, we left one machine directly plugged so that my wife could at least telecommute.
  • Somehow it became apparent that waiting insanely long for the router to remain powered-down -- and we're talking five minutes or longer -- helped. So by now we were suspecting the cable modem. I use a standard Motorola SB5101 I once had to buy in a rush because of the Comcastic ones who all of a sudden changed their minimum requirements which meant they would no longer connect to my existing modem. Anyway. So on Wednesday I called Motorola and had a decent service call with them but as I was at work I couldn't follow up with part numbers etc pp. At least I learned that I seem to have two months of the two-year warranty left...
  • So by Wednesday evening I decided to fall back to the really cheap and old Speedstream router I had used before the Linksys wrt54g. That worked, albeit sloooooowly. Wired and wireless ethernet, direct assignment from the cable modem. All well. But did I mention it was sloooow though?
  • Thursday evening was skipped as I was at the Chicago R meeting we organize to complement our R / Finance conferences in the spring.
  • Given that the cable modem worked with the old Speedstream and with directly-connected machines, I decided to finally go for a long overdue update of the wrt54g software. So that happened on Friday, i.e. yesterday. And similar to my previous wrt54g notes, I needed to flash the new software with the tftp protocol and a helper script on a laptop connected to the router. All this took a while as I needed to remember to also send to a ping flood to the router to be able to catch the tftp request, needed to test which of the atftp and tftp binaries worked reliably, and whether the router prefers .bin images over .trx images when using the tftp protocol. But lo and behold this worked, and I configured a shiny new Kamikaze aka 8.09.1 version of OpenWRT. This even connected to the cable modem once I helped with DNS entries. OpenWRT generally rocks, and this new release is a lot nice than the more bare-bones version I used to run.
  • Unfortunately, I had picked the bcrm47xx variant -- the 2.6.* kernel version of the OpenWRT Project's software for my WRT device. And guess what, that one does not include wireless support due to issues with Broadcom drivers and the kernel. Grrr. So once I had that confirmed this morning, I quickly switched to the bcrm-2.4 variant of the same 8.09.1 release. At least now I can flash from within using the mtd command from the commandline.
  • But once up and running with the bcrm-2.4 release, I ran into the same issue we have had with the Motorola cable modem and Comcast behind them. Each time I connect with the wrt54g, I end up on a specific subnet, without DNS and with no ability to connect. The Speedstream still worked. So what to do? Well, MAC Cloning to the rescue. Now the Linksys wrt54g pretends to be the Speedstream, and all, at last, is well again.
  • So after four days of intermittent service, which means that my few web pages, blog, and goodies like CRANberries were invisible, I now have better router software. That could have come a little easier, and I still don't quite know why Comcast decides to no longer service the wrt54g under the MAC address it presented itself with for 4 1/2 years. I have paid thousands of dollars over that time to get broadband access. But this, I don't quite call service. To top it all off, guess who cold-called to sell VOIP service while I wrote this up? Oh, it's Comcastic ...

Sorting a matrix/data.frame on a column

October 30, 2009 · Posted in R bloggers · Comments Off 
mat.sort <- function(mat,n)
{
	mat[rank(mat[,n]),] <- mat[c(1:nrow(mat)),]
	return(mat)
}

a <- matrix(rnorm(100),ncol=10)
mat.sort(a,1)

Decimal log scale on a plot

October 30, 2009 · Posted in R bloggers · Comments Off 

R only does natural (neperian) log scales by default, and this is lame.

Here is a simple code to do decimal log scale, pretty much a requirement for scientists…

The force(x/y)lim options works for natural and log scales (for the later case, you need to specify the power of 10 that you want : c(-2,2) fixes the limit from 0.01 to 100)

drawlogaxis <- function(side,range)
{
	par(tck=0.02)
#	d <- log(range,10)
	d <- range
	mlog <- floor(min(d))
	Mlog <- ceiling(max(d))
	SeqLog <- c(mlog:Mlog)
	Nlog <- (Mlog-mlog)+1
	axis(side,at=SeqLog,labels=10^SeqLog)
	ats <- log(seq(from=2,to=9,by=1),10)
	mod <- NULL
	for(i in SeqLog)
	{
		mod <- c(mod,rep(i,length(ats)))
	}
	ats <- rep(ats,Nlog)
	ats <- ats+mod
	par(tck=0.02/3)
	axis(side,at=ats,labels=NA)
}

logplot <- function(x,y,log='xy',...,forceylim=c(0,0),forcexlim=c(0,0))
{
	par(tck=0.02)
	xlg <- FALSE
	ylg <- FALSE
	if('x'%in%strsplit(log,'')[[1]]){x <- log(x,10);xlg=TRUE}
	if('y'%in%strsplit(log,'')[[1]]){y <- log(y,10);ylg=TRUE}
	yl <- ifelse(forceylim==c(0,0),range(y),forceylim)
	xl <- ifelse(forcexlim==c(0,0),range(x),forcexlim)
	plot(x,y,...,axes=FALSE,ylim=yl,xlim=xl)
	if(xlg){drawlogaxis(1,xl)}else{axis(1,at=pretty(xl),labels=pretty(xl))}
	if(ylg){drawlogaxis(2,yl)}else{axis(2,at=pretty(yl),labels=pretty(yl))}
	box()
}

addlog <- function(x,y,log='xy',...)
{
	xlg <- FALSE
	ylg <- FALSE
	if('x'%in%strsplit(log,'')[[1]]){x <- log(x,10);xlg=TRUE}
	if('y'%in%strsplit(log,'')[[1]]){y <- log(y,10);ylg=TRUE}
	points(x,y,...)

}

Income inequality and partisan voting in the United States

October 29, 2009 · Posted in R bloggers · Comments Off 
Lane Kenworthy, Yu-Sung Su, and I write: Income inequality in the United States has risen during the past several decades. Has this produced an increase in partisan voting differences between rich and poor? We examine trends from the 1940s through...

Simple R figures

October 29, 2009 · Posted in R bloggers · Comments Off 
http://www.harding.edu/fmccown/R/

This comes very handy.

Kicking Ass with plyr

October 29, 2009 · Posted in R bloggers, Uncategorized · Comments Off 

Tonight (October 29, 2009) at 5:30 PM is the Chicago R meetup at Jaks tap. Here’s more info.  I’ll be making a presentation based on my earlier blog post about plyr. The presentation will only be 8 minutes long so I’ve had to pick and choose my info carefully. OK, who am I kidding? I had a couple of Schlitz (in a bottle!) for lunch over at Boni Vinos and slammed some slides together rather haphazardly. At any rate, here’s the presentation. I owe special thanks to all the folks in Twitter who reviewed these slides this week. A special shout out to @kenahoo who caught my one code typo! And also to @hadleywickham (author of plyr) who made some good suggestions, some of which I heeded. As a professor he should consider 15% application of his information to be a phenomenally high rate.

Click the graphic to download the slides as a PDF:

kickingasswithplry

If you’re wondering what my favorite beer is, I’ll give you a secret. My favorite beer is #3. That’s the one that makes me a persuasive and articulate public speaker. #4 makes me dance well.

I hope to see you tonight.

Go long on close and sell on open

October 29, 2009 · Posted in R bloggers · Comments Off 

I found a description of supposed to be profitable strategy on Bloomberg. The strategy is simple – buy S&P500 index on close and sell it on next day open.

So, I tested this claim and got nice P/L curve:

Photobucket

Yes, since 1993 this strategy has generated the profit >300%. But, neither commissions or slippage are included:)

Let’s consider 0.0007% commissions+slippage(7$ per 10000 trade). There we go:

Photobucket

Is it good? I will look for somethig better…

Bioconductor 2.5 is out

October 29, 2009 · Posted in R bloggers · Comments Off 
For all bioinformaticians and R users out there: the Bioconductor project  for the analysis and comprehension of genomic data is out! A lot of interesting new stuff! See the full announcement here.

Tips for Using StatET and Eclipse for Data Analysis in R

October 29, 2009 · Posted in R bloggers · Comments Off 
My favourite editor for conducting analysis in R is the StatET plug-in for Eclipse. This post discusses an assortment of tips and tricks that I've discovered to make this editing environment even better.

Search
  • Search (Control + H): I maintain projects in the project explorer. If I need to know how I have used an R function in the past, I search for the function name.
Options for Running R Code
  • List Run Options (Control + R)
  • Run entire command (Control + R Control + E): Press this key combination on the identifier for a function to run entire function (particularly useful for running nested functions). It's also useful when you have a line of code that spans multiple lines.
  • Run Function Definition (Control + R Control + F): Fun function definition; If you have nested functions, this key combination runs the both outer and inner functions. Thus, don't use this to refresh the function definition of a nested function.

    Coding
    • Fix Indentation  (Control + I)
    • Delete Line (Control + D)
    • Code Folding

      • Expand Current: (Control + Num "+")
      • Collapse Current (Control + Num "-")
      • Collapse All (Control + Shift + Num "/")
      • Expand All (Control + Num "*")
      • Enable/Disable Code Folding (Control + Num "/")
    Help
    • List tips and tricks (Help - Tips And Tricks - Eclipse Platform)
    • View all short cut keys (Control + Shift + L):
    Outline View
    • Highlight Outline (Alt + Shift Q, O)
    • Refresh code in a function (right click on function in Outline)
    • Cut and paste functions (Use Outline View)

      Assorted
      • Get file path (Alt W, V, P, P, Enter; Navigate to file; Alt + Enter; Alt + L; Shift + End; Shift + Down; Control + c)
      • Go to function definition (Copy function name; Control + Tab to go to function sheet; control + home to go to top of function sheet; control + F to find; control + v to paste; Enter; Esc)
      • Activate cursor in console (Control + R, C)
      • Activate cursor in editor (F12)
      • Toggle maximisation of current window (Control + M)
      • Auto completion (Control + /); this does not worke with dot.case.identifiers. Thus, this is another reason to prefer mixedCaseIdentifiers.
      • Print current variable (Control + R, P); this is useful when writing functions; I might run an assignment (control + R, control + R) and then print the result. However, it is problematic when there is a lot of data.
      • Change variable names (Control + 1)
      • Opening Files in Project Editor based on standard file association (Right Click File - Open With - System Editor). Many files will open within StatET. This is sometimes undesirable.

      Using the “foreign” package for data conversion

      October 27, 2009 · Posted in R bloggers · Comments Off 
      I was in a rush to convert a SPSS data into Stata format. Somehow my Stattransfer v.8 for Linux was lost and I did not want pause my work and go back to Windows just to get this one file converted. So fire Emacs+ESS+R, load the "foreign" package, did the file conversion, and it worked!

      Next Page »