대충 엑셀에서 확인해도 상관없지만 간단하게 R에서 확인해보고 싶은 것들이 있는 경우가 가끔 있다. R에서 불러오는게 귀찮거나 굳이 전체 파일을 다 불러오지 않아도 되는 경우 필요한 부분만 엑셀에서 복사한 후 R로 불러올 수 있다.
read.excel <- function(header=TRUE,...) { read.table("clipboard",sep="\t",header=header,...) } dat=read.excel()
Mac에서는 오류가 난다
Error in file(file, "rt") : X11 module cannot be loaded In addition: Warning message: In file(file, "rt") : unable to load shared object '/Library/Frameworks/R.framework/Resources/modules//R_X11.so': dlopen(/Library/Frameworks/R.framework/Resources/modules//R_X11.so, 6): Library not loaded: /opt/X11/lib/libSM.6.dylib Referenced from: /Library/Frameworks/R.framework/Resources/modules//R_X11.so Reason: image not found
X11 모듈을 설치하면 해결된다고는 한다. (참고: Mac용 X11에 관하여) 아래 코드처럼 쓰면 맥에서도 따로 설치 없이 불러올 수 있다.
read.excel <- function(header=TRUE,...) { read.table(pipe("clipboard",sep="\t",header=header,...) } dat=read.excel()