Example #1
0
func (r RDocument) knit() {
	script := assets.NewRScript("knit.r")
	defer script.Remove()

	prgrm := script.WriteWrapper()
	args := []string{"--input", r.InputFile, "--outdir", r.OutDir}
	log.Printf("Running: %s %s", prgrm, strings.Join(args, " "))
	cmd := exec.Command(prgrm, args...)
	output, err := cmd.CombinedOutput()
	if err != nil {
		log.Fatalf("Trouble with %s:\n\n%s\n\nOutput:\n%s\n\n",
			prgrm, err, string(output))
	}
}
Example #2
0
func installPackages(installType string) {
	log.Println("Installing R packages")

	script := assets.NewRScript("install-packages.r")
	defer script.Remove()

	prgrm := script.WriteWrapper()
	args := []string{installType}
	log.Printf("Running: %s %s", prgrm, strings.Join(args, " "))
	cmd := exec.Command(prgrm, args...)
	cmd.Stdout = os.Stdout
	cmd.Stderr = os.Stderr
	err := cmd.Start()
	if err != nil {
		log.Fatalf("Trouble starting %s:\n\n%s\n\n",
			prgrm, err)
	}
	if err = cmd.Wait(); err != nil {
		log.Fatalf("Trouble running %s:\n\n%s\n\n",
			prgrm, err)
	}
}