This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// from string to int in swift | |
let intString: String = "256" | |
let stringInt: Int? = Int(intString) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var swift_string = "lorem ipsum dolor sit amet" | |
// from String to NSData | |
let data = swift_string.dataUsingEncoding(NSUTF8StringEncoding) | |
print(data) | |
// from NSData to String | |
var out: String = String(data:data!, encoding:NSUTF8StringEncoding)! | |
print(out) // print "lorem ipsum dolor sit amet" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let string = "나는 전설이다." | |
print(string.characters.count) | |
let newString = "I Am Legend." | |
print(newString.characters.count) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 아래 코드는 swift 2.0에서 현재 시간에 하루를 더하는 것을 보여주고 있습니다. | |
let now = NSDate() // 현재 시간 정보를 넣습니다. | |
let comp = NSDateComponents() // 하루를 더하기 위해서 NSDateComponents를 하나 만듭니다. | |
comp.setValue(1, forKey: "day") // 위에서 만든 곳에 1일을 넣습니다. forKey를 바꾸면 다른 것도 넣을 수 있습니다. | |
let myCal = NSCalendar.init(calendarIdentifier: NSCalendarIdentifierGregorian) // 하루를 더해서 넣을 NSCalendar를 하나 만듭니다. | |
let tomorrow = myCal!.dateByAddingComponents(comp, toDate: now, options: NSCalendarOptions(rawValue: 0)) // 위에서 만든 현재 시간인 now에 myCal을 이용하여 하루를 더해서 tomorrow에 넣습니다. |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> A <- c("apple", "fineApple") | |
> A | |
[1] "apple" "fineApple" | |
> B <- c(100 ,200) | |
> testing <- data.frame(A,B) | |
> testing | |
A B | |
1 apple 100 | |
2 fineApple 200 | |
> library(plyr) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mpg <- seq(10,40) | |
kmL <- (mpg * 1.609344)/3.785411784 ## 단순하게 바꾸기 | |
install.packages("datamart") ## 패키지 설치 | |
library(datamart) ## 패키지 설치 | |
uconv(1, "US gal", "l", uset="Volume") ## 1 캘런을 리터로 | |
uconv(1, "mile", "km", uset="Length") ## 1 마일을 킬로미터로 | |
kmL.uconv <- uconv(mpg, "mile", "km", uset="Length")/uconv(1, "US gal", "l", uset="Volume") ## uconv()을 이용하여 바꾸기 | |
kmL == kmL.uconv ## 두 계산 결과 확인 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
title: "R Notebook" | |
output: | |
pdf_document: | |
latex_engine: xelatex | |
html_notebook: default | |
html_document: default | |
mainfont: NanumGothic | |
--- | |
이것은 [R Markdown](http://rmarkdown.rstudio.com) 노트북입니다. | |
This is an [R Markdown](http://rmarkdown.rstudio.com) Notebook. When you execute code within the notebook, the results appear beneath the code. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fitted(Pregnancy.lm) | |
ifelse (fitted(Pregnancy.lm) > 0.5, 1, 0) == PregnancyData$PREGNANT | |
맞나요 <- ifelse (fitted(Pregnancy.lm) > 0.5, 1, 0) == PregnancyData$PREGNANT | |
sum(맞나요)sum(맞나요)/NROW(맞나요) |
OlderNewer