Skip to content

Instantly share code, notes, and snippets.

View janeshdev's full-sized avatar

Janesh Devkota janeshdev

View GitHub Profile
@janeshdev
janeshdev / index.html
Created February 11, 2016 21:34
Testing
<!DOCTYPE html>
<meta charset="utf-8">
<style>
body {
font: 10px sans-serif;
}
.axis path,
.axis line {
COUNTYFIPS NAME STATEPLANEFIPS EPSG
16079 Shoshone County 1103 26970
16073 Owyhee County 1103 26970
16071 Oneida County 1101 26968
16077 Power County 1101 26968
16075 Payette County 1103 26970
06115 Yuba County 0402 26942
06111 Ventura County 0405 26945
06113 Yolo County 0402 26942
31177 Washington County 2600 32104
@janeshdev
janeshdev / read_multiple_files.R
Last active August 24, 2016 20:23
Read multiple csv files in R #csv #multiple #files
# Import files under folder name fawn
# It is very important to include the option (full.names=TRUE). It it is not included
# then you will get the error something like
# "Error in file(file, "rt") : cannot open the connection In addition: Warning message:
#In file(file, "rt") : cannot open file 'FAWN_2002.csv': No such file or directory
mydata=ldply(list.files(path="data/fawn/",pattern="csv",full.names=TRUE),function(filename) {
dum=read.csv(filename)
dum$filename=filename
return(dum)
@janeshdev
janeshdev / velxy_velcomponent.R
Last active August 29, 2015 13:56
This function was created to convert the velocity with magnitude and direction from EFDC similar to x and y velocity components. #velocityxy #velocity
# A function to convert velocity xy EFDC file to velocity component file
velxy_convert <- function(file){
process_pp_template <- function(path) {
# Read data using quicktoolsr function
dat <- readts_EE(path)
# Reshape the data from long format to wide format
dat_mod <- dcast(dat, time ~ id)
return(dat_mod)
}
# Read the file
@janeshdev
janeshdev / 0_reuse_code.js
Created February 19, 2014 00:06
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@janeshdev
janeshdev / Lanczosfilter.m
Created June 24, 2013 00:55
Lanczos filter code by Carlos Adrián Vargas Aguilera. nubeobscura@hotmail.com
function [y,coef,window,Cx,Ff] = lanczosfilter(x,varargin)
%LANCZOSFILTER Filters a time series via Lanczos method (cosine filter).
% [Y,coef,window,Cx,Ff] = LANCZOSFILTER(X,dT,Cf,M,pass) Filters the time
% series via the Lanczos filter in the frequency space (FFT), where
%
% INPUTS:
% X - Time series
% dT - Sampling interval (default: 1)
% Cf - Cut-off frequency (default: half Nyquist)
% M - Number of coefficients (default: 100)
@janeshdev
janeshdev / multiplot.R
Created June 23, 2013 19:36
It can take any number of plot objects as arguments, or if it can take a list of plot objects passed to plotlist.
# Multiple plot function
#
# ggplot objects can be passed in ..., or to plotlist (as a list of ggplot objects)
# - cols: Number of columns in layout
# - layout: A matrix specifying the layout. If present, 'cols' is ignored.
#
# If the layout is something like matrix(c(1,2,3,3), nrow=2, byrow=TRUE),
# then plot 1 will go in the upper left, 2 will go in the upper right, and
# 3 will go all the way across the bottom.
#
@janeshdev
janeshdev / displayonebyone.tex
Created June 19, 2013 22:38
This gist shows how to display the items in beamer one by one using \only overlay
\documentclass{beamer}
\usetheme{CambridgeUS}
\setbeamertemplate{items}[ball]
\usefonttheme[onlylarge]{structurebold}
\usecolortheme[RGB={205,173,0}]{structure}
\setbeamerfont*{frametitle}{size=\normalsize,series=\bfseries}
\useoutertheme{infolines}
%Pacakges
\usepackage{xcolor}
## Let us assign a sample date as first with hours, minutes and seconds.
## It is also recommended to use the time zone
> date <- as.POSIXct("2013-06-14 16:34:26",tz="GMT")
## Convert to Julian date using the following function
> jddd <- julian(date, origin = as.POSIXct("2013-01-01 00:00:00",tz="GMT"))
> jddd
Time difference of 164.6906 days
@janeshdev
janeshdev / insetgraphs.R
Created June 13, 2013 19:15
Create inset graphs in ggplot2
library(ggplot2)
library(grid)
# A viewport taking up a fraction of the plot area
vp <- viewport(width = 0.4, height = 0.4, x = 0.1, y = 0.9,just=c("left","top"))
b_plot <- ggplot(cars,aes(speed,dist))+geom_line()+xlim(10,15)
b_plot