Come ottenere l'output standard RQuando invio il codice R tramite JSL, l'output standard della console R (stdout) viene visualizzato nel registro JMP.C'è un modo per acquisire tali informazioni in una stringa di testo?So di poter reindirizzare lo stdout da R a un file (usando la funzione sink()) e quindi ottenere il contenuto del file in una variabile JMP con un po' di JSL, ma preferirei non dover utilizzare un passaggio intermedio come quello.
Esempio;
names default to here(1);
R Init();
dt=open("$SAMPLE_DATA/Cars.jmp");
R Send(dt);
R Submit(
"
summary(lm(formula=Chest.decel ~ Wt, data=dt))
"
);
RTerm();Questo output viene visualizzato nel file di registro
Call:
lm(formula = Chest.decel ~ Wt, data = dt)
Residuals:
Min 1Q Median 3Q Max
-17.931 -6.650 -1.482 5.593 44.232
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 3.853e+01 2.440e+00 15.792 < 2e-16 ***
Wt 3.354e-03 8.135e-04 4.123 4.7e-05 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 9.367 on 339 degrees of freedom
(11 observations deleted due to missingness)
Multiple R-squared: 0.04776, Adjusted R-squared: 0.04495
F-statistic: 17 on 1 and 339 DF, p-value: 4.703e-05Voglio essere in grado di ottenere l'output come stringa di testo e inserirlo in una casella di testo in una finestra del report.
Re: Come ottenere l'output standard RAcquisizione registro() può fare quello che vuoi.
Names Default To Here(1);
R Init();
dt = Open("$SAMPLE_DATA/Cars.jmp");
R Send(dt);
R_stdout = Log Capture(R Submit("
summary(lm(formula=Chest.decel ~ Wt, data=dt))
"));
R Term();
New Window("example", Text Box(R_stdout));Re: Come ottenere l'output standard RGrazie per il suggerimento.So che se posso inserire i risultati R in un oggetto dati R, posso usare R Get() per recuperare i risultati.Tuttavia, sarebbe molto più semplice ottenere i risultati stdout come stringa di testo, almeno per i miei scopi.
@uday_guntupalli ha scritto:
@MathStatChem ,
Prova questo:
R Init();
dt=open("$SAMPLE_DATA/Cars.jmp");
R Send(dt);
R Submit(
"
model = lm(Chest.decel ~ Wt,data = dt)
t = summary(model)
# Use names function to determine what are the objects that exist
names(t)
# Extract and cast into data frames
Residuals = as.data.frame(t$residuals)
Coefficients = as.data.frame(t$coefficients)
"
);
ResidJMP = R Get(Residuals);
ResidJMP << New Data View;
CoeffJMP = R Get(Coefficients);
CoeffJMP << New Data View;
RTerm();
Close(dt,"No Save");
Re: Come ottenere l'output standard R@MathStatChem ,
Prova questo:
R Init();
dt=open("$SAMPLE_DATA/Cars.jmp");
R Send(dt);
R Submit(
"
model = lm(Chest.decel ~ Wt,data = dt)
t = summary(model)
# Use names function to determine what are the objects that exist
names(t)
# Extract and cast into data frames
Residuals = as.data.frame(t$residuals)
Coefficients = as.data.frame(t$coefficients)
"
);
ResidJMP = R Get(Residuals);
ResidJMP << New Data View;
CoeffJMP = R Get(Coefficients);
CoeffJMP << New Data View;
RTerm();
Close(dt,"No Save");
Re: Come ottenere l'output standard RDa quello che posso vedere, R Get() otterrà i valori da una struttura di dati R o da una variabile (numero, stringa, matrice, elenco o frame di dati), ma non dall'output standard.
Re: Come ottenere l'output standard R@MathStatChem ,
Prima di andare troppo avanti, non vuoi usare R Get() ? Hai provato a utilizzare R Get() e quindi a utilizzare tali informazioni come input nella casella di testo?