centos有趣软件包_这5个软件包使学习R变得有趣
centos有趣軟件包
Sometimes, it’s easy to get frustrated when learning programming. Perhaps you’ve been working on the same concept for an hour or two. Perhaps your progress is slow. Perhaps this is all happening at 6pm on a Friday in the middle of a global pandemic. I’ve been there, and I imagine I’m not alone.
有時(shí),在學(xué)習(xí)編程時(shí)很容易感到沮喪。 也許您已經(jīng)在同一個(gè)概念上研究了一兩個(gè)小時(shí)。 也許您的進(jìn)度很慢。 也許這一切都是在全球大流行期間的星期五下午6點(diǎn)發(fā)生的。 我去過(guò)那里,我想我并不孤單。
Thankfully for R programmers, there are packages that help bring joy back into the learning process. What’s?more, they’re easy to understand and can make amusing additions to recreational projects.
值得慶幸的是,對(duì)于R程序員,有一些軟件包可以使學(xué)習(xí)過(guò)程重新獲得歡樂(lè)。 而且,它們很容易理解,并且可以為娛樂(lè)項(xiàng)目添加有趣的內(nèi)容。
Below, I’ve put together five of my favourite ‘just for fun’ R packages. Each example is very beginner friendly, though make sure you install each package before running the example?code. You can do this by running the function install.packages("packagenamehere") for each example, changing the package name to one of those listed below.
下面,我整理了五個(gè)我最喜歡的“只是為了娛樂(lè)” R程序包。 每個(gè)示例對(duì)初學(xué)者都非常友好,但是請(qǐng)確保在運(yùn)行示例代碼之前先安裝每個(gè)軟件包。 您可以通過(guò)為每個(gè)示例運(yùn)行功能install.packages("packagenamehere")并將包名稱更改為以下所列名稱之一來(lái)完成此操作。
1.蜂 (1. beepr)
The ‘beepr’ package contains only one function: beep. This plays a sound when called, and comes loaded with some fun notifications. If you ever wanted to to hear a Wilhelm scream or the ‘get item’ sound from the Legend of Zelda in the middle of a script, this is the package for you. It’ll also play sound from a .wav file from the internet if you give it a valid URL. Just call beep with a number or valid URL as an argument, and it’ll play a corresponding sound.
“ beepr ”軟件包僅包含一個(gè)功能: beep 。 調(diào)用時(shí)會(huì)播放聲音,并附帶一些有趣的通知。 如果您想在腳本中間聽(tīng)到《塞爾達(dá)傳說(shuō)》中的威廉尖叫聲或“獲取物品”的聲音,那么此包適合您。 如果您給它提供有效的URL,它還將從Internet的.wav文件中播放聲音。 只需使用數(shù)字或有效URL作為參數(shù)調(diào)用beep ,它就會(huì)播放相應(yīng)的聲音。
library(beepr)# Play Zelda treasure notificationbeep(5)
# Play Wilhelm scream
beep(9)
Unlike some of the other packages I mention below, beepr can actually be quite useful in serious work. While running code that takes a long time to execute, I often work on something else while waiting for it to finish. Calling beep at the end of my script signals that my long process is done. It’s pretty satisfying to hear some 8-bit fanfare at the end of a long analysis or simulation.
與下面提到的其他一些軟件包不同,beepr實(shí)際上在認(rèn)真的工作中會(huì)非常有用。 在運(yùn)行需要很長(zhǎng)時(shí)間才能執(zhí)行的代碼時(shí),我經(jīng)常在等待代碼完成的同時(shí)進(jìn)行其他工作。 在腳本末尾調(diào)用beep表示我的長(zhǎng)過(guò)程已經(jīng)完成。 在長(zhǎng)時(shí)間的分析或模擬結(jié)束時(shí)聽(tīng)到一些8位夸張的聲音,這真是令人滿足。
2.好玩 (2. fun)
The aptly named ‘fun’ package is a collection of miscellaneous functions and games. If you ever needed another vehicle for procrastination, you’ve got one in this package. Notable inclusions are a neat version of minesweeper that runs in an R window, as well as other games like a sliding puzzle, and ‘5 in a row’. Running these games is easy, only requires the code below. After loading the package, the conditional statement opens the right interactive graphics device based on your operating system. You can then start any game from the package (such as the sliding puzzle) by calling its function.
恰當(dāng)?shù)孛麨椤?fun ”包是各種功能和游戲的集合。 如果您需要另一種拖延工具,則可以在此工具包中找到。 值得一提的內(nèi)容是在R窗口中運(yùn)行的minesweeper的簡(jiǎn)潔版本,以及其他游戲,例如滑動(dòng)拼圖和“連續(xù)5個(gè)”。 運(yùn)行這些游戲很容易,只需要下面的代碼。 加載軟件包后,條件語(yǔ)句將根據(jù)您的操作系統(tǒng)打開(kāi)正確的交互式圖形設(shè)備。 然后,您可以通過(guò)調(diào)用包的功能來(lái)從包中啟動(dòng)任何游戲(例如滑動(dòng)拼圖)。
library(fun)# Open the right interactive graphics deviceif (.Platform$OS.type == "windows") {
x11()
} else {
x11(type = "Xlib")
}# Start game of choice (sliding puzzle)
fun::sliding_puzzle()
This package also contains some other miscellaneous features and demos. Ever wanted to draw a turtle in R? Test for Alzheimer’s disease? Shut down your operating system? These are all things you can do with ‘fun’. While bricking your OS might not result in laughter, the many other amusing games and distractions in this package are good fun.
該軟件包還包含其他一些雜項(xiàng)功能和演示。 是否曾經(jīng)想在R中畫一只烏龜? 測(cè)試阿爾茨海默氏病? 關(guān)閉操作系統(tǒng)? 這些就是您可以通過(guò)“有趣”做的所有事情。 雖然使操作系統(tǒng)變磚可能不會(huì)引起歡笑,但此程序包中的許多其他有趣的游戲和令人分心的游戲都很好玩。
3.命運(yùn) (3. fortunes)
‘fortunes’ is another package with a sole function; fortune. When called with no arguments, it spits out random nuggets of humour and wisdom from the R-help forums, and other R related sites. To receive a more specific fortune, you can add a string argument to the function call (fortune("divide") for example). This frequently results in some amusing outputs, with one of my favourites below:
“ fortunes ”是另一個(gè)具有唯一功能的軟件包; fortune 。 當(dāng)不加任何參數(shù)地被調(diào)用時(shí),它會(huì)從R-help論壇和其他與R相關(guān)的站點(diǎn)中隨機(jī)散發(fā)出幽默和智慧。 要獲得更具體的財(cái)富,您可以在函數(shù)調(diào)用中添加一個(gè)字符串參數(shù)(例如fortune("divide") )。 這經(jīng)常導(dǎo)致一些有趣的輸出,下面是我的最愛(ài)之一:
Corinna Schmitt: How can I divide the number 0.285 with 2. I need a function. Result: 0.285 / 2 = 0.1425Gabor Csardi: Well, i think half.of.0.285 <- function() { 0.1425 }would do the trick. -- Corinna Schmitt and Gabor Csardi R-help (April 2007)
Corinna Schmitt:如何將數(shù)字0.285除以2。我需要一個(gè)函數(shù)。 結(jié)果:0.285 / 2 = 0.1425Gabor Csardi:嗯,我認(rèn)為0.285 <-function(){0.1425}的一半會(huì)解決問(wèn)題。 -Corinna Schmitt和Gabor Csardi R-help(2007年4月)
As an added learning?incentive, many quotes get funnier as you find out more about R and its community. But whatever your skill level, fortunes’ selection of humourous asides make for a fun distraction from whatever you’re meant to be doing instead.
作為額外的學(xué)習(xí)動(dòng)機(jī),當(dāng)您進(jìn)一步了解R及其社區(qū)時(shí),許多引號(hào)會(huì)變得更有趣。 但是,無(wú)論您的技術(shù)水平如何,財(cái)富中選擇的幽默助手都會(huì)使您分心,而這本來(lái)就是要做什么的。
4. Cowsay (4. cowsay)
A neat package that adds character to text output in the console, ‘cowsay’ lets you print messages that are ‘spoken’ by animals drawn in ASCII characters. Want to soften the blow of a warning message? Make a cat say it with the code below.
一個(gè)很好的程序包,它在控制臺(tái)的文本輸出中添加了字符,“ cowsay ”使您可以打印被ASCII字符繪制的動(dòng)物“說(shuō)出”的消息。 想要減輕警告消息的打擊嗎? 用下面的代碼讓貓說(shuō)出來(lái)。
say(what = "Cannot index object of type 'cat food'.", by = "cat", type = "warning")A very cute warning message.一個(gè)非常可愛(ài)的警告消息。The say function can also handle messages that aren’t defined as warnings, and defaults to printing normal text. It also integrates with the ‘fortunes’ package; when running say(what = "fortune"), a random fortune will be spoken by an animal. Because everyone wants to see a duck lament the stupidity of R users.
say函數(shù)還可以處理未定義為警告的消息,默認(rèn)情況下為打印普通文本。 它還與“財(cái)富”軟件包集成在一起; 當(dāng)運(yùn)行say(what = "fortune") ,動(dòng)物會(huì)說(shuō)出隨機(jī)的運(yùn)氣。 因?yàn)槊總€(gè)人都希望看到鴨子對(duì)R用戶的愚蠢感嘆。
5.好評(píng) (5. praise)
Finally, it’s just nice to receive a compliment sometimes. The ‘praise’ package facilitates this by generating random praise, allowing you to receive fresh encouragement with each call. Calling praise while specifying parts of speech to dynamically generate with the ${} syntax yields statements like the following:
最后,有時(shí)候會(huì)受到稱贊是很好的。 “ 稱贊 ”包通過(guò)產(chǎn)生隨機(jī)稱贊來(lái)促進(jìn)這一點(diǎn),使您在每次通話時(shí)都能得到新鮮的鼓勵(lì)。 在指定詞性以使用${}語(yǔ)法動(dòng)態(tài)生成時(shí)調(diào)用praise會(huì)產(chǎn)生如下語(yǔ)句:
praise("${Exclamation}! Kind reader, you're ${adjective}!")Some kind output.某種輸出。In my example, I capitalised my exclamation, while leaving my adjective in lowercase for grammatical purposes. Dynamically generated phrases can be entirely capitalised for some extra enthusiasm (${EXCLAMATION} , for instance). While I can’t see this gaining traction in many serious production-level scripts, sometimes it’s nice to praise your own efforts. Learned a new analysis today? Sensational work, champ.
在我的示例中,我大寫了感嘆號(hào),同時(shí)出于語(yǔ)法目的將形容詞小寫。 動(dòng)態(tài)生成的短語(yǔ)可以完全大寫,以獲得一些額外的熱情(例如${EXCLAMATION} )。 盡管我看不到在許多嚴(yán)肅的生產(chǎn)級(jí)腳本中如此吸引人,但有時(shí)還是值得稱贊您自己的努力。 今天學(xué)會(huì)了新的分析方法? 聳人聽(tīng)聞的工作,冠軍。
In our current economic climate, people are mainly learning programming for career development. The concern of the hour is learning techniques that secure jobs, not building projects that bring joy. I don’t think this is completely unreasonable either. After all, most R programmers don’t get paid to make ASCII animals talk to users. They get paid to analyse data.
在當(dāng)前的經(jīng)濟(jì)形勢(shì)下,人們主要是學(xué)習(xí)編程以發(fā)展職業(yè)。 時(shí)間的關(guān)注點(diǎn)是學(xué)習(xí)技術(shù)可以確保工作安全,而不是構(gòu)建能夠帶來(lái)歡樂(lè)的項(xiàng)目。 我也不認(rèn)為這完全是不合理的。 畢竟,大多數(shù)R程序員并沒(méi)有獲得使ASCII動(dòng)物與用戶交談的報(bào)酬。 他們得到報(bào)酬來(lái)分析數(shù)據(jù)。
That said, I like these packages because they reaffirm why I was drawn to programming in the first place. It’s fun, and lets me make?interesting?things. When I first started learning to code, I wasn’t gunning for a high powered job. I was?excited?to?create?fun?small?scale?projects?that?applied?my?new?skills. Even though?I?enjoy?writing code?in?my?career nowadays, it’s nice to get back in touch with that feeling once in a while.
就是說(shuō),我喜歡這些軟件包,因?yàn)樗鼈冎厣炅藶槭裁次乙婚_(kāi)始就被編程所吸引。 很好玩,讓我做有趣的事情。 當(dāng)我剛開(kāi)始學(xué)習(xí)編碼時(shí),我并不是在追求高能力的工作。 我很高興創(chuàng)建有趣的小規(guī)模項(xiàng)目,這些項(xiàng)目運(yùn)用了我的新技能。 即使我現(xiàn)在喜歡在職業(yè)生涯中編寫代碼,但偶爾與這種感覺(jué)重新聯(lián)系還是很高興的。
So, in the spirit of fun: say(praise("Thanks for reading, and have fun ${creating} your own ${adjective} R code!"))
因此,本著樂(lè)趣的精神: say(praise("Thanks for reading, and have fun ${creating} your own ${adjective} R code!"))
翻譯自: https://towardsdatascience.com/make-learning-r-fun-with-these-5-packages-3c3f6ca82c96
centos有趣軟件包
總結(jié)
以上是生活随笔為你收集整理的centos有趣软件包_这5个软件包使学习R变得有趣的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: VAIO 发布深红色版 SX12/14
- 下一篇: 求解决方法_解决方法