I may not I properly understand the context of this discussion, and, in
particular what the my.formula() function does. But if I do, the following,
from ?formula, seems relevant and would indicate that the discussion is
unnecessary:
"There are two special interpretations of . in a formula. The usu
What about the Cs()-function in Hmisc?
library(Hmisc)
Cs(a,b,c)
[1] "a" "b" "c"
Steven Yen wrote/hat geschrieben on/am 05.01.2021 13:29:
Thanks Eric. Yes, "unlist" makes a difference. Below, I am doing not
regression but summary to keep the example simple.
> set.seed(123)
> data<-matrix(runif
Thanks Eric. Yes, "unlist" makes a difference. Below, I am doing not
regression but summary to keep the example simple.
> set.seed(123)
> data<-matrix(runif(1:25),nrow=5)
> colnames(data)<-c("x1","x2","x3","x4","x5"); data
x1 x2 x3 x4 x5
[1,] 0.2875775
wrap it in unlist
xx <- unlist(strsplit( ))
On Tue, Jan 5, 2021 at 12:59 PM Steven Yen wrote:
> Thanks Eric. Perhaps I should know when to stop. The approach produces a
> slightly different variable list (note the [[1]]). Consequently, I was not
> able to use xx in defining my regression
Thanks Eric. Perhaps I should know when to stop. The approach produces a
slightly different variable list (note the [[1]]). Consequently, I was
not able to use xx in defining my regression formula.
> x<-colnames(subset(mydata,select=c(
+ hhsize,urban,male,
+ age3045,age4659,age60, # age1
If your column names have no spaces the following should work
x<-strsplit(gsub("[\n ]","",
"hhsize,urban,male,
+ gov,nongov,married"),","); x
On Tue, Jan 5, 2021 at 11:47 AM Steven Yen wrote:
> Here we go! BUT, it works great for a continuous line. With line break(s),
Here we go! BUT, it works great for a continuous line. With line
break(s), I got the nuisance "\n" inserted.
> x<-strsplit("hhsize,urban,male,gov,nongov,married",","); x
[[1]]
[1] "hhsize" "urban" "male" "gov" "nongov" "married"
> x<-strsplit("hhsize,urban,male,
+ gov,no
zx<-strsplit("age,exercise,income,white,black,hispanic,base,somcol,grad,employed,unable,homeowner,married,divorced,widowed",",")
On Tue, Jan 5, 2021 at 11:01 AM Steven Yen wrote:
> Thank you, Jeff. IMO, we are all here to make R work better to suit our
> various needs. All I am asking is an ea
Thank you, Jeff. IMO, we are all here to make R work better to suit our
various needs. All I am asking is an easier way to define variable list
zx, differently from the way z0 , x0, and treat are defined.
> zx<-colnames(subset(mydata,select=c(
+ age,exercise,income,white,black,hispanic,base,som
IMO if you want to hardcode a formula then simply hardcode a formula. If you
want 20 formulas, write 20 formulas. Is that really so bad?
If you want to have an abbreviated way to specify sets of variables without
conforming to R syntax then put them into data files and read them in using a
form
see below
Steven Yen wrote/hat geschrieben on/am 05.01.2021 08:14:
I constantly define variable lists from a data frame (e.g., to define a
regression equation). Line 3 below does just that. Placing each variable
name in quotation marks is too much work especially for a long list so I
do that wit
I constantly define variable lists from a data frame (e.g., to define a
regression equation). Line 3 below does just that. Placing each variable
name in quotation marks is too much work especially for a long list so I
do that with line 4. Is there an easier way to accomplish thisto
define a
12 matches
Mail list logo