Google


Sunday, April 17, 2011

How to find R help online

In R you can find the help page of a function by typing help(func). If you want to something quickly online, place library and function in the following URL and off you go.

http://127.0.0.1:21798/library/[lib]/html/[func].html


Friday, April 15, 2011

Does Amazon filter Kindle items well?

As you might suspect, my answer is No. When searching for new Kindle books, I hardly find good results or recommendations. The problem is that there are a lot of virtually zero priced items which are top of the list but they are hardly worth the megabytes they carry. I am tired of looking at lists of cheap self help books.

Amazon seems to use the same recommendation idea for Kindle books but actually needs to adjust it to make it relevant. How does it help me if every second recommendation is Dracula just because it's free?

Amazon needs to put quality at the top of the list.

Better Choices Better Deals

BIS has published a paper which outlines how customers can benefit from using their data to optimise their shopping. They quote the many loyalty cards and tools which are already out there. They are creating the mydata initiative where customers can access their own data and find the best deals based on their usage.

I am quote skeptic about this scheme.

  1. Data is collected for a reason by specialised companies which exploit the data (not the customer), it is their asset.
  2. Data formats from different providers/retailers are vastly different and will never be brought under one roof, if it will the data will lose its richness. (A good example is the number of households quoted from Boots, Tesco and Nectar - they all use different definitions of what an active household is)
  3. There is a cost involved and it is not clear who will carry that.

Nevertheless I like the idea that customers have more rights to accessing their own data.

http://www.bis.gov.uk/assets/biscore/consumer-issues/docs/b/11-749-better-choices-better-deals-consumers-powering-growth.pdf

Wednesday, April 06, 2011

R and Python

Here is a R and Python syntax table, I have also included Numpy commands to make it more comparable. Where a cell is empty I could not find an equivalent.


Task Python Python Numpy R
sequence x=[I for I in range(1,11)]   x <- 1:10
scalar x=1 x=array(1) x <- 1
vector/list x=[1,2] x=array((1,2)) x <- c(1,2)
constant vector x=100*[1] x=ones(100) x <- rep(1,100)
append x.append(1)   x <- c(x,1)
matrix x=[[1,2],[3,4]] mat([[1,2],[3,4]]) x <- matrix(c(1,2,3,4),ncol=2,byrow=TRUE))
column stack   hstack((x,y)) cbind(x,y)
row stack   vstack((x,y)) rbind(x,y)
for for I in range(1,11):
 print I
  for I in c(1:10)) {
 print(I)
}
while I=1
while (I<10):
 I+=1
  I <- 1
while (I<10) {
 I <- I+1
}
if if I==10:
 print 'Yes'
else:
 print 'No'
  if (I==10) {
 print('Yes')
} else {
 print ('No')
}
length len(x) len(x) length(x), nrow(x)
columns len(x[0]) x.shape[1] ncol(x)
dimension   x.shape dim(x)
summary     summary(x)
read csv import csv
reader=csv.read(open('file','r'))
mydata=[]
for line in reader:
 mydata.append(line)
  mydata <- read.csv("file", header=TRUE)
write csv import csv
writer=csv.writer(open('file','w'))
for d in data:
 writer.writerow(d)
  write.csv(data, file="file", row.names = FALSE)
sum sum(x) sum(x) sum(x)
select element x[1][1] x[1,1] x[2,2]
last element x[-1] x[-1] x[-1]
select column   x[:,1] x[,2], x$Name
correlation   corrcoef(x,y) cor(x,y)
mean   mean(x) mean(x)
function def func(x):
 print x
 return x
  func <- function(x) {
 print(x)
 return(x)
 }
dot product   dot(x,b) x*b
transpose   transpose(x) t(x)
matrix product   b*x t(b) %*% x
random random.random() random.rand(1) runif(1,0,1)
sort x.sort()   sort(x)
help help(command) help(command) help(command), ??command