2017-12-16 24 views
0

다음 결과가 있습니다. 나는 이러한 결과에 대한 깨끗한 출판 가능한 원고 테이블을 만들고 싶지만, R을 통해 이것을 할 수있는 코드를 확신 할 수 없으며 두려운 복사 및 붙여 넣기를 통해서가 아닙니다. 누군가가 도와 줄 수 있습니까?요약 결과를 게시 용 단어로 표로 내보내기

calfrg <- read.csv("~/Desktop/R/CalFRG2017.csv", header = TRUE) 
attach(calfrg) 
model1 = lm(formula = energy ~ infectionstatus+ fl + weight + site + infectionstatus*weight +site*weight + infectionstatus*fl + site*fl +weight*fl +infectionstatus*weight*fl + site*weight*fl, data = calfrg) 
summary(model1) 
model2 = lm(formula = percentmoisture ~ infectionstatus+ fl + weight +site + infectionstatus*weight +site*weight + infectionstatus*fl + site*fl +weight*fl +infectionstatus*weight*fl + site*weight*fl, data = calfrg) 
summary(model2) 
model3 = lm(formula = cf ~ infectionstatus + site, data = calfrg) 
summary(model3) 
model4 = lm(formula = relativecf ~ infectionstatus +site, data = calfrg) 
summary(model4) 
+0

대답 중 하나에서 언급 한'knitr :: kable '외에도'kableExtra' 패키지에서'kable' 테이블의 형식을보다 유연하게 변경할 수 있습니다. – eipi10

답변

0

capture.output을 사용하여 화면으로 출력되는 내용을 캡처 한 다음 파일에 쓸 수 있습니다.

SText = capture.output(summary(lm(Sepal.Length ~ . , data=iris[,1:4]))) 
FileCon = file("IrisSummary.txt") 
writeLines(SText, FileCon) 
close(FileCon) 
+1

또는 한 줄로 이것을 수행하기 위해'capture.output'의'file ='인수를 사용하는 것보다 짧습니다. – dww

0

knitr :: kable() 또는 pander :: pander()를 사용해보십시오. 이것도 도움이되는 다른 패키지가 있습니다. 가장 강력한 테이블은 아마 테이블 일 것이지만 학습 곡선이 있습니다. 요약을 오브젝트에 할당 한 다음 오브젝트를 더 처리하여 원하는 방식으로 인쇄물을 얻을 수도 있습니다.