반응형

R markdown -- table 그리기


테스트환경 : windows 7 64bit, R 3.1.2 64bit, RStudio 0.98


참고 : http://rfunction.com/archives/2474

         http://cran.r-project.org/web/packages/xtable/index.html

         http://www.inside-r.org/packages/cran/xtable/docs/xtable

         https://nsaunders.wordpress.com/2012/08/27/custom-css-for-html-generated-using-rstudio/

         



xtable package 를 사용한다. 


1. xtable package 설치하기


install.packages("xtable")
 


2. xtable 사용법

  -- print() 내부에 type="html" 을 적어야 html로 출력된다, 아니면 latex 형식으로 출력된다.

library(xtable)
data(iris)
print(xtable(head(iris, 10)), type = "html", include.rownames = F)
 


 
x <- matrix(rnorm(6), ncol = 2)
x.small <- xtable(x, label = 'absmall', caption = 'A margin table')
print(x.small,floating.environment= 'margintable',  table.placement = NULL, type = "html")
 


3. Rmd 파일에서 사용 예


test.Rmd


test.Rmd 파일 내용은 아래와 같다.

 
---
title: "test"
output: html_document
---
 
- Draw table example
 
```{r   comment=NA, results='asis'}
library(xtable)
data(iris)
print(xtable(head(iris, 5)), type = "html", include.rownames = F)
```
 
You can also embed plots, for example:
 
```{r  results="asis"}
d <- data.frame(tail=c(12,11,32,0), legs=c(4,4,4,2), height=c(31,35,62,68))
print(xtable(d), type="html") 
```


```{r  results="asis"}
df <- data.frame(A = c(1.00123, 33.1, 6), B = c(111111, 3333333, 3123.233))
print(xtable(df, display = c("s","f","f"), digits = 4),
  format.args = list(big.mark = " ", decimal.mark = ","), type="html")
```


```{r results="asis"}
x <- matrix(rnorm(6), ncol = 2)
x.small <- xtable(x, label = 'absmall', caption = 'A margin table')
print(x.small,floating.environment= 'margintable',  table.placement = NULL, type = "html")
```

 




** RStudio 에서 knit HTML 버튼 눌러서, 위의 test.Rmd 파일을 실행한 출력결과









반응형
Posted by 자유프로그램
,
반응형

라즈베리파이 설치 시작하기


작업환경 : windows 7 64bit 


참고 : http://sourceforge.net/projects/win32diskimager/

         https://www.sdcard.org/downloads/formatter_4/      -- SD 카드 포맷 프로그램




1. SD 카드 포맷하기







2. PC 에 Win32 Disk Imager 설치하기.


http://sourceforge.net/projects/win32diskimager/  사이트에 들어가서 

Win32DiskImager-0.9.5-install.exe 파일을 다운 받아 실행시켜 설치한다.


-- 설치후 실행 화면...




3. 라즈베리파이에 사용할 OS image 다운받기.




4. 다운받은 OS image zip 파일 압축해제하고,  Win32 Disk Imager 사용하여 라즈베리파이용 (mini)SD 굽기





5. 


































































반응형
Posted by 자유프로그램
,
반응형

tistory 에서 mathjax 사용하기


참고 : http://docs.mathjax.org/en/latest/start.html#tex-and-latex-input



TISTORY 관리자 화면에서 HTML/CSS 편집 메뉴 선택하여, skin.html 내의 <head> ... </head> 내부에 아래 내용을 복사해 넣고, 사용하면 된다.



<script type="text/x-mathjax-config">
MathJax.Hub.Config({
  tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']]}
});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=
TeX-AMS_HTML"></script>





$A \cap B$

 $A \cap B$












반응형

'기타' 카테고리의 다른 글

R markdown -- table 그리기  (0) 2015.01.11
라즈베리파이 설치 시작하기  (0) 2015.01.08
windows 에서 elasticsearch 설치하기  (0) 2015.01.02
git 설치 및 사용하기  (0) 2014.12.12
R markdown 사용법  (0) 2014.12.05
Posted by 자유프로그램
,
반응형

windows 에서 chocolatey 를 사용하여  elasticsearch 설치하기


테스트 환경 : windows 7 64bit


참고 : https://chocolatey.org/       ==> chocolatey 홈페이지

         https://chocolatey.org/packages/elasticsearch

         http://elasticsearch-users.115913.n3.nabble.com/new-windows-install-td3021742.html



1. chocolatey 를 설치하기 

     -- 위의 chocolatey 홈페이지에 나온것 처럼 설치하면된다.


      -- 즉, 아랫명령어를 복사한후, 관리자모드 명령프롬프트창에 붙여넣고 실행하면 , chocolatey 설치된다.


@powershell -NoProfile -ExecutionPolicy unrestricted -Command "iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))" && SET PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin



2. elasticsearch 설치하기.






3. 윈도우즈 명령창에서 curl 이용하여 data 입력시 주의사항.


Its a windows command line thing. Use " and """ where you want a ". 


curl -XPUT "http://localhost:9200/twitter/user/kimchy" -d "{ """name""" : 

"""Shay Banon""" }" 


resulted in the following. 


{"ok":true,"_index":"twitter","_type":"user","_id":"kimchy","_version":1}



curl -XPUT localhost:9200/my_index/my_type/1 -d "{"""name""":"""park""","""id""":34}"




4. 입력 결과 확인하기


curl GET localhost:9200/my_index/my_type/_search

















반응형

'기타' 카테고리의 다른 글

라즈베리파이 설치 시작하기  (0) 2015.01.08
tistory 에서 mathjax 사용하기  (0) 2015.01.05
git 설치 및 사용하기  (0) 2014.12.12
R markdown 사용법  (0) 2014.12.05
R markdown Slidy 에 rCharts 결과 그래프 넣기  (0) 2014.10.27
Posted by 자유프로그램
,
반응형

matplotlib 선형방정식 x축, y축 그리기


테스트 환경 : mac osx 요세미티, python 2.7.8


참고 : http://matplotlib.org/api/pyplot_api.html#matplotlib.pyplot.axhline

         http://nbviewer.ipython.org/github/jrjohansson/scientific-python-lectures/blob/master/Lecture-4-Matplotlib.ipynb#Axes-where-x-and-y-is-zero




y = 2x + 3 직선을 그려보자



** 그래프 그릴때 x 축과 y 축을 그리기위해 axvline() , axhline() 을 사용한다. 



import numpy as np
import matplotlib.pyplot as plt
plt.axvline(x=0, color = 'r') # draw x =0 axes
plt.axhline(y=0, color = 'r') # draw y =0 axes
x = np.arange(-10,10)
y = 2*x + 3
plt.plot(x, y) # draw line
plt.plot(x, y, 'o') # draw dots
# plt.plot(x, y, x, y, 'o')
plt.show()











반응형
Posted by 자유프로그램
,