Tapply ua haujlwm li cas hauv R?
Tapply ua haujlwm li cas hauv R?

Video: Tapply ua haujlwm li cas hauv R?

Video: Tapply ua haujlwm li cas hauv R?
Video: Zom hniav thaum caij tsaug zog yuav ua li cas ? 2024, Kaum ib hlis
Anonim

tapply () suav ib qho kev ntsuas (txhais tau tias, nruab nrab, min, max, thiab lwm yam..) lossis ua haujlwm rau txhua qhov sib txawv hauv vector. Nws yog ib qho tseem ceeb muaj nuj nqi uas cia koj tsim ib tug subset ntawm ib vector thiab ces siv ib co zog rau txhua lub subset.

Ib yam li ntawd, nws raug nug, Lapply ua haujlwm li cas hauv R?

lapply muaj nuj nqi yog siv rau kev khiav hauj lwm ntawm cov npe khoom thiab xa rov qab ib daim ntawv teev cov khoom ntawm tib qhov ntev ntawm thawj txheej. lapply ua haujlwm hauv R , rov qab ib daim ntawv teev npe ntawm qhov ntev tib yam li cov khoom siv hauv cov npe khoom, txhua lub ntsiab lus uas yog qhov tshwm sim ntawm kev siv FUN rau cov khoom sib thooj ntawm cov npe.

Tsis tas li ntawd, Mapply yog dab tsi? daim ntawv qhia yog ib tug multivariate version ntawm sapply . daim ntawv qhia siv kev lom zem rau thawj lub ntsiab lus ntawm txhua… kev sib cav, lub ntsiab lus thib ob, lub ntsiab lus thib peb, thiab lwm yam. Cov lus sib cav yuav rov siv dua yog tias tsim nyog.

Kuj kom paub, qhov txawv ntawm Lapply thiab Sapply hauv R yog dab tsi?

Main qhov sib txawv ntawm lapply thiab sapply yog tias sapply yuav sim simplify ntau npaum li nws ua tau cov zis ntawm lapply . Yog tias koj lub luag haujlwm rov qab ib tus nqi rau txhua lub caij ntawm daim ntawv teev npe sapply yuav rov vector nrog cov txiaj ntsig, piv txwv li. pab tau thaum koj xav tshawb xyuas qhov ntev ntawm cov npe khoom.

r cov ntsiab lus yog dab tsi?

R cov ntsiab lus Muaj nuj nqi. Cov ntsiab lus () muaj nuj nqi yog ib tug generic muaj nuj nqi siv los tsim cov ntsiab lus ntawm cov ntsiab lus ntawm ntau yam qauv haum functions. Lub luag haujlwm hu rau cov txheej txheem tshwj xeeb uas nyob ntawm chav kawm ntawm thawj qhov kev sib cav.

Pom zoo: