hermesh2
11/22/2015 - 1:57 AM

06 Solution 5.R

# Solution 5
# S Surface 3d ------------------------------------------------------------
nbins <- 20
x.bin <- seq(0, 1000, length= nbins)
y.bin <- seq(0, 700, length= nbins)

freq <-  as.data.frame(table(findInterval(x = d[,1], vec = x.bin),
                             findInterval(x = d[,2], vec = y.bin))) # generates a frequency matrix
freq[,1] <- as.numeric(freq[,1])
freq[,2] <- as.numeric(freq[,2])

freq2D <- diag(nbins)*0 # create a square matrix with nbin rows.
freq2D[cbind(freq[,1], freq[,2])] <- freq[,3] # Generates frequence mastrix

surface3d(x.bin,y.bin,freq2D/5, col="steelblue") 
# E Surface 3d ------------------------------------------------------------