Re: [R] apply

2024-10-04 Thread Steven Yen
gges wrote: > Homework questions are not answered on this list. > > Best, > Uwe Ligges > > > > On 04.10.2024 10:32, Steven Yen wrote: >> The following line calculates standard deviations of a column vector: >> >> se&l

Re: [R] apply

2024-10-04 Thread Steven Yen
ctor element is zero, it's only one value therefore it does not vary. A similar reasonong can be applied to cov(x[1], x[2]), etc. Hope this helps, Rui Barradas Às 12:14 de 04/10/2024, Steven Yen escreveu: Hello I have a vector: set.seed(123) > n<-3 > x<-rnorm(n); x [1]

Re: [R] apply

2024-10-04 Thread Steven Yen
[1]) cov(x[3],x[2]) var(x[3]) And I like to do it with "apply". Thanks. On 10/4/2024 6:35 PM, Rui Barradas wrote: > Hello, > > If you have a numeric matrix or data.frame, try something like > > cov(mtcars) > > Hope this helps, > > Rui Barradas > > > Às

Re: [R] apply

2024-10-04 Thread Steven Yen
On 10/4/2024 5:13 PM, Steven Yen wrote: > Pardon me!!! > > What makes you think this is a homework question? You are not > obligated to respond if the question is not intelligent enough for you. > > I did the following: two ways to calculate a covariance matrix but &g

[R] apply

2024-10-04 Thread Steven Yen
The following line calculates standard deviations of a column vector: se<-apply(dd,1,sd) How can I calculate the covariance matrix using apply? Thanks. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/l

Re: [R] Printing

2024-08-11 Thread Steven Yen
invisible. On 8/11/2024 10:09 PM, Rui Barradas wrote: Às 09:51 de 11/08/2024, Steven Yen escreveu: Hi In the following codes, I had to choose between printing (= TRUE) or deliver something for grab (ei, vi). Is there a way to get both--that is, to print and also have ei and vi for grab? Thanks.

[R] Printing

2024-08-11 Thread Steven Yen
t<-out[!grepl(colnames(zx)[1],rownames(out)),] if(printing){ cat("\nAPPs of bivariate ordered probit probabilities",     "\nWritten by Steven T. Yen (Last update: 08.11.24)",     "\ny1.level=", y1.level,     "  y2.level=", y2.level,     "\

Re: [R] If loop

2024-08-09 Thread Steven Yen
n() { >> v <- v+1 >> return (v) >> } >> >> v <- funB() >> cat (v) >> #2 >> >> Or use <<- assignment I think. (I usually return, but return can only >> return one object and I think you want two or more >> >> v <

Re: [R] If loop

2024-08-09 Thread Steven Yen
x27;t see? > > joint12 <- marg1 <-F > > marg1 <-T > > if (joint12) { >   print ("joint 12") >   cat (joint12) > } > > if (marg1) { >   print("marg 1") >   cat(marg1) > } > > Would probably be my diagnostic approach > &

Re: [R] If loop

2024-08-08 Thread Steven Yen
  } else if(marg1) {     labels<-c(labels,lab.p1)   } else if(marg2) {     labels<-c(labels,lab.p2)   } else if(cond12){     labels<-c(labels,lab.pc12)   } else {     labels<-c(labels,lab.pc21)   } On 8/9/2024 11:44 AM, Steven Yen wrote: Can someone help me with the if loop below?

[R] If loop

2024-08-08 Thread Steven Yen
Can someone help me with the if loop below? In the subroutine, I initialize all of (joint12,marg1,marg2,cond12,cond21) as FALSE, and call with only one of them being TRUE: ,...,joint12=FALSE,marg1=FALSE,marg2=FALSE,cond12=FALSE,cond21=FALSE joint12 seems to always kick in, even though I ca

Re: [R] grep

2024-08-01 Thread Steven Yen
Thanks! On 8/2/2024 12:28 PM, Rui Barradas wrote: Às 02:10 de 02/08/2024, Steven Yen escreveu: Good Morning. Below I like statement like j<-grep(".r\\b",colnames(mydata),value=TRUE); j with the \\b option which I read long time ago which Ive found useful. Are there more or

[R] grep

2024-08-01 Thread Steven Yen
Good Morning. Below I like statement like j<-grep(".r\\b",colnames(mydata),value=TRUE); j with the \\b option which I read long time ago which Ive found useful. Are there more or these options, other than ? grep? Thanks. dstat is just my own descriptive routine. > x  [1] "age"  "sleep

Re: [R] grep

2024-07-13 Thread Steven Yen
  9 10 11 12 13 28 29 30 31 32 33 34 35 50 51 52 53 54 55 56 57 > On 7/13/2024 12:31 AM, Rui Barradas wrote: Hello, So any of names(goprobit.p$est) |> grep("somewhat|very", x = _) goprobit.p$est |> names() |> grep("somewhat|very", x = _) should work, right?

Re: [R] grep

2024-07-12 Thread Steven Yen
341 -0.1108 -0.0694 -0.2909 -0.4267 -0.6188 -0.7580 -0.3413 -0.3813 [10] -0.3101 -0.2977 -0.6310 -0.9132 0.1885 -0.0887 -0.0850 0.0847 -0.1588 On 7/12/2024 11:57 PM, Steven Yen wrote: > Thanks. First and second of the following worked, but the third (with > coef) did not. This may be bec

Re: [R] grep

2024-07-12 Thread Steven Yen
Sorry. grepl worked: which(grepl("very|somewhat",names(goprobit.p$est))) On 7/12/2024 5:34 PM, Steven Yen wrote: > > Could not get "which" to work, but my grep worked. Thanks. > > > which(grep("very|somewhat",names(goprobit.p$est))) Error in >

Re: [R] grep

2024-07-12 Thread Steven Yen
goprobit.p$est)) [1] 6 7 8 9 10 11 12 13 28 29 30 31 32 33 34 35 50 51 52 53 54 55 56 57 On 7/12/2024 5:26 PM, Steven Yen wrote: > Thanks. In this case below, what is "x"? I tried rownames(out) which > did not work. > > Sorry. Does this sound like homework to you? > &

Re: [R] grep

2024-07-12 Thread Steven Yen
Thanks. In this case below, what is "x"? I tried rownames(out) which did not work. Sorry. Does this sound like homework to you? On 7/12/2024 5:09 PM, Uwe Ligges wrote: On 12.07.2024 10:54, Steven Yen wrote: Below is part a regression printout. How can I use "grep" to

[R] grep

2024-07-12 Thread Steven Yen
Below is part a regression printout. How can I use "grep" to identify rows headed by variables (first column) with a certain label. In this case, I like to find variables containing "somewhath", "veryh", "somewhatm", "verym", "somewhatc", "veryc","somewhatl", "veryl". The result should be an in

Re: [R] Naming output file

2024-06-24 Thread Steven Yen
Jun 2024 20:16:46 +0800 Steven Yen пишет: In the call to ame.bopa in a loop, I like inputs in the call to ame.bopa to be bop1, bop2, bop3,... Thanks. for (im in 1:m) { ame<-ame.bopa(bop,y1.level=y1value,y2.level=y2value,jindex=jindex1,vb.method="invH",joint12=TRUE,    

Re: [R] Naming output file

2024-06-24 Thread Steven Yen
.method="invH",joint12=TRUE,     printing=FALSE,testing=TRUE) } On 6/24/2024 7:57 PM, Eric Berger wrote: > assign(paste0("bop",im),boprobit(eqs,mydata,wt=weight,method="BHHH",tol=0,reltol=0,gradtol=1e-5,Fisher=TRUE)) > > > On Mon, Jun 24, 2024 at 2

Re: [R] Naming output file

2024-06-24 Thread Steven Yen
Thanks Eric. I am not following your suggested line. Would you just edit my line 4? Thanks. On 6/24/2024 7:51 PM, Eric Berger wrote: > How about > > assign(paste0("bop",im), boprobit( etc )) > > > > On Mon, Jun 24, 2024 at 2:41 PM Steven Yen wrote: > >

[R] Naming output file

2024-06-24 Thread Steven Yen
I would like a loop to (1) read data files 2010midata1,2010midata2,2010midata3; and (2)  name OUTPUT bop1,bop2,bop3. I succeeded in line 3 of the code below, BUT not line 4. The error message says: Error in paste0("bop", im) <- boprobit(eqs, mydata, wt = weight, method = "NR", : target of ass

Re: [R] Printout and saved results

2024-03-25 Thread Steven Yen
you want to save the value, you can wrap the assignment in parentheses, making it an expression: (retained.interesting.result <- function.with.interesting.result(..)) On Tue, 26 Mar 2024 at 15:03, Steven Yen wrote: How can I have both printout and saved results at the same time. The subr

[R] Printout and saved results

2024-03-25 Thread Steven Yen
How can I have both printout and saved results at the same time. The subroutine first return "out" and the printout gets printed, but not saved. I then run the "invisible" line. Results got saved and accessible but no printout. How can I have both printout and also have the results saved? T

Re: [R] Initializing vector and matrices

2024-02-29 Thread Steven Yen
Thanks to all. Great ideas. I found Eik Vettorazzi's suggesstion easy to implrment: ebarm<-vbarm<-NULL ... if (is.null(ebarm)) ebarm<-ame.00$ei/k else ebarm<-ebarm+ame.00$ei/k if (is.null(vbarm)) vbarm<-ame.00$vi/k else vbarm<-vbarm+ame.00$vi/k ... Steven Yen On 2/

Re: [R] [EXT] Initializing vector and matrices

2024-02-29 Thread Steven Yen
m Xi # sum over Xi Reduce("+",Xi) Hope that helps Eik Am 28.02.2024 um 09:56 schrieb Steven Yen: Is there as way to initialize a vector (matrix) with an unknown length (dimension)? NULL does not seem to work. The lines below work with a vector of length 4 and a matrix of 4 x 4. W

Re: [R] Initializing vector and matrices

2024-02-28 Thread Steven Yen
("midata", ind, ".csv")) ... k<-length(ame.00$bame) bsum<-bsum[1:k]+ame.00$bame vsum<-vsum[1:k,1:k]+ame.00$vame } On 2/28/2024 4:56 PM, Steven Yen wrote: Is there as way to initialize a vector (matrix) with an unknown length (dimension)? NULL does not seem to work. The

[R] Initializing vector and matrices

2024-02-28 Thread Steven Yen
Is there as way to initialize a vector (matrix) with an unknown length (dimension)? NULL does not seem to work. The lines below work with a vector of length 4 and a matrix of 4 x 4. What if I do not know initially the length/dimension of the vector/matrix? All I want is to add up (accumulate) 

[R] Including an external set of coded

2024-02-20 Thread Steven Yen
How can I call and include an external set of R codes, not necessarily a complete procedure (which can be include with a “source” command). Example: #I like to include and run the following lines residing in a file outside the main program: mydata<-transform(mydata, a<-b+c d<-e+f } Steven fro

Re: [R] Looping

2024-02-20 Thread Steven Yen
Steven from iPhone > On Feb 19, 2024, at 4:56 PM, Steven Yen wrote: > > Thanks to all. Glad there are many options. > > Steven from iPhone > >>> On Feb 19, 2024, at 1:55 PM, Rui Barradas wrote: >>> >> Às 03:27 de 19/02/2024, Steven Yen escreve

[R] Looping

2024-02-18 Thread Steven Yen
I need to read csv files repeatedly, named data1.csv, data2.csv,… data24.csv, 24 altogether. That is, data<-read.csv(“data1.csv”) … data<-read.csv(“data24.csv”) … Is there a way to do this in a loop? Thank you. Steven from iPhone [[alternative HTML version deleted]] __

[R] Concordance and Kendall's tau in copula

2023-11-06 Thread Steven Yen
t to read and what to use? Thank you. Steven Yen __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide comm

[R] Yext in parentheses.

2023-10-26 Thread Steven Yen
Dear All My program is long and sorry I do not have a replicable set of codes to present. But I present a chunk of codes at the end below. Essentially, 1. I initialize cat.ref as NUL (see line 1) 2. Then, I repeatedly add elements to cat.ref, where each element include parentheses in double qu

[R] Stacking matrix columns

2023-08-06 Thread Steven Yen
I wish to stack columns of a matrix into one column. The following matrix command does it. Any other ways? Thanks. > x<-matrix(1:20,5,4) > x [,1] [,2] [,3] [,4] [1,]    1    6   11   16 [2,]    2    7   12   17 [3,]    3    8   13   18 [4,]    4    9   14   19 [5,]    5   10   15   20 > ma

[R] Stacking matrix columns

2023-08-05 Thread Steven Yen
I wish to stack columns of a matrix into one column. The following matrix command does it. Any other ways? Thanks. > x<-matrix(1:20,5,4) > x [,1] [,2] [,3] [,4] [1,]    1    6   11   16 [2,]    2    7   12   17 [3,]    3    8   13   18 [4,]    4    9   14   19 [5,]    5   10   15   20 > ma

Re: [R] knitr and tinytex

2023-04-28 Thread Steven Yen
Here’s what I found: Running the line commands install.packages("knitr") install.packages('tinytex') and interactively in RStudio: Tools->Install Packages -> … both work. Thank you! Steven from iPhone > On Apr 27, 2023, at 8:26 AM, Steven T. Yen wrote: &g

[R] knitr and tinytex

2023-04-26 Thread Steven T. Yen
Dear tinytex users I install knitr and tinytex with the following line commands in RStudio and it seems to work: install.packages("knitr") install.packages('tinytex') In the long past I was told to also run the following lines but now they do not seem to be needed. #update.packages(ask = FA

Re: [R] R does not run under latest RStudio

2023-04-06 Thread Steven Yen
one is about R. > > Best, > Uwe Ligges > > > > >> On 06.04.2023 11:28, Steven T. Yen wrote: >> I updated to latest RStudio (RStudio-2023.03.0-386.exe) but >> R would not run. Error message: >> Error Starting R >> The R session failed to start. >&

Re: [R] R does not run under latest RStudio

2023-04-06 Thread Steven T. Yen
p.s. But now I click some (but not all)  .R file and cannot see the source code. On 4/6/2023 5:28 PM, Steven T. Yen wrote: I updated to latest RStudio (RStudio-2023.03.0-386.exe) but R would not run. Error message: Error Starting R The R session failed to start. RSTUDIO VERSION RStudio

[R] R does not run under latest RStudio

2023-04-06 Thread Steven T. Yen
I updated to latest RStudio (RStudio-2023.03.0-386.exe) but R would not run. Error message: Error Starting R The R session failed to start. RSTUDIO VERSION RStudio 2023.03.0+386 "Cherry Blossom " (3c53477a, 2023-03-09) for Windows [No error available] I also tried RStudio 2022.12.0+353 --- same

Re: [R] Removing variables from data frame with a wile card

2023-02-12 Thread Steven Yen
he first few lines of > `[.data.frame` when the first index is missing and the second is > provided, it does almost the same thing as if only the first index > provided. > >> On Sun, Feb 12, 2023 at 9:38 PM Steven Yen wrote: >> >> x[“V2”] would retain columns of x he

Re: [R] Removing variables from data frame with a wile card

2023-02-12 Thread Steven Yen
x[“V2”] would retain columns of x headed by V2. What I need is the opposite——I need a data grime with those columns excluded. Steven from iPhone > On Feb 13, 2023, at 9:33 AM, Rolf Turner wrote: > >  >> On Sun, 12 Feb 2023 14:57:36 -0800 >> Jeff Newmiller wrote: >> >> x["V2"] >> >> is more

Re: [R] Removing variables from data frame with a wile card

2023-02-12 Thread Steven T. Yen
>> >> You could alternatively use >> >> x["V2"] >> >> which should be identical to x[, "V2", drop = FALSE], but some people don't >> like that because it doesn't look like matrix indexing anymore. >> >> >

Re: [R] Removing variables from data frame with a wile card

2023-02-12 Thread Steven T. Yen
In the line suggested by Andrew Simmons, mydata <- mydata[, !grepl("^yr", colnames(mydata)), drop = FALSE] what does drop=FALSE do? Thanks. On 1/14/2023 8:48 PM, Steven Yen wrote: > Thanks to all. Very helpful. > > Steven from iPhone > >> On Jan 14, 2023, at

Re: [R] Removing variables from data frame with a wile card

2023-01-14 Thread Steven Yen
) > > Then you might write something like this to remove the columns starting with > yr: > > mydata <- mydata[, !grepl("^yr", colnames(mydata)), drop = FALSE] > >> On Sat, Jan 14, 2023 at 1:56 AM Steven T. Yen wrote: >> >> I have a data fra

[R] Removing variables from data frame with a wile card

2023-01-13 Thread Steven T. Yen
I have a data frame containing variables "yr3",...,"yr28". How do I remove them with a wild cardsomething similar to "del yr*" in Windows/doc? Thank you. > colnames(mydata)   [1] "year"   "weight" "confeduc"   "confothr" "college"   [6] ...  [41] "yr3"    "yr4"    "yr5"

[R] Background for word

2023-01-11 Thread Steven T. Yen
Dear, I am having a lucky day. I am programming in RStudio and when I type "black" (quotation signs included, the word turn into a word with black ground. Couldn't get rid of the backgroundcopying to Word, Excel, text editor and paste back to Rstudio, the word is still in black background

Re: [R] Format printing with R

2022-11-22 Thread Steven T. Yen
nodiscfem   0.51    0.50 discfem 0.49    0.50 notradgrol  0.70    0.46 tradgrol    0.30    0.46 nofemnopol  0.80    0.40 femnopol    0.20    0.40 nopreshurt  0.66    0.47 On 11/22/2022 3:08 PM, Ivan Krylov wrote: On Tue, 22 Nov 2022 08:15:57 +0800 "Steven T. Yen" wrote: Thanks to

Re: [R] Format printing with R

2022-11-21 Thread Steven T. Yen
00.32 [86,] 1.3000.74 R will still print 3 decimal places for the third column since it wants them to be of the same format, but each number is 2 sigfigs. On Mon, Nov 21, 2022 at 3:41 PM Steven T. Yen via R-help wrote: Hi, I have two variables with 86 observations each. Below I print

[R] Format printing with R

2022-11-21 Thread Steven T. Yen via R-help
Hi, I have two variables with 86 observations each. Below I print with the print command with digit=2. But, I am getting three decimal places for my first variable and two for the second. Please help. Thanks. > cbind(Mean,Std.dev)     Mean   Std.dev  [1,]  0.3107966  0.462820  [2,]  0.1

Re: [R] cannot print a list with cat

2022-10-24 Thread Steven T. Yen
ycontrol$gradtol) #works msg<-with(mycontrol,sprintf(fmt_string,tol,reltol,steptol,gradtol))   cat(msg) tol = 0.0e+00 reltol  = 0.0e+00 steptol = 1.0e-08 gradtol = 1.0e-10 Thids has worked great! Thanks again to all. Steven Yen On 10/25/2022 3:23 AM, Rui Barradas wrote: Às 16:21 de 24/10

Re: [R] cannot print a list with cat

2022-10-24 Thread Steven T. Yen
age. msg <- sprintf("(tol,reltol,steptol,gradtol): %E %E %E %E", mycontrol$tol,mycontrol$reltol,mycontrol$steptol,mycontrol$gradtol) message(msg) Hope this helps, Rui Barradas Às 14:25 de 24/10/2022, Steven T. Yen escreveu: Thank, Boris and Ivan. The simple command suggested b

Re: [R] cannot print a list with cat

2022-10-24 Thread Steven T. Yen
ov wrote: В Mon, 24 Oct 2022 20:39:33 +0800 "Steven T. Yen" пишет: Printing this in a main program causes no problem (as shown above). But, using the command t(mycontrol) the line gets ignored. t() doesn't print, it returns a value. In R, there's auto-printing in the toplevel

[R] cannot print a list with cat

2022-10-24 Thread Steven T. Yen
I have a "list" containing four elements, as shown below: > t(mycontrol) tol reltol steptol gradtol [1,] 0   0  1e-08   1e-12 Printing this in a main program causes no problem (as shown above). But, using the command t(mycontrol) the line gets ignored. Any idea? Thank

Re: [R] cat in a subroutine

2022-10-13 Thread Steven T. Yen
rew for help! On 10/13/2022 10:30 PM, Bill Dunlap wrote: > Do you have another function called "cat" in scope? (with an argument > called "j")?  Before calling cat("...") call print(cat) and > print(find("cat")). > > -Bill > > > On

Re: [R] cat in a subroutine

2022-10-13 Thread Steven Yen
eed anything? > > Jim > >> On Thu, Oct 13, 2022 at 8:02 PM Steven T. Yen wrote: >> >> Not really. >> >> fortytwo<-42 >> cat("\nMarginal and Discrete Effects of Gen Ordered Logit / Probit >> Probabilities", >> &qu

Re: [R] cat in a subroutine

2022-10-13 Thread Steven T. Yen
rginal and Discrete Effects of Gen Ordered Logit / Probit Probabilities","logisitic =",fortytwo,"\n") j<-grep(".one\\b",c(".one\\a",".one\\b")) Marginal and Discrete Effects of Gen Ordered Logit / Probit Probabilities logisitic = 42 If I don't

Re: [R] cat in a subroutine

2022-10-13 Thread Steven Yen
t<-abs(me)/se; p<-2*(1-pt(t,nrow(x))) sig<-my.sig.levels(p) out<-data.frame(round(cbind(me,se,t,p),digits)); out<-cbind(out,sig) rownames(out)<-names(me) colnames(out)<-c("est","se","t","p","sig") cat("\nMarginal and Discrete Effects of Gen Ordered Logit / Probit Probabilities", "\n\nlogistic

Re: [R] cat in a subroutine

2022-10-13 Thread Steven Yen
13, 2022, at 3:54 PM, Erin Hodgess wrote: > >  > All right. Are these lines of code part of a larger function, please? Is > that function possibly calling a loop, please? > > Thanks, > Erin > >> On Thu, Oct 13, 2022 at 1:49 AM Steven T. Yen wrote: >>

Re: [R] cat in a subroutine

2022-10-13 Thread Steven T. Yen
te Effects of Gen Ordered Logit / Probit Probabilities") :   argument "j" is missing, with no default > On 10/13/2022 3:37 PM, Erin Hodgess wrote: > Hi Steven: > > Do you have a variable called logistic, please?  I think that might be > the culprit. > > Tha

[R] cat in a subroutine

2022-10-13 Thread Steven T. Yen
I have had an issue with printing (with cat) in a subroutine for which I do not have a applicable example, but I am still hoping to get some help. In the following, the first block of code works fine. ... t<-abs(me)/se; p<-2*(1-pt(t,nrow(x))) sig<-my.sig.levels(p) out<-data.frame(round(cbind(m

Re: [R] Help with a simple subroutine

2022-09-09 Thread Steven T. Yen
to start looking for a problem. Hand calculation can use pencil and paper or Excel or other tools. It is a tedious task but very effective. Tim -Original Message- From: R-help On Behalf Of Ivan Krylov Sent: Friday, September 9, 2022 5:03 AM To: Steven T. Yen Cc: R-help Mailing List

Re: [R] Renaming multiple objects

2021-11-21 Thread Steven Yen
(tmp_list) rm(list = obj_names) # check to see if it worked (it did) ls() #[1] "meb1.p"  "meb2.p"  "mec1.p"  "mec2.p"  "mej12.p" "mej22.p" Hope this helps, Rui Barradas Às 10:27 de 20/11/21, Steven Yen escreveu: I have named NUMEROUS ob

[R] Renaming multiple objects

2021-11-20 Thread Steven Yen
I have named NUMEROUS objects (each containing, e.g., 48 obs. of 5 variables), such as   mec1.p.emb   mec2.p.emb   meb1.p.emb   meb2.p.emb   mej12.p.emb   mej22.p.emb How would I rename these objects removing the silly ".emb", into objects   mec1.p   mec2.p   meb1.p   meb2.p   mej12.p   mej22.p

Re: [R] Wild cards for dataframes

2021-10-22 Thread Steven Yen
ects names matching the pattern. rm(list = ls(pattern = "data\\..*$")) Hope this helps, Rui Barradas Às 10:20 de 22/10/21, Steven Yen escreveu: I like to be able to use a command with something similar to a "wild card". Below, lines 4 works to delete all three dataframes,

[R] Wild cards for dataframes

2021-10-22 Thread Steven Yen
I like to be able to use a command with something similar to a "wild card". Below, lines 4 works to delete all three dataframes, but line 5 does not work. Any elegant way to accomplish this? My list of dataframes can be long and so this would be convenient. data.1<-data.frame(x=1:3,y=4:6,z=7:9

Re: [R] [External] Subset command

2021-10-15 Thread Steven Yen
negation - -c(TRUE,FALSE) [1] -1 0 as.logical(-c(TRUE,FALSE)) [1] TRUE FALSE !c(TRUE,FALSE) [1] FALSE TRUE On Oct 15, 2021, at 21:23, Steven Yen wrote: The following "subset command works. I was hoping the second would as well but it does not. My definition of exclude is re

Re: [R] Subset command

2021-10-15 Thread Steven Yen
Thanks. YES the second call to subset is there, trying to use my failed definition of "exclude". Read on.. On 2021/10/16 上午 09:35, Jeff Newmiller wrote: I don't see a "second one". Looks like you forgot the subset function call? On October 15, 2021 6:23:56 PM PDT

[R] Subset command

2021-10-15 Thread Steven Yen
The following "subset command works. I was hoping the second would as well but it does not. My definition of exclude is rejected. Help please? Thanks. > mydata<-subset(mydata, +    prim>-9 & highsch>-9  & tert>-9 & +    govt>-9 & nongovt>-9  & +    m

Re: [R] Variable labels

2021-05-15 Thread Steven Yen
ry List maker for Android and iOS. > https://play.google.com/store/apps/details?id=io.robertknight.MPGL > <https://play.google.com/store/apps/details?id=io.robertknight.MPGL> > > > > > > > On Wed, May 12, 2021 at 9:49 PM Steven Yen <mailto:st...@ntu.edu.tw>&

Re: [R] Variable labels

2021-05-14 Thread Steven Yen
ttributes(mydata) $names [1] "id" "age" "yrmarry" $class [1] "data.frame" $row.names [1] 1 2 3 4 5 6 $var.labels [1] "Individual ID" "Age in Years" "Years of marriage" Cheers Petr -Original Message- Fr

Re: [R] Variable labels

2021-05-14 Thread Steven Yen
get? Use save/load. You want to do something different? So please explain what exactly. Cheers Petr -Original Message- From: Steven Yen Sent: Thursday, May 13, 2021 5:53 PM To: PIKAL Petr Subject: Re: [R] Variable labels Petr Those attachments (1.jpg, 2.jpg) I sent earlier were just

Re: [R] Variable labels

2021-05-13 Thread Steven Yen
; Is that what you wanted? > > Fredrik > >> On Thu, May 13, 2021 at 4:49 AM Steven Yen wrote: >> I insert variable with the expss function as shown below. No error >> message. My question is, how to save the variable labels in the data >> frame so that I c

[R] Variable labels

2021-05-12 Thread Steven Yen
I insert variable with the expss function as shown below. No error message. My question is, how to save the variable labels in the data frame so that I can click to read the labels. Thank you. mydata<-read_excel("data/Excel/hseinv.xlsx",na=".") library(expss) mydata=apply_labels(mydata,    

Re: [R] grep

2021-05-08 Thread Steven Yen
function names like "names" as data names is bad practice.) nms <- c( "x1.one", "x1.black", "x1.othrrace", "x1.moddkna", "x1.conserv", "x1.nstrprty", "x1.strrep", "x1.sevngprt", "x2.one", "

[R] grep

2021-05-08 Thread Steven Yen
Below, the first command simply creates a list of 16 names (labels) which can be ignore. In the 2nd and 3rd commands, I am able to identify names containing "black". In line 4, I am trying to identify names containing "black" or "conserv" but obviously it does not work. Can someone help? Thank

Re: [R] Identifying column type

2021-04-11 Thread Steven Yen
eric columns only. > > > Hope this helps, > > Rui Barradas > > Às 04:25 de 10/04/21, Steven Yen escreveu: >> I have data of mixed types in a data frame - date and numeric, as shown >> in summary below. How do I identify the column(s) that is/are not >> numeric

Re: [R] Identifying column type

2021-04-09 Thread Steven Yen
Thanks much! Yes it does. I will read. On 2021/4/10 上午 11:33, Jeff Newmiller wrote: Does sapply( mydata, inherits, what = "POSIXt" ) give you any ideas? On April 9, 2021 8:25:36 PM PDT, Steven Yen wrote: I have data of mixed types in a data frame - date and numeric, as shown

[R] Identifying column type

2021-04-09 Thread Steven Yen
I have data of mixed types in a data frame - date and numeric, as shown in summary below. How do I identify the column(s) that is/are not numeric, in this case, the first. All I want is to identify the column(s) and so that I can remove it/them from the data frame Thanks. > summary(mydata) Dat

Re: [R] Column-by-column division

2021-03-03 Thread Steven Yen
`%!%` <- function(x, y) {    stopifnot(ncol(x) == length(y))    t(t(x)/y) } x <- matrix(1:20, ncol = 2) s <- 1:2 x %!% s x %!% 1:4 Hope this helps, Rui Barradas Às 11:00 de 03/03/21, Steven Yen escreveu: I have a 10 x 2 matrix x. Like to divide the first column by s[1] and second

[R] Column-by-column division

2021-03-03 Thread Steven Yen
I have a 10 x 2 matrix x. Like to divide the first column by s[1] and second column by s[2]. The following lines work but are clumsy. Any idea? Thanks. > x   [,1] [,2]  [1,]    1   11  [2,]    2   12  [3,]    3   13  [4,]    4   14  [5,]    5   15  [6,]    6   16  [7,]    7   17  [8,]    8 

[R] Calling procedures

2021-01-24 Thread Steven Yen
something bad (which I should avoid) in my calls to mycdf2 and mycdf to obtain p2 and p3, respectively. Thank you. Steven Yen pbivlogis <- function(x,y,rho){ # * # Bivariate logistic CDF # *   p<-(1+exp(-x)+

Re: [R] Defining partial list of variables

2021-01-05 Thread Steven Yen
   Min.   :0.1029   Min.   :0.6405  1st Qu.:0.4090   1st Qu.:0.4533   1st Qu.:0.6557  Median :0.7883   Median :0.5726   Median :0.6928  Mean   :0.6617   Mean   :0.5527   Mean   :0.7746  3rd Qu.:0.8830   3rd Qu.:0.6776   3rd Qu.:0.8895  Max.   :0.9405   Max.   :0.9568   Max.   :0.9943 On 2021/1/5

Re: [R] Defining partial list of variables

2021-01-05 Thread Steven Yen
v + nongov + married > eq2<-my.formula(y="cig",x=xx); eq2 cig ~ c("hhsize", "urban", "male", "age3045", "age4659", "age60",     "highsc", "tert", "gov", "nongov", "married"

Re: [R] Defining partial list of variables

2021-01-05 Thread Steven Yen
t;married" On 2021/1/5 下午 05:34, Eric Berger wrote: > 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 <mailto:st...@ntu.

Re: [R] Defining partial list of variables

2021-01-05 Thread Steven Yen
. NSE has its strengths... but as a method of creating data objects it sucks. Note that even the tidyverse (now) requires you to use quotes when you are not directly referring to something that already exists. And if you were... you might as well be creating a formula. On January 4, 2021 11:1

[R] Defining partial list of variables

2021-01-04 Thread Steven Yen
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

Re: [R] Printing upon calling a function

2020-11-30 Thread Steven Yen
posting a reproducible example, you're wasting everyone's time. Duncan Murdoch On 30/11/2020 6:06 a.m., Steven Yen wrote: No, sorry. Line 1 below did not print for me and I had to go around and do line 2 to print: me.probit(obj) v<-me.probit(obj); v A puzzle. On 2020/11/30 下午

Re: [R] Printing upon calling a function

2020-11-30 Thread Steven Yen
No, sorry. Line 1 below did not print for me and I had to go around and do line 2 to print: me.probit(obj) v<-me.probit(obj); v A puzzle. On 2020/11/30 下午 07:00, Duncan Murdoch wrote: On 30/11/2020 5:41 a.m., Stefan Evert wrote: On 30 Nov 2020, at 10:41, Steven Yen wrote: Thanks

Re: [R] Printing upon calling a function

2020-11-30 Thread Steven Yen
.../R/oprobit.R") it did print. I do not understand. On 2020/11/30 下午 06:41, Stefan Evert wrote: On 30 Nov 2020, at 10:41, Steven Yen wrote: Thanks. I know, my point was on why I get something printed by simply doing line 1 below and at other occasions had to do line 2. me.probit(obj) T

Re: [R] Printing upon calling a function

2020-11-30 Thread Steven Yen
of printing it. By appending ";v" tp that command line, you implicitly call "print". Jim On Mon, Nov 30, 2020 at 7:15 PM Steven Yen wrote: I hope I can get away without presenting a replicable set of codes because doing so would impose burdens. I call a function which return

[R] Printing upon calling a function

2020-11-30 Thread Steven Yen
I hope I can get away without presenting a replicable set of codes because doing so would impose burdens. I call a function which return a data frame, with the final line return(out) In one case the data frame gets printed (similar to a regression printout), with simply a call me.probit(obj

Re: [R] Language environment

2020-11-17 Thread Steven Yen
Thanks. YES, include the line Sys.setenv(LANG="en"); in my Rprofile file and it worked. On 2020/11/18 上午 12:43, Jeff Newmiller wrote: put it in your .Rprofile file. Read the R Installation and Administration Manusl for more info. On November 17, 2020 5:00:06 AM PST, Steven Yen wr

[R] Language environment

2020-11-17 Thread Steven Yen
In R, I was able to set the language environment by fixing the line in file "C:\Program Files\R\R-4.0.3\etc\Rconsole", line 70 below, set language to EN: language = EN In RStudio, I am not able to do that, except to include the line Sys.setenv(LANG="en"); in every one of my program file. That

Re: [R] [External] Re: unable to access index for repository...

2020-10-08 Thread Steven Yen
autocorrect is crazy > On Oct 9, 2020, at 4:28 AM, Arne Henningsen wrote: > > Hi Steven > > Which optimisation algorithms in maxLik work better under R-3.0.3 than > under the current version of R? > > /Arne > >> On Thu, 8 Oct 2020 at 21:05, Steven Yen wrote: >

Re: [R] [External] Re: unable to access index for repository...

2020-10-08 Thread Steven Yen
ssue is >> that important to you. Such is the nature of volunteer-developed open source >> software... so support your local experts. >> >>> On October 8, 2020 10:22:54 AM PDT, Steven Yen wrote: >>> Thanks for the help. I have a reason to continue with R-3.0.3.

Re: [R] unable to access index for repository...

2020-10-08 Thread Steven Yen
file from CRAC Archive, right. So, this will always work for me? Thank you all !! If there are more direct options that work, I would still be interested to know. Steven Yen On 2020/10/9 上午 12:49, Duncan Murdoch wrote: Don't choose a mirror.  That will override the repos choice. Do updat

Re: [R] unable to access index for repository...

2020-10-08 Thread Steven Yen
below, probably due to an R bug.  But since you're using an obsolete version of R, it shouldn't surprise you that it has bugs that nobody else is seeing.) Duncan Murdoch On 08/10/2020 11:54 a.m., Steven Yen wrote: Thanks. You gentlemen please tell me what this means. In R (outside of R

Re: [R] unable to access index for repository...

2020-10-08 Thread Steven Yen
eived a warning but it went on to try https://cran-archive.r-project.org/bin/windows/contrib/3.0/aod_1.3.zip and it worked. See log below. I expect to continue to use R-3.0.3 for a while and I very much like this to become a routine. Thank you all. Steven Yen > install.packages("aod&quo

  1   2   3   >