官术网_书友最值得收藏!

Next steps with R

Before we pe into machine learning, it will be useful to pause for a moment, take a deep breath, and contemplate on what you have learnt so far. This quick yet detailed refresher of R will help you a lot in the upcoming chapters. However, there are two more things which we must go through quickly. They are how to get help in R and how to work with various packages in R.

Getting help

By now, you must have figured out that there are thousands of functions and constructs in R and it is impossible to remember what each of them actually does and you don't have to either! R provides many intuitive ways to get help regarding any function, package, or data structure. To start with, you can run the help.start() function at the R command prompt, which will start a manual browser. Here you will get detailed information regarding R which includes manuals, references, and other material. The following command shows the contents of help.start() as shown in the screenshot following the command, which you can use to navigate further and get more help:

> help.start()

If nothing happens, you should open http://127.0.0.1:31850/doc/html/index.html yourself.

To get help on any particular function or construct in R, if you know the function's name, you can get help using the help function or the ? operator in combination with the function name. For example, if you want help regarding the apply function, just type help("apply") or ?apply to get detailed information regarding the apply function. This easy mechanism for getting help in R increases your productivity and makes working with R a pleasant experience. Often, you won't quite remember the exact name of the function you intend to use but you might have a vague idea of what its name might be. R has a help feature for this purpose too, where you can use the help.search function or the ?? operator, in combination with the function name. For example, you can use ??apply to get more information on the apply function.

Handling packages

There are thousands and thousands of packages containing a wide variety of capabilities available on CRAN (Comprehensive R Archive Network), which is a repository hosting all these packages. To download any package from CRAN, all you have to do is run the install.packages function passing the package name as a parameter, like install.packages("caret"). Once the package is downloaded and installed, you can load it into your current R session using the library function. To load the package caret, just type library(caret) and it should be readily available for use. The require function has similar functionality to load a specific package and is used specially inside functions in a similar way by typing require(caret) to load the caret package. The only difference between require and library is that, in case the specific package is not found, library will show an error but require will continue the execution of code without showing any error. However, if there is a dependency call to that package then your code will definitely throw an error.

主站蜘蛛池模板: 乐业县| 萍乡市| 咸阳市| 邳州市| 肇州县| 离岛区| 固原市| 仙居县| 渭源县| 黄山市| 尉犁县| 溧阳市| 深水埗区| 宿松县| 大渡口区| 广平县| 青川县| 工布江达县| 浦城县| 乐山市| 会理县| 吉林市| 庆云县| 疏勒县| 绍兴市| 郯城县| 衡阳县| 新龙县| 邵东县| 招远市| 鹤壁市| 奉新县| 海宁市| 鄂伦春自治旗| 柘荣县| 临沂市| 西乌珠穆沁旗| 句容市| 万全县| 鲁甸县| 北流市|