Basics of R- Session 1- Help Command
Dr Manohar Kapse
2015-07-23T21:13:14-05:00
welcome to the First Session of Learn R
First things we should learn before starting R is help command
help.start()
# for general help use ?help() or help()
# to get help about a specific package or command use help.search("")
# to get information about any package or command or word, input the word in ""
#example
help.search(“mean”)
# gives information about mean in the R environment
# help("mean")
# it gives information regarding the word "mean", which is available in the R environment
# we can use ?mean() or ?mean.default()
# it gives the information about the mean function
# use of example()
# it gives examples on few of the commands in R packages
Example of mean
example("mean")
##
## mean> x <- c(0:10, 50)
##
## mean> xm <- mean(x)
##
## mean> c(xm, mean(x, trim = 0.10))
## [1] 8.75 5.50
Example of Linear regression
example("lm")
##
## lm> require(graphics)
##
## lm> ## Annette Dobson (1990) "An Introduction to Generalized Linear Models".
## lm> ## Page 9: Plant Weight Data.
## lm> ctl <- c(4.17,5.58,5.18,6.11,4.50,4.61,5.17,4.53,5.33,5.14)
##
## lm> trt <- c(4.81,4.17,4.41,3.59,5.87,3.83,6.03,4.89,4.32,4.69)
##
## lm> group <- gl(2, 10, 20, labels = c("Ctl","Trt"))
##
## lm> weight <- c(ctl, trt)
##
## lm> lm.D9 <- lm(weight ~ group)
##
## lm> lm.D90 <- lm(weight ~ group - 1) # omitting intercept
##
## lm> ## No test:
## lm> ##D anova(lm.D9)
## lm> ##D summary(lm.D90)
## lm> ## End(No test)
## lm> opar <- par(mfrow = c(2,2), oma = c(0, 0, 1.1, 0))
##
## lm> plot(lm.D9, las = 1) # Residuals, Fitted, ...
##
## lm> par(opar)
##
## lm> ## Don't show:
## lm> ## model frame :
## lm> stopifnot(identical(lm(weight ~ group, method = "model.frame"),
## lm+ model.frame(lm.D9)))
##
## lm> ## End(Don't show)
## lm> ### less simple examples in "See Also" above
## lm>
## lm>
## lm>
No comments:
Post a Comment