R –Refcards and Basic I/O Operations

While working with a large number of files for data processing, I used the following R commands for data processing. Given that everyone needs to split as well merge and append data – I am just giving some code on splitting data based on parameters , and appending data as well as merging data.

Splitting Data Based on a Parameter.

The following divides the data into subsets which contain either Male or anything else in different datasets.

Input and Subset

Note the read.table command assigns the dataset name X in R environment from the file reference (path denoted by ….)

x <- read.table(....)
rowIndx <- grep("Male", x$col)
write.table(x[rowIndx,], file="match")
write.table(x[-rowIndx,], file="nomatch")


Suppose we need to divide the dataset into multiple data sets.

X17 <- subset(X, REGION == 17)

This is prefered to the technique -

attach(X)
X17 = X[REGION == 17,]

Output

For putting the files back to the Windows environment you can use-

write.table(x,file="",row.names=TRUE,col.names=TRUE,sep=" ")

Append

Lets say you have a large number of data files ( say csv files )

that you need to append (assuming the files are in same structure)

after performing basic operations on them.

>setwd("C:\\Documents and Settings\\admin\\My Documents\\Data")

Note this changes the working folder to folder you want it to be,

note the double slashes which are needed to define the path

>list.files(path = ".", pattern = NULL, all.files = FALSE, full.names = FALSE,recursive = FALSE, ignore.case = FALSE)

The R output would be something like below

[1] "calk.csv"                                            "call.csv"                                           
[2]"calm.csv"                                            "caln.csv"                                           
[3]"calo.csv"                                            "calp.csv"                                           

For appending one file repeatedly (like ten times) you can use the command

file.append("A", rep("B", 10))

For Refcards on learning R , the best ones are –

http://cran.r-project.org/doc/contrib/Shortrefcard.pdf

and

http://disinterested.googlepages.com/RQuickReference.pdf

dtp.amazon.com BETA

Here is a nice beta thing for all authors.

Amazon’s self publishing paltform

https://dtp.amazon.com/mn/dashboard

It is great for ease of use, functional design and convenience.

Caveat – Its limited to United States .You need United States Tax information to register.image

But still a very good DTP platform and aimed at the Amazon Kindle ( E –Book ) Segment initially.

 image

Scribd.com

I belive you know this already, but in case you don’t. Scribd.com is a much better view to share documents than the normal upload-the-pdf and wait-for-it-to-load-method.

 

You can see the previews here ( I was experimenting with http://www.decisionstats.com/drupal in the middle of some finishing some models and creating software robots projects-

https://decisionstats.com/drupal/node/3

 

image image

or can actually see the full effect here

Book2.1WithCover

Backing up :WordPress Sites

If you have a WordPress site that you have put in a fair amount of work- here is a great way to back it up in 5 minutes.

 

  1. Go to Manage- Exportimage
  2. Export the Xml file which has all posts, tags,categories,comments of your site.
  3. Go to www.wordpress.com
  4. Create a new blog www.yoursite.wordpress.com
  5. Import the XML file created in Step 2image
  6. Ole ! Your Backup site is ready – for free – and in five minutes image.
  7. Caveat – www.wordpress.com offers better themes and the latest WordPress version so the backup might end up looking better than the real site
  8. Copy some widgets manually – like Feedblitz readership etc

Grey Christmas

Grey Christmas, as the fog hangs on deep.

Bright lights shine ,from the city that refuses to sleep.

Rubbing your hands, walking alone in the cold.

Was it always like this at Christmas or Am I just growing old.

 

What if I never lived on this earth,

Did it make any difference with my birth.

Jobs are rare, rarer than hot sunny days,

Christmas was a party, now its time to change ways.

 

To live down slowly, gather savings and adjust.

Someone else ‘s folly, and some bankers money lust.

So We the people still gather Around the tree.

The rich still have white Christmas ,

but it’s colored grey for you and me.

 

 

 

 

 

 

 

 

 

 

 

Image from the Christmas Movie- “Its a wonderful life”.

A Software called Splunk

Splunk from www.splunk.com is a software that helps

* Index and search all of your IT data generated by your Windows
desktops, servers and applications.
* See all data – registry, event logs, network and security device
logs, system performance – in a single, related view.
* Track down who installed what, when and where. Save and schedule
searches as proactive alerts to improve monitoring coverage over time.
* Speed up root-cause analysis and pinpoint which system is the
problem. Reports and dashboards let you keep watch across the servers
you manage.

You can use Splunk  in the following ( from the website)

image

Operations.

Improve service levels and recover from problems faster.

Security.

Thwart attacks with quick, in-depth incident response.

Compliance.

E-Discovery, FFIEC, FISMA, HIPAA, PCI, SOX without disrupting operations.

Business Intelligence.

See your transactions as they happen.

 

Its quite nice and should be tried by IT administrators and server managers for analysis of logs. It is also now available in all Windows editions -Downloadable here

http://cts.vresp.com/c/?SplunkInc./17589c269e/2ba88cef29/54cbdb46ca

And it is free 🙂

Walk Alone

Tagore’s English translation

If they answer not to thy call walk alone,
If they are afraid and cower mutely facing the wall,
O thou of evil luck,
open thy mind and speak out alone.

If they turn away, and desert you when crossing the wilderness,
O thou of evil luck,
trample the thorns under thy tread,
and along the blood-lined track travel alone.

If they do not hold up the light when the night is troubled with storm,
O thou of evil luck,
with the thunder flame of pain ignite thy own heart
and let it burn alone.

http://en.wikipedia.org/wiki/Ekla_Chalo_Re

From a Bengali-Indian Poet – Tagore who won the Nobel Prize in 1914