Skip to content

Instantly share code, notes, and snippets.

View Leo-Lee15's full-sized avatar
😁
Busy!

Leo Lee Leo-Lee15

😁
Busy!
  • China
View GitHub Profile
@Leo-Lee15
Leo-Lee15 / example.R
Created July 4, 2020 00:55 — forked from timelyportfolio/example.R
cell in rhansontable trigger modal with additional information
library(shiny)
library(htmltools)
library(rhandsontable)
library(dplyr)
rht <- rhandsontable(
head(mtcars) %>%
mutate(name = rownames(.)) %>%
select(name, everything()),
rowHeaders = NULL
@Leo-Lee15
Leo-Lee15 / r-to-python-data-wrangling-basics.md
Created February 23, 2020 14:15 — forked from conormm/r-to-python-data-wrangling-basics.md
R to Python: Data wrangling with dplyr and pandas

R to python data wrangling snippets

The dplyr package in R makes data wrangling significantly easier. The beauty of dplyr is that, by design, the options available are limited. Specifically, a set of key verbs form the core of the package. Using these verbs you can solve a wide range of data problems effectively in a shorter timeframe. Whilse transitioning to Python I have greatly missed the ease with which I can think through and solve problems using dplyr in R. The purpose of this document is to demonstrate how to execute the key dplyr verbs when manipulating data using Python (with the pandas package).

dplyr is organised around six key verbs:

@Leo-Lee15
Leo-Lee15 / ortho_example.R
Created October 7, 2019 23:29 — forked from tylermorganwall/ortho_example.R
rayrender orthographic projection example
library(rayrender)
#Create base scene
basescene = xz_rect(x=555/2,y=0.1,z=555/2,555,555,
material = lambertian(color="#bababa", checkercolor = "grey10", checkerperiod = 100)) %>%
add_object(xz_rect(x=555/2,y=1000,z=555/2,343,332,
material = lambertian(color="white", lightintensity=40,implicit_sample = TRUE),
flipped=TRUE))
#Function for sphere bouncing
titanic_1tree = h2o.gbm(x = predictors, y = response,
training_frame = titanicHex,
ntrees = 1, min_rows = 1, sample_rate = 1, col_sample_rate = 1,
max_depth = 5,
# use early stopping once the validation AUC doesn't improve by at least 0.01%
# for 5 consecutive scoring events
stopping_rounds = 3, stopping_tolerance = 0.01,
stopping_metric = "AUC",
seed = 1)
@Leo-Lee15
Leo-Lee15 / dplyr5000.md
Created October 13, 2018 00:41 — forked from cecilesauder/dplyr5000.md
ggplot for people who made more than 40 #dplyr travis builds
#devtools::install_github("r-lib/gh")
library(gh)
#devtools::install_github("romainfrancois/dplyr5000")
library(dplyr5000)
library(tidyverse)
library(grid) 
library(magick)
#> Linking to ImageMagick 6.9.7.4
#> Enabled features: fontconfig, freetype, fftw, lcms, pango, x11
@Leo-Lee15
Leo-Lee15 / Linux_R_execution.bash
Created January 18, 2018 12:26
在Linux系统(centOS 7.4)下执行R代码以及脚本
Rscript -e 'print("us")' # 执行`print("us")`这一行R代码
Rscript test_R.R # 执行`test_R.R`脚本
## library(stringr)
## xx <- c("we are", "There are", "All are")
## str_replace_all(xx, pattern = "are", replacement = "是")
@Leo-Lee15
Leo-Lee15 / fst_test.R
Created January 18, 2018 05:32
code used to test the `fst` and `fstplyr` packages
library(fstplyr)
path <- tempfile()
dir.create(path)
fst::write_fst(iris, file.path(path, "iris.fst"))
fst::write_fst(mtcars, file.path(path, "mtcars.fst"))
# usage of the file.path() function
file.path("C:/Users/Lenovo/Documents", "mtcars.xlsx")
# results: "C:/Users/Lenovo/Documents/mtcars.xlsx"
# create a big tibble, about 2GB
# based on a article from here https://dirkschumacher.github.io/ompr/articles/problem-graph-coloring.html
library(maptools)
library(dplyr)
# devtools::install_github("dirkschumacher/ompr@milp")
# CC by
map_data <- rgdal::readOGR("https://raw.githubusercontent.com/nvkelso/natural-earth-vector/master/geojson/ne_50m_admin_0_countries.geojson", "OGRGeoJSON")
@Leo-Lee15
Leo-Lee15 / mtlbl_clf.R
Created May 4, 2017 13:28 — forked from mick001/mtlbl_clf.R
Multilabel classification using R and the neuralnet package
################################################################################
# Loading data
rm( list=ls() )
# load libs
require(neuralnet)
require(nnet)
# Load data and set names