MLDM_RBasic
R Basic Tutorial for MLDM Monday.
R Basic Tutorial for MLDM Monday.
如題,避免現場一陣忙亂XD
忘了寫 t() .....
mtcars %>%
ggvis(x = ~wt, y = ~mpg) %>%
layer_smooths(se=TRUE, opacity := 0.5, opacity.hover := 0.75) %>%
layer_points(fill = ~factor(cyl), size := 50, size.hover := 200) %>%
set_options(hover_duration = 250)
Error: could not find function "%>%"
Error: unexpected SPECIAL in "%>%"
在windows 7
tmp <- read.table('cl_info_other.csv', sep = ',',stringsAsFactors = F, header = T, nrows = 1000)
Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings, :
line 1 did not have 14 elements
可用read.csv
希望可以有產生magic vector的code chunk
1.45284450 ,-0.04625854 vs 1.45284450, -0.04625854
as title
第二行是多餘的,還是數字?
畫不出來 冏
rm(list = ls())
set.seed(3690)
p = matrix(c(0, 0), ncol = 1)
coord = rbind(data.frame(), t(p))
for () {
# 從 uniform(0, 1) 中抽取 indicator 決定當次遞迴式。
indicator = runif(1, 0, 1)
# 根據抽樣結果決定遞迴式。
if (indicator <= 0.05) {
m = __________
const = matrix(c(0, 0), ncol = 1)
} else if () {
m = matrix(c(0.85, -0.04, 0.04, 0.85), nrow = 2, ncol = 2)
const = ______
} else if (____) {
m = ______
const = ______
} else {
m = ______
const = ______
}
# 計算新的 p 坐標值。
p = _______
# 將新的 p 點坐標合併至 coord 中。
coord = _______
}
plot(x = coord[, 2], y = coord[, 1], plt = c(0, 10, -5, 5), cex = 0.1, asp = 1)
很酷
建議將
sample.int(5, 1) # 從 15 中隨機抽取 1 個數字。5 中隨機抽取 1 個正整數。
修改為
sample.int(5, 1) # 從 1
Template 可以放到https://gist.github.com/, 然後用iframe improt進來
如題。
建議加入str函數 說明my_data變數的class
battleship <- function(num_guess){
ship_x <- _____
ship_y <- _____
map =list(c('O', 'O', 'O', 'O', 'O'),
c('O', 'O', 'O', 'O', 'O'),
c('O', 'O', 'O', 'O', 'O'),
c('O', 'O', 'O', 'O', 'O'),
c('O', 'O', 'O', 'O', 'O'))
for (row in map){
______
}
trial <- 0
while (){
# 玩家選定坐標 x 與 y 。
x <- as.numeric(readline('Guess the x:'))
y <- as.numeric(readline('Guess the y:'))
# 根據玩家選定之 x 與 y 更新 map。
map[[**]][**] <- 'X'
# 繪製地圖。
for (){
print(row)
}
# 根據玩家猜測的結果,顯示適當資訊與更新相關變數。
if (________){
cat('Oh NO~~~You shrink my boat!!')
break
} else{
cat('You miss.')
trial <- ____
}
# 當玩家用完所有機會,顯示遊戲結束的訊息與電腦的 x 與 y 坐標。
if (_______){
cat('You loss.\n')
cat("The battleship's x-coordinate is", ship_x, '\n')
cat("The battleship's y-coordinate is", ship_y, '\n')
}
}
}
ALSA lib pcm_dmix.c:1018:(snd_pcm_dmix_open) unable to open slave
ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
ALSA lib audio/pcm_bluetooth.c:1614:(audioservice_expect) BT_GET_CAPABILITIES failed : Input/output error(5)
ALSA lib audio/pcm_bluetooth.c:1614:(audioservice_expect) BT_GET_CAPABILITIES failed : Input/output error(5)
ALSA lib audio/pcm_bluetooth.c:1614:(audioservice_expect) BT_GET_CAPABILITIES failed : Input/output error(5)
ALSA lib audio/pcm_bluetooth.c:1614:(audioservice_expect) BT_GET_CAPABILITIES failed : Input/output error(5)
ALSA lib pcm_dmix.c:957:(snd_pcm_dmix_open) The dmix plugin supports only playback stream
ALSA lib pcm_dmix.c:1018:(snd_pcm_dmix_open) unable to open slave
Cannot connect to server socket err = No such file or directory
Cannot connect to server socket
jack server is not running or cannot be started
ALSA lib pcm_dmix.c:1018:(snd_pcm_dmix_open) unable to open slave
ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
ALSA lib audio/pcm_bluetooth.c:1614:(audioservice_expect) BT_GET_CAPABILITIES failed : Input/output error(5)
ALSA lib audio/pcm_bluetooth.c:1614:(audioservice_expect) BT_GET_CAPABILITIES failed : Input/output error(5)
ALSA lib audio/pcm_bluetooth.c:1614:(audioservice_expect) BT_GET_CAPABILITIES failed : Input/output error(5)
ALSA lib audio/pcm_bluetooth.c:1614:(audioservice_expect) BT_GET_CAPABILITIES failed : Input/output error(5)
ALSA lib pcm_dmix.c:957:(snd_pcm_dmix_open) The dmix plugin supports only playback stream
ALSA lib pcm_dmix.c:1018:(snd_pcm_dmix_open) unable to open slave
Cannot connect to server socket err = No such file or directory
Cannot connect to server socket
jack server is not running or cannot be started
希望標題能增加 (1/2) (2/2)
OS: Windows 8.1
P.147
path <- DSC2014Tutorial::Basic_file("barnsley_fern_template.R")
utils::browseURL(path)
P.149
path <- DSC2014Tutorial::Basic_file("barnsley_fern_answer.R")
utils::browseURL(path)
P.159
path <- DSC2014Tutorial::Basic_file("battleship_template.R")
utils::browseURL(path)
template 檔中文註解顯示亂碼。
[win8] cl_info_other.csv 要改成 cl_info_other_windows.csv 才讀的了
while (trial < num_guess){
x <- as.numeric(readline('Guess the x:'))
y <- as.numeric(readline('Guess the y:'))
if (x <= 5 && y <= 5 && x > 0 && y > 0){
map[[y]][x] <- 'X'
for (r in map){
print(r)
}
if (x == ship_x & y == ship_y){
cat('Oh NO~~~You shrink my boat!!')
break
} else{
cat('You miss.')
trial <- trial + 1
}
下面少兩個括號
用 utils::browseURL 使用預設瀏覽器打開 .R 檔案
少了三個 "}"
如題! 謝謝大大!
for (i in 1:5){
system("say 'Nann Moll Ah Mi Tow Fo'")
system("say 'Ah Men'")
}
for (i in 1:5){
system("espeak 'Nann Moll Ah Mi Tow Fo'")
system("espeak 'Ah Men'")
}
Add intro to factor() and data.frame()
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.