Skip to content

Instantly share code, notes, and snippets.

@pgtwitter
pgtwitter / RSample.java
Last active August 29, 2015 14:13
sqrt(36)
package rJava;
import org.rosuda.JRI.REXP;
import org.rosuda.JRI.Rengine;
public class RSample {
public static void main(String[] args) {
System.err.println(System.getenv("R_HOME"));
System.err.println(System.getenv("java.library.path"));
@pgtwitter
pgtwitter / RSample.java
Last active August 29, 2015 14:13
curve fitting
package rJava;
import org.rosuda.JRI.REXP;
import org.rosuda.JRI.Rengine;
public class RSample {
public static void main(String[] args) {
System.out.println("R_HOME:" + System.getenv("R_HOME"));
System.out.println("java.library.path:"
+ System.getProperty("java.library.path"));
@pgtwitter
pgtwitter / RSample.java
Last active August 29, 2015 14:13
frequency table
package rJava;
import java.util.Vector;
import org.rosuda.JRI.REXP;
import org.rosuda.JRI.RVector;
import org.rosuda.JRI.Rengine;
public class RSample {
public static void main(String[] args) {
@pgtwitter
pgtwitter / RSample.java
Created January 11, 2015 01:49
creates the 'png' image (The 'Base64.Encoder' class is in Java 1.8)
package rJava;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.util.Base64;
import org.rosuda.JRI.Rengine;
public class RSample {
@pgtwitter
pgtwitter / RSample.java
Created January 11, 2015 02:04
creates the 'svg' image
package rJava;
import java.io.File;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.util.Base64;
import org.rosuda.JRI.Rengine;
@pgtwitter
pgtwitter / RSample.java
Last active August 29, 2015 14:13
plot images for the flip book
package rJava;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.image.BufferedImage;
import java.io.File;
package rJava;
import java.awt.Graphics;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.image.BufferedImage;
import java.io.File;
import javax.imageio.ImageIO;
import javax.swing.JFrame;
package rJava;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import org.rosuda.JRI.REXP;
public class RSample extends RBase implements KeyListener {
static int L = 30;
static int L2 = L * L;
DROP TABLE IF EXISTS temp_table, drop_table;
CREATE TABLE temp_table LIKE target_table;
LOAD DATA INFILE "/path/to/csvfile.csv" INTO TABLE temp_table
FIELDS TERMINATED BY ',' ENCLOSED BY '"'
LINES STARTING BY '' TERMINATED BY '\n';
RENAME TABLE target_table to drop_table, temp_table to target_table;
DROP TABLE drop_table;
-- col1 主キー (csv 第1カラム)
-- col2 値 (csv 第2カラム)
-- col3 値 (csv 第3カラム)
-- col4 登録timestamp
-- col5 更新timestamp
-- 一時テーブルの作成
DROP TABLE IF EXISTS tmp_table;
CREATE TABLE tmp_table LIKE target_table;
-- 一時テーブルの読込み