treemap in R

library(RODBC)
library(lattice)
library(treemap)

ch<-odbcConnect("mike_db",uid="mike")
c<-sqlQuery(ch, paste("select" 
,"ward,year(end_Dttm) as [year]"
,",sum(datediff(mi,start_Dttm,end_Dttm)/1440.0) as LOS"
,"from [wardstays_examples]"
,"GROUP BY ward ,year(end_Dttm)" 
))
str(c)

treemap (c
         ,index=c("year","ward") # the different levels
         ,vSize = "LOS" # the value on which to scale the squares
         )


Excel: replace a character or string with CR LF

This is a technique aimed at splitting up a long cumbersome string held in a single cell using new line breaks. It requires that we replace a normal character with the special characters [CR][LF].

Why would you want to do this?
Well sometimes it looks nice and it makes life easier, or it can make the data easier to scan through. I first used it to show ICD10 Diagnosis code strings from a concatanated string into a single readable cell.

To start off generate your file so that each part of the string that you want on a seperate line has a unique character (or unique string) at the end of the subsection.
In this example I’ve used “: ”
Pic1
Now highlight the section you want to change. Ctrl + A on a section etc.
Then bring up the find and replace dialog using Ctrl + H
In this example I needed to replace “: ” (thats colon followed by a space)
pic2
Now place your cursor in the replace section:
Hold down ALT + 010 release (the ALT key) and then ALT + 013 then release again.
Press the replace all button and away it goes, It can take longer doing this than a normal find and replace.
pic3
…and that’s what you get newlines instead of “: ”

Set Grub2 (Fedora 19) default boot to…something other

grep menuentry /boot/grub2/grub.cfg

Copy the name of the OS you want as default
then access the /etc/default/grub file as root

sudo gedit /etc/default/grub 

Replace whatever is currently being given to GRUB_DEFAULT with the OS name you want as the default (enclose the OS name in “”)

Then run as root:

grub2-mkconfig -o /boot/grub2/grub.cfg

…and reboot to test

I don’t think this survives a Kernel update, but the process is not onerous, and no sacrifices to the gods are required.

GIS in R cran

library(maptools)
library(Cairo)
walesCoast<-readShapeSpatial("Z:/MAPPING DATA/Meridian 2 Shape/data/coast_ln_polyline.shp", proj4string=CRS("+init=epsg:27700"))
walesUA<-readShapeSpatial("Z:/MAPPING DATA/Meridian 2 Shape/data/district_region.shp", proj4string=CRS("+init=epsg:27700"))
x1x2<-c(221000,346594)
y1y2<-c(269406,395000)

plot(walesUA,xaxs="i",yaxs="i",xlim=x1x2,ylim=y1y2,lwd=1)
plot(walesCoast,xaxs="i",yaxs="i",xlim=x1x2,ylim=y1y2,lwd=3,col="red", add=TRUE)

mtext("upvar",side=2,line=2,col=1)
mtext("Bottom",side=1,line=2,col=2)
mtext("Top",side=3,line=2,col=3)
mtext("Right",side=4,line=1,col=4)

Remove lots of values from a large Excel without the undo memory overhead

in this case get rid of the null, this was a sparse query output!

Sub RemoveNulls_memoryCheap()
'
' RemoveNulls_memoryCheap Macro
'
For cci = 1 To 255
If Not Cells(1, cci) = "" Then
    columnCOunt = cci
End If
Next cci
    
For t = 1 To columnCOunt
Range(Columns(t), Columns(t)).EntireColumn.Select
    Selection.Replace What:="null", Replacement:="", LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
Next t

some grep

Find all instances of java in the output list from the rpm installed packages list.

rpm -qa | grep "java"