Skip to content

Instantly share code, notes, and snippets.

View mrchypark's full-sized avatar

ChanYub Park mrchypark

View GitHub Profile
grade <-
as.data.frame(cbind(
ID = c(LETTERS[1:5]),
GPA = list('A+','F', c('C-','B','A+'), c('A','A+'), 'D')
))
unstack <- function(grade){
do.call(rbind, apply(grade, 1, function(x)
data.frame(ID = x$ID, GPA = x$GPA)))
}
library(shiny)
library(ggplot2)
library(gapminder)
library(dplyr)
ui <- fluidPage(
titlePanel("ggplot test"),
sidebarPanel(
function(input, output, session) {
# Combine the selected variables into a new data frame
selectedData <- reactive({
iris[, c(input$xcol, input$ycol)]
})
clusters <- reactive({
kmeans(selectedData(), input$clusters)
})
library(rvest)
library(stringr)
dat<-c()
for (i in 1:2005){
url<-paste0("http://www.bobaedream.co.kr/cyber/CyberCar.php?gubun=K&page=",i)
usedCar <- read_html(url)
title <-
usedCar %>%
html_nodes("td.carinfo a.title") %>%
library(googleCloudStorageR)
library(dplyr)
library(bigrquery)
library(dbplyr)
# 필요 데이터를 다운로드 받습니다.
# dabrp_classnote3 프로젝트 폴더일 때를 기준으로 했습니다.
chk<-file.info("./data/recomen/tran.csv")
if(is.na(chk$size)){
library(dplyr)
library(ggplot2)
# showtext는 윈도우에서 출력시 폰트 문제가 발생하는걸 고칠 수 있게 도와줍니다.
# https://github.com/yixuan/showtext
library(showtext)
font.add.google("Noto Sans")
# q1에서 차용했습니다. 유용한 코드 공유 감사합니다!
format.percent <- function(x) paste(floor(x),'%',se1p='')
@mrchypark
mrchypark / crawling_hikaku.R
Created August 23, 2017 07:52
crawling hikaku using r
library(rvest)
root<-"http://www.ts-hikaku.com/clist/a0/v1s22t0p"
tail<-".html"
options(stringsAsFactors = F)
dat<-c()
for(i in 1:34){
print(i)
tar<-read_html(paste0(root,i,tail))
company <-
# loading packages
library(dplyr)
library(tidyr)
library(igraph)
# set sample data set
options(stringsAsFactors = F)
exd<-data.frame(comp=sample(LETTERS),
partner1=sample(LETTERS),
install.packages("data.table")
library(data.table)
# 샘플 데이터를 만듬
testData <- data.frame(LET=sample(LETTERS,1000,replace = T),
NUM=sample(1:10,1000,replace = T),
stringsAsFactors = F)
# 데이터를 확인함
head(testData,100)
# 정렬된 데이터를 확인함