SlideShare une entreprise Scribd logo
1  sur  22
Télécharger pour lire hors ligne
Kan, Hao-Cheng
Lunghwa University of Science and Technology
http://kanchengzxdfgcv.blogspot.tw/
> as.numeric(TRUE)
> as.numeric(FALSE)
> as.character(TRUE)
> as.character(FALSE)
> as.factor(TRUE)
> as.factor(FALSE)
>
> k = "kan"
> class(k)
> as.character(k)
>
> n = 123
> class(n)
> as.numeric(n)
>
> test = as.numeric(k)
> test
> 1 == 1
> 1 < 1
> 1 <= 1
> 1 > 1
> 1 >= 1
> 1 != 1
> toCheck = 1
if (toCheck == 1)
{
print("hello")
}
if (toCheck == 0)
{
print("hello")
}
check.bool = function(x){
if (x == 1){
print("hello")
}else{
print("goodbye")
}
}
> check.bool(1)
> check.bool(0)
> check.bool("k")
> check.bool(TRUE)
check.bool = function(x){
if (x == 1){
print("hello")
} else if (x == 0){
print("goodbye")
} else{
print("confused")
}
}
> check.bool(1)
> check.bool(0)
> check.bool(2)
> check.bool("k")
use.switch = function(x){
switch(x,
"a"="first",
"b"="second",
"z"="last",
"c"="third",
"other")
}
> use.switch("a")
> use.switch("b")
> use.switch("c")
> use.switch("d")
> use.switch("OwO")
> use.switch("z")
> use.switch(1)
> use.switch(2)
> use.switch(3)
> use.switch(4)
> use.switch(5)
> use.switch(6)
> is.null(use.switch(6))
> ifelse(1 == 1, "Yes", "No")
> ifelse(1 == 0, "Yes", "No")
>
> toTest = c(1, 1, 0, 1, 0, 1)
> class(toTest)
> toTest
>
> ifelse(toTest == 1, "Yes", "No")
> ifelse(toTest == 1, toTest * 3, toTest)
> ifelse(toTest == 1, toTest * 3, "Zero")
>
> toTest[2] = NA
> class(toTest)
> toTest
>
> ifelse(toTest == 1, "Yes", "No")
> ifelse(toTest == 1, toTest * 3, toTest)
> ifelse(toTest == 1, toTest * 3, "Zero")
> a = c(1, 1, 0, 1)
> b = c(2, 1, 0, 1)
> bs = c(2, 1, 0, 1)
>
> ifelse(a == 1 & b == 1, "Yes", "No")
> ifelse(a == 1 && b == 1, "Yes", "No")
> ifelse(a == 1 && bs == 1, "Yes", "No")
ifelse(a == 1 & b == 1, "Yes", "No") ifelse(a == 1 && b == 1, "Yes", "No")
squfc = function(xsqu,ysqu){
if( xsqu <= 0 || ysqu <= 0|| is.na(xsqu) || is.na( ysqu) || is.character(xsqu) ||is.character(ysqu)){
print(NA)
}else{
squmatem = xsqu * ysqu
return(squmatem)
}
}
> squfc( 3, 4)
> squfc( 0, 4)
> squfc( 3, 0)
> squfc( 3, NA)
> squfc( NA, 4)
> squfc( 3, "Hi")
> squfc( "Hi", 4)
>
> ww = c(1,NA,3,4,5)
> qq = c(6,7,NA,9,10)
> squfc(ww,qq)
kan r_ifels
kan r_ifels
kan r_ifels

Contenu connexe

Similaire à kan r_ifels

«PyWat. А хорошо ли вы знаете Python?» Александр Швец, Marilyn System
«PyWat. А хорошо ли вы знаете Python?» Александр Швец, Marilyn System«PyWat. А хорошо ли вы знаете Python?» Александр Швец, Marilyn System
«PyWat. А хорошо ли вы знаете Python?» Александр Швец, Marilyn Systemit-people
 
Useful javascript
Useful javascriptUseful javascript
Useful javascriptLei Kang
 
Parse Everything With Elixir
Parse Everything With ElixirParse Everything With Elixir
Parse Everything With ElixirGabriele Lana
 
PostgreSQL10の新機能 ~ロジカルレプリケーションを中心に~
PostgreSQL10の新機能 ~ロジカルレプリケーションを中心に~PostgreSQL10の新機能 ~ロジカルレプリケーションを中心に~
PostgreSQL10の新機能 ~ロジカルレプリケーションを中心に~Atsushi Torikoshi
 
An introduction to property-based testing
An introduction to property-based testingAn introduction to property-based testing
An introduction to property-based testingVincent Pradeilles
 
An example of R code for Data visualization
An example of R code for Data visualizationAn example of R code for Data visualization
An example of R code for Data visualizationLiang (Leon) Zhou
 
Recurrent Networks and LSTM deep dive
Recurrent Networks and LSTM deep diveRecurrent Networks and LSTM deep dive
Recurrent Networks and LSTM deep diveAlex Kalinin
 
Ecuaciones dispositivos electronicos
Ecuaciones dispositivos electronicosEcuaciones dispositivos electronicos
Ecuaciones dispositivos electronicosfsdewr
 
Monadologie
MonadologieMonadologie
Monadologieleague
 
轻量级文本工具集
轻量级文本工具集轻量级文本工具集
轻量级文本工具集March Liu
 
A Course in Fuzzy Systems and Control Matlab Chapter Three
A Course in Fuzzy Systems and Control Matlab Chapter ThreeA Course in Fuzzy Systems and Control Matlab Chapter Three
A Course in Fuzzy Systems and Control Matlab Chapter ThreeChung Hua Universit
 
(How) can we benefit from adopting scala?
(How) can we benefit from adopting scala?(How) can we benefit from adopting scala?
(How) can we benefit from adopting scala?Tomasz Wrobel
 
PromptWorks Talk Tuesdays: Ray Zane 1/17/17 "Elixir Is Cool"
PromptWorks Talk Tuesdays: Ray Zane 1/17/17 "Elixir Is Cool"PromptWorks Talk Tuesdays: Ray Zane 1/17/17 "Elixir Is Cool"
PromptWorks Talk Tuesdays: Ray Zane 1/17/17 "Elixir Is Cool"PromptWorks
 
SparkSQLの構文解析
SparkSQLの構文解析SparkSQLの構文解析
SparkSQLの構文解析ゆり 井上
 
Diapositiva de Estudio: SolPrac2Am4.pptx
Diapositiva de Estudio:  SolPrac2Am4.pptxDiapositiva de Estudio:  SolPrac2Am4.pptx
Diapositiva de Estudio: SolPrac2Am4.pptxjorgejvc777
 

Similaire à kan r_ifels (20)

«PyWat. А хорошо ли вы знаете Python?» Александр Швец, Marilyn System
«PyWat. А хорошо ли вы знаете Python?» Александр Швец, Marilyn System«PyWat. А хорошо ли вы знаете Python?» Александр Швец, Marilyn System
«PyWat. А хорошо ли вы знаете Python?» Александр Швец, Marilyn System
 
Next Level Testing
Next Level TestingNext Level Testing
Next Level Testing
 
Scala Parallel Collections
Scala Parallel CollectionsScala Parallel Collections
Scala Parallel Collections
 
Useful javascript
Useful javascriptUseful javascript
Useful javascript
 
Chap 3php array part4
Chap 3php array part4Chap 3php array part4
Chap 3php array part4
 
Parse Everything With Elixir
Parse Everything With ElixirParse Everything With Elixir
Parse Everything With Elixir
 
PostgreSQL10の新機能 ~ロジカルレプリケーションを中心に~
PostgreSQL10の新機能 ~ロジカルレプリケーションを中心に~PostgreSQL10の新機能 ~ロジカルレプリケーションを中心に~
PostgreSQL10の新機能 ~ロジカルレプリケーションを中心に~
 
An introduction to property-based testing
An introduction to property-based testingAn introduction to property-based testing
An introduction to property-based testing
 
An example of R code for Data visualization
An example of R code for Data visualizationAn example of R code for Data visualization
An example of R code for Data visualization
 
Recurrent Networks and LSTM deep dive
Recurrent Networks and LSTM deep diveRecurrent Networks and LSTM deep dive
Recurrent Networks and LSTM deep dive
 
Ecuaciones dispositivos electronicos
Ecuaciones dispositivos electronicosEcuaciones dispositivos electronicos
Ecuaciones dispositivos electronicos
 
Monadologie
MonadologieMonadologie
Monadologie
 
轻量级文本工具集
轻量级文本工具集轻量级文本工具集
轻量级文本工具集
 
Meet scala
Meet scalaMeet scala
Meet scala
 
A Course in Fuzzy Systems and Control Matlab Chapter Three
A Course in Fuzzy Systems and Control Matlab Chapter ThreeA Course in Fuzzy Systems and Control Matlab Chapter Three
A Course in Fuzzy Systems and Control Matlab Chapter Three
 
(How) can we benefit from adopting scala?
(How) can we benefit from adopting scala?(How) can we benefit from adopting scala?
(How) can we benefit from adopting scala?
 
PromptWorks Talk Tuesdays: Ray Zane 1/17/17 "Elixir Is Cool"
PromptWorks Talk Tuesdays: Ray Zane 1/17/17 "Elixir Is Cool"PromptWorks Talk Tuesdays: Ray Zane 1/17/17 "Elixir Is Cool"
PromptWorks Talk Tuesdays: Ray Zane 1/17/17 "Elixir Is Cool"
 
Python Lecture 11
Python Lecture 11Python Lecture 11
Python Lecture 11
 
SparkSQLの構文解析
SparkSQLの構文解析SparkSQLの構文解析
SparkSQLの構文解析
 
Diapositiva de Estudio: SolPrac2Am4.pptx
Diapositiva de Estudio:  SolPrac2Am4.pptxDiapositiva de Estudio:  SolPrac2Am4.pptx
Diapositiva de Estudio: SolPrac2Am4.pptx
 

Dernier

Top profile Call Girls In Purnia [ 7014168258 ] Call Me For Genuine Models We...
Top profile Call Girls In Purnia [ 7014168258 ] Call Me For Genuine Models We...Top profile Call Girls In Purnia [ 7014168258 ] Call Me For Genuine Models We...
Top profile Call Girls In Purnia [ 7014168258 ] Call Me For Genuine Models We...nirzagarg
 
Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...ZurliaSoop
 
Gulbai Tekra * Cheap Call Girls In Ahmedabad Phone No 8005736733 Elite Escort...
Gulbai Tekra * Cheap Call Girls In Ahmedabad Phone No 8005736733 Elite Escort...Gulbai Tekra * Cheap Call Girls In Ahmedabad Phone No 8005736733 Elite Escort...
Gulbai Tekra * Cheap Call Girls In Ahmedabad Phone No 8005736733 Elite Escort...gragchanchal546
 
Top profile Call Girls In bhavnagar [ 7014168258 ] Call Me For Genuine Models...
Top profile Call Girls In bhavnagar [ 7014168258 ] Call Me For Genuine Models...Top profile Call Girls In bhavnagar [ 7014168258 ] Call Me For Genuine Models...
Top profile Call Girls In bhavnagar [ 7014168258 ] Call Me For Genuine Models...gajnagarg
 
DATA SUMMIT 24 Building Real-Time Pipelines With FLaNK
DATA SUMMIT 24  Building Real-Time Pipelines With FLaNKDATA SUMMIT 24  Building Real-Time Pipelines With FLaNK
DATA SUMMIT 24 Building Real-Time Pipelines With FLaNKTimothy Spann
 
Top profile Call Girls In Latur [ 7014168258 ] Call Me For Genuine Models We ...
Top profile Call Girls In Latur [ 7014168258 ] Call Me For Genuine Models We ...Top profile Call Girls In Latur [ 7014168258 ] Call Me For Genuine Models We ...
Top profile Call Girls In Latur [ 7014168258 ] Call Me For Genuine Models We ...gajnagarg
 
Predicting HDB Resale Prices - Conducting Linear Regression Analysis With Orange
Predicting HDB Resale Prices - Conducting Linear Regression Analysis With OrangePredicting HDB Resale Prices - Conducting Linear Regression Analysis With Orange
Predicting HDB Resale Prices - Conducting Linear Regression Analysis With OrangeThinkInnovation
 
+97470301568>>weed for sale in qatar ,weed for sale in dubai,weed for sale in...
+97470301568>>weed for sale in qatar ,weed for sale in dubai,weed for sale in...+97470301568>>weed for sale in qatar ,weed for sale in dubai,weed for sale in...
+97470301568>>weed for sale in qatar ,weed for sale in dubai,weed for sale in...Health
 
In Riyadh ((+919101817206)) Cytotec kit @ Abortion Pills Saudi Arabia
In Riyadh ((+919101817206)) Cytotec kit @ Abortion Pills Saudi ArabiaIn Riyadh ((+919101817206)) Cytotec kit @ Abortion Pills Saudi Arabia
In Riyadh ((+919101817206)) Cytotec kit @ Abortion Pills Saudi Arabiaahmedjiabur940
 
Reconciling Conflicting Data Curation Actions: Transparency Through Argument...
Reconciling Conflicting Data Curation Actions:  Transparency Through Argument...Reconciling Conflicting Data Curation Actions:  Transparency Through Argument...
Reconciling Conflicting Data Curation Actions: Transparency Through Argument...Bertram Ludäscher
 
Top profile Call Girls In Hapur [ 7014168258 ] Call Me For Genuine Models We ...
Top profile Call Girls In Hapur [ 7014168258 ] Call Me For Genuine Models We ...Top profile Call Girls In Hapur [ 7014168258 ] Call Me For Genuine Models We ...
Top profile Call Girls In Hapur [ 7014168258 ] Call Me For Genuine Models We ...nirzagarg
 
SAC 25 Final National, Regional & Local Angel Group Investing Insights 2024 0...
SAC 25 Final National, Regional & Local Angel Group Investing Insights 2024 0...SAC 25 Final National, Regional & Local Angel Group Investing Insights 2024 0...
SAC 25 Final National, Regional & Local Angel Group Investing Insights 2024 0...Elaine Werffeli
 
Nirala Nagar / Cheap Call Girls In Lucknow Phone No 9548273370 Elite Escort S...
Nirala Nagar / Cheap Call Girls In Lucknow Phone No 9548273370 Elite Escort S...Nirala Nagar / Cheap Call Girls In Lucknow Phone No 9548273370 Elite Escort S...
Nirala Nagar / Cheap Call Girls In Lucknow Phone No 9548273370 Elite Escort S...HyderabadDolls
 
Vadodara 💋 Call Girl 7737669865 Call Girls in Vadodara Escort service book now
Vadodara 💋 Call Girl 7737669865 Call Girls in Vadodara Escort service book nowVadodara 💋 Call Girl 7737669865 Call Girls in Vadodara Escort service book now
Vadodara 💋 Call Girl 7737669865 Call Girls in Vadodara Escort service book nowgargpaaro
 
Jodhpur Park | Call Girls in Kolkata Phone No 8005736733 Elite Escort Service...
Jodhpur Park | Call Girls in Kolkata Phone No 8005736733 Elite Escort Service...Jodhpur Park | Call Girls in Kolkata Phone No 8005736733 Elite Escort Service...
Jodhpur Park | Call Girls in Kolkata Phone No 8005736733 Elite Escort Service...HyderabadDolls
 
Top profile Call Girls In Vadodara [ 7014168258 ] Call Me For Genuine Models ...
Top profile Call Girls In Vadodara [ 7014168258 ] Call Me For Genuine Models ...Top profile Call Girls In Vadodara [ 7014168258 ] Call Me For Genuine Models ...
Top profile Call Girls In Vadodara [ 7014168258 ] Call Me For Genuine Models ...gajnagarg
 
Top profile Call Girls In Chandrapur [ 7014168258 ] Call Me For Genuine Model...
Top profile Call Girls In Chandrapur [ 7014168258 ] Call Me For Genuine Model...Top profile Call Girls In Chandrapur [ 7014168258 ] Call Me For Genuine Model...
Top profile Call Girls In Chandrapur [ 7014168258 ] Call Me For Genuine Model...gajnagarg
 
Sonagachi * best call girls in Kolkata | ₹,9500 Pay Cash 8005736733 Free Home...
Sonagachi * best call girls in Kolkata | ₹,9500 Pay Cash 8005736733 Free Home...Sonagachi * best call girls in Kolkata | ₹,9500 Pay Cash 8005736733 Free Home...
Sonagachi * best call girls in Kolkata | ₹,9500 Pay Cash 8005736733 Free Home...HyderabadDolls
 
Top Call Girls in Balaghat 9332606886Call Girls Advance Cash On Delivery Ser...
Top Call Girls in Balaghat  9332606886Call Girls Advance Cash On Delivery Ser...Top Call Girls in Balaghat  9332606886Call Girls Advance Cash On Delivery Ser...
Top Call Girls in Balaghat 9332606886Call Girls Advance Cash On Delivery Ser...kumargunjan9515
 
TrafficWave Generator Will Instantly drive targeted and engaging traffic back...
TrafficWave Generator Will Instantly drive targeted and engaging traffic back...TrafficWave Generator Will Instantly drive targeted and engaging traffic back...
TrafficWave Generator Will Instantly drive targeted and engaging traffic back...SOFTTECHHUB
 

Dernier (20)

Top profile Call Girls In Purnia [ 7014168258 ] Call Me For Genuine Models We...
Top profile Call Girls In Purnia [ 7014168258 ] Call Me For Genuine Models We...Top profile Call Girls In Purnia [ 7014168258 ] Call Me For Genuine Models We...
Top profile Call Girls In Purnia [ 7014168258 ] Call Me For Genuine Models We...
 
Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
Gulbai Tekra * Cheap Call Girls In Ahmedabad Phone No 8005736733 Elite Escort...
Gulbai Tekra * Cheap Call Girls In Ahmedabad Phone No 8005736733 Elite Escort...Gulbai Tekra * Cheap Call Girls In Ahmedabad Phone No 8005736733 Elite Escort...
Gulbai Tekra * Cheap Call Girls In Ahmedabad Phone No 8005736733 Elite Escort...
 
Top profile Call Girls In bhavnagar [ 7014168258 ] Call Me For Genuine Models...
Top profile Call Girls In bhavnagar [ 7014168258 ] Call Me For Genuine Models...Top profile Call Girls In bhavnagar [ 7014168258 ] Call Me For Genuine Models...
Top profile Call Girls In bhavnagar [ 7014168258 ] Call Me For Genuine Models...
 
DATA SUMMIT 24 Building Real-Time Pipelines With FLaNK
DATA SUMMIT 24  Building Real-Time Pipelines With FLaNKDATA SUMMIT 24  Building Real-Time Pipelines With FLaNK
DATA SUMMIT 24 Building Real-Time Pipelines With FLaNK
 
Top profile Call Girls In Latur [ 7014168258 ] Call Me For Genuine Models We ...
Top profile Call Girls In Latur [ 7014168258 ] Call Me For Genuine Models We ...Top profile Call Girls In Latur [ 7014168258 ] Call Me For Genuine Models We ...
Top profile Call Girls In Latur [ 7014168258 ] Call Me For Genuine Models We ...
 
Predicting HDB Resale Prices - Conducting Linear Regression Analysis With Orange
Predicting HDB Resale Prices - Conducting Linear Regression Analysis With OrangePredicting HDB Resale Prices - Conducting Linear Regression Analysis With Orange
Predicting HDB Resale Prices - Conducting Linear Regression Analysis With Orange
 
+97470301568>>weed for sale in qatar ,weed for sale in dubai,weed for sale in...
+97470301568>>weed for sale in qatar ,weed for sale in dubai,weed for sale in...+97470301568>>weed for sale in qatar ,weed for sale in dubai,weed for sale in...
+97470301568>>weed for sale in qatar ,weed for sale in dubai,weed for sale in...
 
In Riyadh ((+919101817206)) Cytotec kit @ Abortion Pills Saudi Arabia
In Riyadh ((+919101817206)) Cytotec kit @ Abortion Pills Saudi ArabiaIn Riyadh ((+919101817206)) Cytotec kit @ Abortion Pills Saudi Arabia
In Riyadh ((+919101817206)) Cytotec kit @ Abortion Pills Saudi Arabia
 
Reconciling Conflicting Data Curation Actions: Transparency Through Argument...
Reconciling Conflicting Data Curation Actions:  Transparency Through Argument...Reconciling Conflicting Data Curation Actions:  Transparency Through Argument...
Reconciling Conflicting Data Curation Actions: Transparency Through Argument...
 
Top profile Call Girls In Hapur [ 7014168258 ] Call Me For Genuine Models We ...
Top profile Call Girls In Hapur [ 7014168258 ] Call Me For Genuine Models We ...Top profile Call Girls In Hapur [ 7014168258 ] Call Me For Genuine Models We ...
Top profile Call Girls In Hapur [ 7014168258 ] Call Me For Genuine Models We ...
 
SAC 25 Final National, Regional & Local Angel Group Investing Insights 2024 0...
SAC 25 Final National, Regional & Local Angel Group Investing Insights 2024 0...SAC 25 Final National, Regional & Local Angel Group Investing Insights 2024 0...
SAC 25 Final National, Regional & Local Angel Group Investing Insights 2024 0...
 
Nirala Nagar / Cheap Call Girls In Lucknow Phone No 9548273370 Elite Escort S...
Nirala Nagar / Cheap Call Girls In Lucknow Phone No 9548273370 Elite Escort S...Nirala Nagar / Cheap Call Girls In Lucknow Phone No 9548273370 Elite Escort S...
Nirala Nagar / Cheap Call Girls In Lucknow Phone No 9548273370 Elite Escort S...
 
Vadodara 💋 Call Girl 7737669865 Call Girls in Vadodara Escort service book now
Vadodara 💋 Call Girl 7737669865 Call Girls in Vadodara Escort service book nowVadodara 💋 Call Girl 7737669865 Call Girls in Vadodara Escort service book now
Vadodara 💋 Call Girl 7737669865 Call Girls in Vadodara Escort service book now
 
Jodhpur Park | Call Girls in Kolkata Phone No 8005736733 Elite Escort Service...
Jodhpur Park | Call Girls in Kolkata Phone No 8005736733 Elite Escort Service...Jodhpur Park | Call Girls in Kolkata Phone No 8005736733 Elite Escort Service...
Jodhpur Park | Call Girls in Kolkata Phone No 8005736733 Elite Escort Service...
 
Top profile Call Girls In Vadodara [ 7014168258 ] Call Me For Genuine Models ...
Top profile Call Girls In Vadodara [ 7014168258 ] Call Me For Genuine Models ...Top profile Call Girls In Vadodara [ 7014168258 ] Call Me For Genuine Models ...
Top profile Call Girls In Vadodara [ 7014168258 ] Call Me For Genuine Models ...
 
Top profile Call Girls In Chandrapur [ 7014168258 ] Call Me For Genuine Model...
Top profile Call Girls In Chandrapur [ 7014168258 ] Call Me For Genuine Model...Top profile Call Girls In Chandrapur [ 7014168258 ] Call Me For Genuine Model...
Top profile Call Girls In Chandrapur [ 7014168258 ] Call Me For Genuine Model...
 
Sonagachi * best call girls in Kolkata | ₹,9500 Pay Cash 8005736733 Free Home...
Sonagachi * best call girls in Kolkata | ₹,9500 Pay Cash 8005736733 Free Home...Sonagachi * best call girls in Kolkata | ₹,9500 Pay Cash 8005736733 Free Home...
Sonagachi * best call girls in Kolkata | ₹,9500 Pay Cash 8005736733 Free Home...
 
Top Call Girls in Balaghat 9332606886Call Girls Advance Cash On Delivery Ser...
Top Call Girls in Balaghat  9332606886Call Girls Advance Cash On Delivery Ser...Top Call Girls in Balaghat  9332606886Call Girls Advance Cash On Delivery Ser...
Top Call Girls in Balaghat 9332606886Call Girls Advance Cash On Delivery Ser...
 
TrafficWave Generator Will Instantly drive targeted and engaging traffic back...
TrafficWave Generator Will Instantly drive targeted and engaging traffic back...TrafficWave Generator Will Instantly drive targeted and engaging traffic back...
TrafficWave Generator Will Instantly drive targeted and engaging traffic back...
 

kan r_ifels

  • 1.
  • 2. Kan, Hao-Cheng Lunghwa University of Science and Technology http://kanchengzxdfgcv.blogspot.tw/
  • 3.
  • 4.
  • 5.
  • 6. > as.numeric(TRUE) > as.numeric(FALSE) > as.character(TRUE) > as.character(FALSE) > as.factor(TRUE) > as.factor(FALSE) > > k = "kan" > class(k) > as.character(k) > > n = 123 > class(n) > as.numeric(n) > > test = as.numeric(k) > test
  • 7. > 1 == 1 > 1 < 1 > 1 <= 1 > 1 > 1 > 1 >= 1 > 1 != 1 > toCheck = 1 if (toCheck == 1) { print("hello") } if (toCheck == 0) { print("hello") }
  • 8. check.bool = function(x){ if (x == 1){ print("hello") }else{ print("goodbye") } } > check.bool(1) > check.bool(0) > check.bool("k") > check.bool(TRUE)
  • 9. check.bool = function(x){ if (x == 1){ print("hello") } else if (x == 0){ print("goodbye") } else{ print("confused") } } > check.bool(1) > check.bool(0) > check.bool(2) > check.bool("k")
  • 10.
  • 11. use.switch = function(x){ switch(x, "a"="first", "b"="second", "z"="last", "c"="third", "other") } > use.switch("a") > use.switch("b") > use.switch("c") > use.switch("d") > use.switch("OwO") > use.switch("z") > use.switch(1) > use.switch(2) > use.switch(3) > use.switch(4) > use.switch(5) > use.switch(6) > is.null(use.switch(6))
  • 12.
  • 13. > ifelse(1 == 1, "Yes", "No") > ifelse(1 == 0, "Yes", "No") > > toTest = c(1, 1, 0, 1, 0, 1) > class(toTest) > toTest > > ifelse(toTest == 1, "Yes", "No") > ifelse(toTest == 1, toTest * 3, toTest) > ifelse(toTest == 1, toTest * 3, "Zero") > > toTest[2] = NA > class(toTest) > toTest > > ifelse(toTest == 1, "Yes", "No") > ifelse(toTest == 1, toTest * 3, toTest) > ifelse(toTest == 1, toTest * 3, "Zero")
  • 14.
  • 15. > a = c(1, 1, 0, 1) > b = c(2, 1, 0, 1) > bs = c(2, 1, 0, 1) > > ifelse(a == 1 & b == 1, "Yes", "No") > ifelse(a == 1 && b == 1, "Yes", "No") > ifelse(a == 1 && bs == 1, "Yes", "No") ifelse(a == 1 & b == 1, "Yes", "No") ifelse(a == 1 && b == 1, "Yes", "No")
  • 16.
  • 17.
  • 18. squfc = function(xsqu,ysqu){ if( xsqu <= 0 || ysqu <= 0|| is.na(xsqu) || is.na( ysqu) || is.character(xsqu) ||is.character(ysqu)){ print(NA) }else{ squmatem = xsqu * ysqu return(squmatem) } }
  • 19. > squfc( 3, 4) > squfc( 0, 4) > squfc( 3, 0) > squfc( 3, NA) > squfc( NA, 4) > squfc( 3, "Hi") > squfc( "Hi", 4) > > ww = c(1,NA,3,4,5) > qq = c(6,7,NA,9,10) > squfc(ww,qq)