Reversing Bob

Following our look at Weird Al Jankovic’s palindromic song, Bob, I have written two short VBA User Defined Functions (UDFs) to help writing palindromes (and possibly with other tasks as well).

Reverse() will, as the name suggests, reverse any text entered as the argument, for instance:
” I, man, am regal – a German am I” becomes:
” I ma namreG a – lager ma ,nam ,I”

Reverse also has two optional arguments to start and stop at specified characters, counting from the start and end of the original string, so:
=reverse(“abcdefgh”,2,3) returns:
“fedcb”

Palin() returns a palindrome consisting of the argument string followed by the string reversed, so:
=Palin(“Never od”) returns:
“Never oddo reveN”

Palin has two optional arguments:
“Rev” = False (default) will start with the input string, followed by the reversed string, whereas Rev = True will put the reversed string first.
“RepeatCen” = False (default) will not repeat the last character of the input string, whereas True will repeat the character.

The code for these two functions is quite short:

Function Reverse(Base As String, Optional FirstChar As Long = 1, Optional LastChar As Long = 1) As String
Dim Rtn As String, i As Long

For i = Len(Base) - LastChar + 1 To FirstChar Step -1
    Rtn = Rtn & Mid(Base, i, 1)
Next i
Reverse = Rtn

End Function

Function Palin(Base As String, Optional Rev As Boolean = False, Optional RepeatCen As Boolean = False) As String
Dim Rtn As String, i As Long, LastChar As Long

If RepeatCen = True Then LastChar = 1 Else LastChar = 2

If Rev = True Then
    Rtn = Reverse(Base, LastChar, 1)
    Palin = Rtn & Base
Else
    Rtn = Reverse(Base, 1, LastChar)
    Palin = Base & Rtn
End If

End Function

But since one of the functions is named Palin, we really should do it in Python, which is even shorter:

def palin(pstring, rev, repeatcen):

    lastchar = 1
    if repeatcen == True: lastchar = 0
    strlen = len(pstring)
    if rev == True:
        return pstring[::-1] + pstring[lastchar:strlen]
    else:
        return pstring + pstring[strlen-1-lastchar::-1] 

def reverse(pstring, firstchar, lastchar):
    strlen = len(pstring)
    if firstchar > 1:
        return pstring[strlen-(lastchar):firstchar-2:-1]
    else:
        return pstring[strlen-(lastchar)::-1]

Both versions of the functions can be downloaded from Palin.zip.

The Python version includes all the necessary ExcelPython files, but will need an installed copy of Python.

The files also include the full lyrics of Bob, both forwards and backwards:

Palin1

Posted in Excel, Link to Python, UDFs, VBA | Tagged , , , , , | Leave a comment

Two exceptional musicians

On Saturday night we were treated to fine performances from two exceptional young musicians.  The first was Stefan Jackiw, performing with The Australian Chamber Orchestra at Angel Place.  Here he is playing a Beethoven piece in 2009:

Then after the concert, walking down a traffic free and pedestrian packed George Street, on the way to see the Circular Quay illuminations the guitarist Tom Ward was busking to a large crowd.  Most of the Youtube clips of his outside performances have terrible sound quality, but it’s not too bad on this one:

(the battered guitar is still going!)

It seems that Tom Ward has not yet been deemed Wiki-worthy, but you can read more about him at last.fm.

He also plays inside sometimes:

 

 

Posted in Bach | Tagged , , , | Leave a comment

Baby Names and Pivot Tables

boyslast (1)

Baby Boom: An Excel Tutorial on Analyzing Large Data Sets is a comprehensive (and free) tutorial looking at analysing public databases of baby names, using Excel:

There are professional data analysts out there who tackle “big data” with complex software, but it’s possible to do a surprising amount of analysis with Microsoft Excel. In this case, we’re using baby names from California based on the United States Social Security Baby Names Database. In this tutorial, you’ll not only learn how to manipulate big data in Excel, you’ll learn some critical thinking skills to uncover some of the flaws within databases. As you’ll see, the Social Security database, which goes back to 1880, has some weird and wonderful anomalies that we’ll discuss.

The tutorial is comprehensive and well presented, including the following topics:

Download the data andimport it into Excel 
Use Filters 
SanityChecks 
Summarize withPivot Tables 
Add aPivotChart 
AnotherSanity Check 
Explore yourdata and uncover insights 
Determineimportant ratios 
Graph individualdata points and trends 
Visualizeyour data

For more on analysing and visualising data also see the authors blog:
prooffreader.com

About the author: David Taylor is a scientist who does freelance data analysis for paying customers so that he can afford to do fun data analysis for free on his blog, prooffreader.com. (Yes, “prooffreader” is misspelled; that’s the joke!)

 

Posted in Charts, Excel | Tagged , , , , , | Leave a comment

Managing Data Using Excel …

… is a new book by Mark Gardener, published by Pelagic Publishing.*

It is subtitled “Organising, summarising and visualising scientific data”.  The publishers say of the book:

Microsoft Excel is a powerful tool that can transform the way you use data. This book explains in comprehensive and user-friendly detail how to manage, make sense of, explore and share data, giving scientists at all levels the skills they need to maximize the usefulness of their data.

Readers will learn how to use Excel to:
* Build a dataset – how to handle variables and notes, rearrangements and edits to data.
* Check datasets – dealing with typographic errors, data validation and numerical errors.
* Make sense of data – including datasets for regression and correlation; summarizing data with averages and variability; and visualizing data with graphs, pivot charts and sparklines.
* Explore regression data – finding, highlighting and visualizing correlations.
* Explore time-related data – using pivot tables, sparklines and line plots.
* Explore association data – creating and visualizing contingency tables.
* Explore differences – pivot tables and data visualizations including box-whisker plots.
* Share data – methods for exporting and sharing your datasets, summaries and graphs.

Alongside the text, Have a Go exercises, Tips and Notes give readers practical experience and highlight important points, and helpful self-assessment exercises and summary tables can be found at the end of each chapter. Supplementary material can also be downloaded on the companion website.

Managing Data Using Excel is an essential book for all scientists and students who use data and are seeking to manage data more effectively. It is aimed at scientists at all levels but it is especially useful for university-level research, from undergraduates to postdoctoral researchers.

Clearly the book is aimed at scientists, particularly those dealing with the analysis of observational data, but is it of value to a wider audience?  Having worked through the book I would say that it is definitely worthwhile for many other groups, including those in engineering and other branches of science and technology, and also those in commercial and marketing work dealing with the analysis of numerical data of any kind.

Aspects of the book that I found particularly useful were:

  • Detailed and clear descriptions of the use of pivot tables in the analysis and summary of numerical data of any kind (an area where I could certainly make more use of the features available in Excel)
  • Clearly laid out procedures for arranging, checking and exploring data.
  • Detailed procedures for display of data in a wide variety of graphs.
  • Detailed step-by step example spreadsheets available from the publisher’s web-site.

This is certainly not a book “for dummies”, and some may find the emphasis on scientific procedures off-putting, but for those willing to spend some time working through the examples I believe it will be of value to anyone who uses Excel to organise, summarise and visualise numerical data of any kind.

* Pelagic Publishing provided me with a free copy of the book for this review; I have no other connection with the publishers or the author.

 

Posted in Charts, Excel, Newton | Tagged , , | Leave a comment

Avoid si Aibohphobia is di ova …

… which loosely translated means, if you have inherited the rare but debilitating condition known as aibohphobia, or fear of palindromes, then read no further, and don’t even think about clicking on the Vimeo video below.

Since today (for those of you living in countries where the month comes before the day) is 5-10-2015, which is a palindrome, I thought we should celebrate with this palindromic song from Weird Al Yankovic (click the video full-screen icon to read the words!):

and the original (non-palindromic) version from “bob” himself:

And if that is not enough for you, read all about Subterranean Homesick Blues (1965) – Bob Dylan – Filming Location – London, England

 

 

Posted in Bach | Tagged , , | 2 Comments