Kuxazululiwe: klelisa wonke amaphakheji afakiwe

Impela, ake siqale ukubhala indatshana yokuthi kufakwa kanjani kuhlu wonke amaphakheji afakiwe ku-R.

Ulimi lokuhlela lwe-R luyithuluzi elibalulekile lokuthuthukiswa emkhakheni wezibalo wekhompuyutha kanye nezithombe. Phakathi kwamakhono ayo, u-R uvumela izindlela ezimbalwa zokubuka ukuthi yimaphi amaphakheji afakiwe njengamanje. Amandla okuhlola nokusebenzisa lawa maphakheji atholakalayo engeza ukuguquguquka kwekhodi yakho engu-R futhi angaba nomthelela omkhulu ekuhlaziyeni kwakho. Lesi sihloko sigxile ekuboniseni izindlela ezahlukene zokufaka ohlwini wonke amaphakheji afakiwe ku-R.

Faka kuhlu amaphakheji afakiwe ku-R

In R izinhlelo, amaphakheji ahlinzeka ngezinhlobo eziningi zokusebenza kubasebenzisi. Ukuba nombono ocacile wamaphakheji afakiwe kubalulekile njengoba kunikeza ukuqonda okujulile kwemisebenzi ongayisebenzisa. Nansi indlela yokubuyisa uhlu lwamaphakheji afakiwe ku-R:

# Using installed.packages() function
installed_packages <- installed.packages()
package_names <- installed_packages&#91;,1&#93;
&#91;/code&#93;

In the code snippet above, we are employing the installed.packages() function, which provides a matrix of details related to the packages. Then, by indexing, we select all the package names.

<h2>Understanding the installed.packages() function</h2>

In R, the <b>installed.packages()</b> function is a simple yet powerful utility to fetch a variety of details about your repository's packages. This function retrieves a matrix with a row for every package found in the libraries and a column for every piece of information known about the packages.

[code lang="R"]
# Using installed.packages() function
installed_packages <- installed.packages()
&#91;/code&#93;

After running the installed.packages() function, it returns a matrix with the various details such as package versions, license, and library where the package has been installed, among others. If you're solely interested in package names, you can index the matrix, as shown in the code earlier.

<h2>The utils and library() functions in R</h2>

The <b>utils</b> package in R comes with a series of functions vital in installing and managing packages. It's automatically installed and loaded in your R environment, ensuring the functions are ready for use. Among these functions, library() is particularly useful for accessing installed packages.

[code lang="R"]
# Displaying loaded packages with library()
library()

Umsebenzi womtapo wezincwadi (), uma usetshenziswa ngaphandle kwezimpikiswano, unikeza uhlu lwawo wonke amaphakheji okwamanje alayishwe endaweni ka-R. Kungumsebenzi owusizo ukuhlola ngokushesha ukuthi amaphakheji adingekayo ayafinyeleleka yini.

Sengiphetha, u-R unikeza ububanzi bemisebenzi ehlukahlukene ukuze kuhlu wonke amaphakheji afakiwe. Ukuqonda ukuthi uyisebenzisa kanjani le misebenzi kungathuthukisa kakhulu ukusebenza kahle kwakho nempumelelo ohlelweni lwe-R, okukuvumela ukuthi usebenzise ngokugcwele izinsiza eziningi ezitholakala endaweni yephakheji enwetshiwe.

Okuthunyelwe okuhlobene:

Shiya amazwana