Uyigcina njani imizobo kwiFayile yeFayile kwiR

NguAndrie de Vries, uJoris Meys

Ukuba ufuna ukupapasha iziphumo zakho, kuya kufuneka ugcine isiza sakho kwifayile eku-R kwaye ungenise le fayile yemizobo kwelinye uxwebhu. Uninzi lwexesha nangona kunjalo, unokufuna ukusebenzisa iigraphic R ngendlela yokunxibelelana ukuphonononga idatha yakho.



Ukugcina iyelenqe kwifayile yomfanekiso, kuya kufuneka wenze izinto ezintathu ngokulandelelana:



  1. Vula isixhobo semizobo.

    linzess idosi kabini ngemini

    Isixhobo esingagqibekanga kwimizobo R siscreen sekhompyuter yakho. Ukugcina iyelenqe kwifayile yomfanekiso, kufuneka uxelele u-R ukuba avule uhlobo lwesixhobo- kule meko, ifayile yemizobo yohlobo oluthile, njengePNG, iPDF, okanye iJPG.



    Umsebenzi R wokwenza isixhobo sePNG nguImibala ye-png (). Ngokufanayo, wenza isixhobo sePDF ngeUXwebhu ()kunye nesixhobo seJPGjpg ().

  2. Yenza umxholo.

  3. Vala isixhobo semizobo.



    Ukwenza oku ngedev.off ()umsebenzi.

Beka oku ekusebenzeni ngokugcina iyelenqe leuthembekilekwifolda yekhaya kwikhompyuter yakho. Kuqala setha isikhombisi esisebenzayo kwifolda yakho yasekhaya (okanye nakweyiphi na incwadi oyithandayo). Ukuba usebenzisa iLinux, uya kube uqhelene nokusebenzisa~ /njengendlela emfutshane kwifolda yakho yasekhaya, kodwa oku kuyasebenza kwiWindows nakwiMac:

> setwd('~/') > getwd() [1] 'C:/Users/Andrie'

Emva koko, bhala imigca emithathu yekhowudi ukugcina iyelenqe lokufaka kwifayile:

> png(filename='faithful.png') > plot(faithful) > dev.off()

Ngoku ungajonga inkqubo yakho yefayile ukuze ubone ukuba ngaba le fayileethembekileyo.pngikhona. (Kufanele!) Iziphumo zefayile yemizobo yohlobo lwePNG ongayifaka kwintetho, uxwebhu, okanye iwebhusayithi.