Demo entry 6687340

asdasd

   

Submitted by anonymous on Dec 28, 2017 at 04:50
Language: S. Code size: 916 Bytes.

book <- readChar("chapter2.txt", file.info("chapter2.txt")$size)
book <- gsub('[\r\n\t]', ' ', book)
book <- gsub('[^a-zA-Z]', ' ', book)
book <- gsub(' [b-zB-Z]{1,2} ', ' ', book)
book <- gsub("  *", " ", book)
book <- strsplit(book, " ")
book1 <- as.data.frame(table(book))

# Turn off warnings...
oldw <- getOption("warn")
options(warn = -1)

par(mfrow=c(1,2))
plot(sort(book1$Freq) , 1-ecdf(book1$Freq)(sort(book1$Freq) ), 
     type = "l",
     xlab = "1-CDF(x)", ylab = "y", 
     main="CCDF" )
plot(sort(book1$Freq) , 1-ecdf(book1$Freq)(sort(book1$Freq) ), 
     log="xy", type = "l",
     xlab = expression(-alog(x)+alog(x[m])), ylab = "log(y)", 
     main="CCDF: log-log" )

options(warn = oldw)

Data <- as.integer(book1$Freq)
Y <- log(sort(Data))
X <- log(1-ecdf(Data)(sort(Data) ))
Data1 <- as.data.frame(cbind(Y,X))
Data1[2108,2] <- Data1[2107,2]
lm(Y ~ X, data = Data1)

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).