1) Plot Chi-Squared Distribution:
>help(Chisquare)
> x <- seq(-20,20,by=.2) > y <- dchisq(x,df=10) # df is degree distribution > plot(x,y)
2) Vector
> y <- 1:10 #create a vector of consecutive integers from 1 to 10
> y <-c(4,9,2,8) #create a vector with 4 components > sum(y) #sum of elements in y
> cumsum(y) #cumulative sum vector
> sort(y) # increase order
> sort(y, decreasing=T) # decreasing order
> length(y) # number of elements in y
> y[2] # the second element of y
>y[1:2] # the first two elements in y
3) function
find root
> y.fun<-function (x)
{y<-(log(x))^2-x*exp(-x^3)
}
>root.fun<- function ()
{ x<-seq(0.2,2,0.01)
y<-y.fun(x)
plot(x,y,type="l")
abline(h=0)
r1 <- uniroot(y.fun,lower=0.2,upper=1)$root
r2 <- uniroot(y.fun,lower=1,upper=2)$root
cat("Roots : ", round(r1,4), " ", round(r2,4),"\n")
}
> root.fun()
4) Basic plots:
> my <- read.csv(file="my.dat",sep=",",head=TRUE) # read in my.dat
> stripchart(my$vals)
> stripchart(my$vals,method="jitter")
> stripchart(my$vals,vertical=TRUE)
> stripchart(my$vals,method="stack",
+ main='test',
+ xlab='number') # strip chart
>hist(my$vals,breaks=2) # number of division in x is 2
>boxplot(my) #box plot
Online computer courses, code, programming tutorial and sidebar information for monitoring Canadian S&P/TSX index. Build friendship and networking. Welcome to visit my blogs often!!! I also have two other sites: YouTube Channel and Google site.
Adsense
Popular Posts
- PHP: add a download as pdf file button in report page
- How to blend adsense inside your post?
- Formatting my post
- PHPWind-- A PHP forum script applcaition in China
- Notepad++ - Add C++ compiler
- PHP connect IBM db2 database in XAMPP
- Datatable export excel wraptext and newline
- phpexcel toggle expand and hide column in EXCEL and summary
- Sweet Alert JS library - beautiful replacement of JavaScript Alert
- ActionScript 3.0 demo: create a falling snow in flash CS6
No comments:
Post a Comment