[R] Merging RData files

2018-01-16 Thread Steven Yen
I ran two separate hours-long projects. Results of each were saved to two separate .RData files. Content of each includes, among others, the following:    me    se  t p sig pc21.age    0.640 0.219  2.918 0.004 *** pc21.agesq  0.000 0.000    NaN   NaN pc21.inc 

Re: [R] Merging RData files

2018-01-16 Thread Steven Yen
t not html, otherwise they can > be mangled. > > Cheers > Petr > >> -Original Message- >> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Steven Yen >> Sent: Tuesday, January 16, 2018 9:44 AM >> To: r-help@r-project.org >> Su

Re: [R] Merging RData files

2018-01-16 Thread Steven Yen
Understood. In my case, a.RData and b.RData contain identical variables/data, plus simulation outputs from separate runs. The codes deliver what I need. Good to know the three lines work. Thank you. On 1/16/2018 8:06 PM, Duncan Murdoch wrote: > On 16/01/2018 6:33 AM, Steven Yen wrote: >&g

[R] Problem saving .RData file with save.image

2018-01-26 Thread Steven Yen
I am running R-3.0.3 on RStudio 1.1.183. I have recently gotten the following error message while saving an .RData file with the save.image command. I have not had this problem until recently. Help appreciated. === Error in save.image("bope1a.RData") : image could not be renamed and is left i

[R] Documenting R package with Rd file

2018-03-14 Thread Steven Yen
I have trouble documenting an R package. In my .Rd file (sixth line below), I have uhat<-m%*%y but when the package is built (successfully), the matrix multiplication part does not show up in the documentation. The line become (missing %*% y) uhat<-m === \examples{ x<-c(1,2,3,4,5) y<-c(1,1,2,

[R] Problem building binary data into library file

2018-04-26 Thread Steven Yen
I build binary data files into a library by placing the .rda files at the proper \data sub-folder before building the library with the following procedure: 1. File -> Open project 2. Build -> Build binary packages. This has worked up to 3 .rda files. Now, I add another .rda file to the folder. I

[R] Package installation

2018-07-09 Thread Steven Yen
I have had trouble installing packages (e.g., car, aod) in some computers (such as computers in the student lab) but no problem in my own laptop. Installation typically goes through, but after I got out and back in R (and RStudios), the error message says "packages xxx not available". That is,

[R] Matrix multiplication

2017-06-07 Thread Steven Yen
eed(76543211) a<-matrix(rpois(20,2),nrow=10); a a<-sqrt(w)*a; a t(a)%*%a On 1/4/2017 5:41 PM, Steven Yen wrote: > I need help with gls{nlme}. > Specifically, I am estimating an equation with AR(1) using > maximum-likelihood. I am not understanding the correlationoption

Re: [R] Matrix multiplication

2017-06-07 Thread Steven Yen
lemented two of them (?) and it is unclear (to me) what you think > the right answer for any of them is supposed to be. > -- Sent from my phone. Please excuse my brevity. On June 7, 2017 > 8:50:55 PM PDT, Steven Yen wrote: >> I need to have all elements of a matrix multiplied by a

[R] Grep command

2016-05-19 Thread Steven Yen
What is a good way to grep multiple strings (say in a vector)? In the following, I grep ants, cats, and fox separately and concatenate them, is there a way to grep the trio in one action? Thanks. all<-c("ants","birds","cats","dogs","elks","fox"); all [1] "ants" "birds" "cats" "dogs" "elks" "

[R] Element-by-element multiplication

2016-05-22 Thread Steven Yen
Dear R users: > # p is a vector if length 10 > # a is a vector if length 3 > # I like to create a matrix with > # the first column being p multiplied by a[1] > # the second column being p multiplied by a[2] > # the third column being p multiplied by a[3] > # The following would do that:

[R] Element-by-element operation (adding)

2016-05-22 Thread Steven Yen
Hi all, need help below. Thank you. > # Matrix v is 5 x 3 > # Vector b is of length 3 > # I like to add b[1] to all element in v[,1] > # I like to add b[2] to all element in v[,2] > # I like to add b[3] to all element in v[,3] > # as follows > v<-matrix(0,nrow=5,ncol=3); v [,1] [,2] [

[R] read.fortran format

2016-05-27 Thread Steven Yen
Dear fellow R users: I am reading a data (ascii) file with fortran fixed format, containing multiple records. R does not recognize fortran's record break (a slash). I tried to do the following but it does not work. Help appreciated. 60 FORMAT(1X,F6.0,5F8.6/1X,5F8.4,F10.6/1X,2F6.0,3E15.9,F8.0,F

Re: [R] read.fortran format

2016-05-27 Thread Steven Yen
n 5/27/2016 2:21 PM, John McKown wrote: > On Fri, May 27, 2016 at 12:56 PM, Steven Yen <mailto:sye...@gmail.com>>wrote: > > Dear fellow R users: > I am reading a data (ascii) file with fortran fixed format, containing > multiple records. R does not recognize fortran

Re: [R] read.fortran format

2016-05-27 Thread Steven Yen
f8")), digits=10) > V1 V2 V3 V4 V5 V6 V7 > 1 1950 0.61435 0.026834 0.087227 0.006821 0.180001 0.0456 > > > If I recall correctly, a dot in the format pushes the decimal point: > > > print(read.fortran(textConnection(txt), c("f5&

[R] Reading csv file with missing value

2016-06-24 Thread Steven Yen
I read a csv file (with read.csv) containing missing values (as shown below). Is there a convenient way to set these NA into zeros? Better yet, is there an option to assign zeros to these blank cells in reading the csv file? Thank you! NA -1 NA NA NA 1 NA NA NA NA NA NA NA NA NA NA

[R] t-test for regression estimate

2016-06-28 Thread Steven Yen
test option for linearHypothesis in library(car) include "Chisq" and "F". I prefer a simple t-test so that I can retrieve the standard error. Any options other than linearHypothesis to test the linear hypothesis (with 1 restriction/degree of freedom)? > summary(ols1) Coefficients:

Re: [R] t-test for regression estimate

2016-06-28 Thread Steven Yen
helps, > John > > - > John Fox, Professor > McMaster University > Hamilton, Ontario > Canada L8S 4M4 > Web: socserv.mcmaster.ca/jfox > > >> -Original Message- >> From: R-help [mailto:r-help-boun...@r-project.org] On Be

Re: [R] t-test for regression estimate

2016-06-29 Thread Steven Yen
> development version of the car package on R-Forge, which you should be able > to install via install.packages("car", repos="http://R-Forge.R-project.org";). > Then see ?linearHypothesis for more information. > > Best, > John > >> -Original Me

Re: [R] t-test for regression estimate

2016-06-29 Thread Steven Yen
Also, Is there a way to get the second command (hypothesis defined with externally scalars) below to work? Thanks. linearHypothesis(U,"0.5*eq1_DQ+0.3*eq2_DQ",verbose=T) w1<-0.5; w2<-0.3 linearHypothesis(U,"w1*eq1_DQ+w2*eq2_DQ",verbose=T) # does not work On 6/29/2016

[R] Column product

2016-07-01 Thread Steven Yen
A is a 5 x 3 matrix and a is a 3-vector. I like to exponentiate A[,1] to a[1], A[,2] to a[2], and A[,3] to a[3], and obtain the product of the resulting columns, as in line 3. I also accomplish this with lines 4 and 5. I like to have rowProducts(B) but there is not so I came up with something u

[R] Build command in library(devtools)

2016-07-19 Thread Steven Yen
I recently updated my R and RStudio to the latest version and now the binary option in the "build" command in devtools stops working. I went around and used the binary=F option which worked by I get the .tar.gz file instead of the .zip file which I prefer. Does anyone understand the following e

Re: [R] Build command in library(devtools)

2016-07-19 Thread Steven Yen
Thanks. I found the reason was Rtools does not run under the new version of R. I had to go back to as early as R 3.0.2 (September 2013) to make Rtools work. Any idea for a go-around? Thanks. On 7/19/2016 4:38 PM, John McKown wrote: > On Tue, Jul 19, 2016 at 3:15 PM, Steven Yen <mail

Re: [R] Build command in library(devtools)

2016-07-20 Thread Steven Yen
tion like this. Any help/insight would be appreciated. On 7/20/2016 10:08 AM, Steven Yen wrote: > On 7/19/2016 4:38 PM, John McKown wrote: >> On Tue, Jul 19, 2016 at 3:15 PM, Steven Yen > <mailto:sye...@gmail.com>>wrote: >> >> I recently updated my R and RStudio to

[R] Read text file

2015-06-17 Thread Steven Yen
How do I read a block of space-delimited numbers into a column vector using the read.table command? 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

[R] Call to a function

2015-06-23 Thread Steven Yen
Dear Members I have a data frame as generated below. I like to be able to call a function both with a vector and a vector (mydata$v1) in that data frame (v1). The first call works, but the second does not. Can someone help me with the second call? Thanks!! --- mydata<-data.frame(matrix(1:20,ncol=

Re: [R] Call to a function

2015-06-23 Thread Steven Yen
Thanks! From this I learn the much needed class statement if (class(wt)=="character") wt <- x[, wt] which serves my need in a bigger project. Steven Yen On 6/23/2015 6:20 PM, boB Rudis wrote: You can do something like: aaa <- function(data, w=w) { if (class(w)

Re: [R] 'class(.) == **' [was 'Call to a function']

2015-06-25 Thread Steven Yen
t;mts" and "ts" - The time-date objects POSIXt , POSIXct, POSIXlt ==> do work with inherits(, , ) We've seen this use of class(.) == ".."(or '!=" or %in% ...) in too many places; though it may work fine in your test cases, it is

Re: [R] 'class(.) == **' [was 'Call to a function']

2015-06-25 Thread Steven Yen
was hoping to figure out a way to fix the wmean routine some how so that I can call with wmean(mydata,wt=weight) Good to know there is a better way to initialize the vector Mean and and a better list command. Thank you! On 6/26/2015 2:39 AM, David Winsemius wrote: On Jun 25, 2015, at

[R] Judging if a matrix contains any NA

2015-07-26 Thread Steven Yen
How do I judge if a matrix contain any NA or otherwise non-missing, non-numerical? In the following, I would like to deliver ONE logical of TRUE or FALSE, rather than a 4 x 4 matrix containing TRUE or FALSE. Thank you. > a<-matrix(1:16,nrow=4) > diag(a)<-NA > a [,1] [,2] [,3] [,4] [1,] N

[R] Element-by-element division

2015-07-27 Thread Steven Yen
I need help with element-by-element division. Below, matrices a and c are both 5 x 2 and element-by-element division works as (I) expected. What if matrix is 1 by 2: to divide first column of a by b[1] and second column of a by b[2]. I had to go around (two ways) to make it work. In Gauss, these ca

[R] Splitting lines in R script

2015-08-02 Thread Steven Yen
I have a line containing summation of four components. # This works OK: p<-pbivnorm(bb,dd,tau)+pbivnorm(aa,cc,tau)- -pbivnorm(aa,dd,tau)-pbivnorm(bb,cc,tau) # This produces unpredicted results without warning: p<-pbivnorm(bb,dd,tau)+pbivnorm(aa,cc,tau) -pbivnorm(aa,dd,tau)-pbivnorm(bb

[R] Checking if a logical variable exists

2014-12-14 Thread Steven Yen
My obj does not always come with a logical variable defined. So I do my.foo <- function(obj,df,digits=5){ if (!is.na("obj$spec$Fisher")) Fisher<-obj$spec$Fisher ... } This works when "Fisher" is defined in/passed from obj. When it is not, I get error: Error in (!is.na("obj$spec$Fisher")) & Fi

Re: [R] Checking if a logical variable exists

2014-12-14 Thread Steven Yen
t(spec = list) Fisher <- ifelse(!("Fisher" %in% names(obj$spec)), FALSE, obj$spec$Fisher) Cheers, Ben On Dec 14, 2014, at 8:07 AM, Steven Yen wrote: > My obj does not always come with a logical variable defined. So I do > > my.foo <- function(obj,df,digits=5){ > if (!i

[R] Automating regression

2014-12-22 Thread Steven Yen
How do I specify the type of regression in calling a procedure/ In the following I call the procedure to do a probit regression. Of course, I can change "probit" into "lm" in procedure "myreg" to do a linear regression. My question is, how do I automate this (choice of lm or probit) in callin

[R] Matrix element-by-element multiplication

2015-01-07 Thread Steven Yen
I like to multiple the first and second column of a 10 x 3 matrix by 100. The following did not work. I need this in an operation with a much larger scale. Any help? aa<-matrix(1:30,nrow=10,ncol=3); aa bb<-matrix(c(100,100,1),nrow=1,ncol=3); bb dim(aa) dim(bb) aa*bb Results: > aa<-matrix(1:30

Re: [R] Matrix element-by-element multiplication

2015-01-07 Thread Steven Yen
Thank you both. Both John and Peter's suggestions work great!! At 06:17 PM 1/7/2015, John McKown wrote: >On Wed, Jan 7, 2015 at 5:05 PM, Steven Yen ><<mailto:sye...@gmail.com>sye...@gmail.com> wrote: >I like to multiple the first and second column >of a 10 x 3 mat

[R] Package corpcor: Putting symmetric matrix entries in vector

2015-01-30 Thread Steven Yen
Dear I use sm2vec from package corpcor to puts the lower triagonal entries of a symmetric matrix (matrix A) into a vector. However, sm2vec goes downward (columnwise, vector B), but I would like it to go across (rowwise). So I define a vector to re-map the vector (vector C). This works. But is

Re: [R] Package corpcor: Putting symmetric matrix entries in vector

2015-01-30 Thread Steven Yen
88050 0.3907721 1.0941534 0.2402183 -1.6214086 No need to play with potentially error-prone index vectors; upper.tri does that for you. Hope this helps, Peter On Fri, Jan 30, 2015 at 3:03 PM, Steven Yen wrote: > Dear > I use sm2vec from package corpcor to puts the lower triagonal entries of a &

[R] Problem with Rtools version 3.5.0.4

2018-07-31 Thread Steven Yen
I am trying to build an R package with Rtools version 3.5.0.4 along with R-3.5.1 using the following  sequence of commands: File -> Open Project -> Build -> Build Binary Package I received the following error message: zip I/O error: No such file or directory zip error: Temporary file failure (Y

[R] Polygon

2018-10-02 Thread Steven Yen
Can someone help me with polygon. The following codes are self-runnable and mark a shaded area under the standard normal curve in the x-range (-3,-1). Is there a way to also mark the area in (1,3), at the same time. That is, I want shaded areas in both tails. Thank you... === # Create data for t

Re: [R] Polygon

2018-10-02 Thread Steven Yen
inue with > > > polygon(-rev(cord.x), rev(cord.y), col = 'skyblue') > > > Hope this helps, > > Rui Barradas > > Às 17:25 de 02/10/2018, Steven Yen escreveu: >> Can someone help me with polygon. The following codes are self-runnable >> and mark a shad

Re: [R] Polygon

2018-10-02 Thread Steven Yen
Thanks!!! It did wonders. Steven On 10/3/2018 9:39 AM, David Winsemius wrote: >> On Oct 2, 2018, at 5:50 PM, Steven Yen wrote: >> >> Great. Thanks! It did wonders. >> 1. Is there a way to suppress the obvious tick stops (-3,-2,-1,0,1,2,3) >> and mark only the tick

[R] Graphing output

2018-10-09 Thread Steven Yen
Is it possible to release the file destination after sending it to a pdf file? Below, line 3 send the graph to a pdf file. I like to release the devise so that I can see result produced by line for on the console (screen). Thanks. x<-1:10 pdf("test1.pdf") # pdf {grDevices} boxplot(x) # This goes

Re: [R] Polygon

2018-10-21 Thread Steven Yen
David, Rui, and All: Greetings. 1. I need a helping hand with the polygon statement below so that I can have the area under the curve highlighted, between (z1,z2). 2. Is it possible to label the X-axis with in two scale, in the current z-scale and another, say x = (z+5)*2? Thank you. z1<- -1 z2<

[R] Using apply

2018-10-30 Thread Steven Yen
I need help with "apply". Below, I have no problem getting the column sums. 1. How do I get the sum of squares? 2. In general, where do I look up these functions? Thanks. x<-matrix(1:10,nrow=5); x sum <- apply(x,2,sum); sum [[alternative HTML version deleted]]

[R] Printing with cat in a procedure

2018-12-22 Thread Steven Yen
How do I print a matrix running a procedure? In the code below, I print with the cat command and get a vector (from A and C). A<-matrix(rpois(16,lambda=5),nrow=4,byrow=T) B<-diag(4) try5<-function(A,B){ C<-A+B cat("\nA =",A,"\nC = ",C) structure(list(A=A,B=B,C=C)) } v<-try5(A,B) v$C -- st

Re: [R] Printing with cat in a procedure

2018-12-22 Thread Steven Yen
("\nC = ") > print(C) > structure(list(A=A,B=B,C=C)) > } > > HTH, > Eric > > > On Sat, Dec 22, 2018 at 4:32 PM Steven Yen <mailto:st...@ntu.edu.tw>> wrote: > > How do I print a matrix running a procedure? In the code below, I > pri

[R] Random seed

2018-12-22 Thread Steven Yen
I have known from the old days to set a random seed of a LARGE ODD NUMBER. Now I read instructions of set.seed and it requires ANY INTEGER. Any idea? Or, does it matter. Thanks. -- st...@ntu.edu.tw (S.T. Yen) [[alternative HTML version deleted]] __

[R] Retrievable results in a procedure

2018-12-25 Thread Steven Yen
I would like to suppressed printing of retrievable results in a procedure and to print only when retrieved. In line 10 below I call procedure "try" and get matrices A,B,C all printed upon a call to the procedure. I get around this unwanted printing by calling with v<-try(A,B) as in line 11. An

Re: [R] Retrievable results in a procedure

2018-12-25 Thread Steven Yen
s already a base function try() so that's not a great > name for test functions. > > Sarah > > On Tue, Dec 25, 2018 at 8:47 AM Steven Yen <mailto:st...@ntu.edu.tw>> wrote: > > I would like to suppressed printing of retrievable results in a > procedure and

[R] Installing package into...

2019-03-12 Thread Steven Yen
I install package using either the command line or Tools -> Install packages... (in RStudio) and get a non-fatal message saying... Installing package into ‘C:/Users/xuhaer/Documents/R/win-library/3.5’ (as ‘lib’ is unspecified) I know it is not a fatal message. But, is there a way to do a cleaner

[R] Printing vectrix

2019-03-24 Thread Steven Yen
I like to print a vector, wrapped by rows of 10. Below the first command below works for 20 numbers. The second command is ugly. How can I print the 25 numbers into 2 rows of ten plus a helf row of 5? Thanks. > x<-1:20; matrix(x,nrow=2,byrow=T) [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9]

[R] Overwriting a procedure

2014-09-02 Thread Steven Yen
Is there a way to over-write a procedure (subroutine)? I include a default procedure fixx in a list of procedures which are compiled into a package. By default, the procedure deliver the data matrix x. fixx <- function(x){ result <- list(x=x) return(result) } In some applications, I have tran

Re: [R] Overwriting a procedure

2014-09-24 Thread Steven Yen
nside of a package namespace then look at the assignInNamespace function in the utils package (but note the warning in the description on the help page). On Tue, Sep 2, 2014 at 12:45 PM, Steven Yen wrote: > Is there a way to over-write a procedure (subroutine)? > > I include a default procedure f

[R] Writing .csv file

2014-09-24 Thread Steven Yen
I use the following command to write data to a .csv file: write.csv(yxz,file="foo.csv") And I get the following in the file, with one column appended to the file: "","fsp","fsec","cincome", "1",0,3,2.25,... "2",0,1,2.75,... "3",1,1,0.625,... Question: is there a way to avoid the first colu

Re: [R] Writing .csv file

2014-09-24 Thread Steven Yen
Wonderful. It worked like charms and I love it! Thank you Don. Steven At 05:06 PM 9/24/2014, Don McKenzie wrote: I believe you need to specify row.names = FALSE See the help for write.table() On Sep 24, 2014, at 2:00 PM, Steven Yen wrote: > I use the following command to write data t

[R] Reading text file with fortran format

2014-09-30 Thread Steven Yen
Hello I read data with fortran format: mydata<-read.fortran('foo.txt', c("4F10.4","F8.3","3F3.0","20F2.0")) colnames(mydata)<-c("q1","q2","q3","q4","income","hhsize", "weekend","dietk","quart1","quart2","quart3","male","age35", "age50","age65","midwest","south","west","no

Re: [R] Reading text file with fortran format

2014-09-30 Thread Steven Yen
Thanks to all. Steven Yen At 06:18 PM 9/30/2014, Nordlund, Dan (DSHS/RDA) wrote: > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- > project.org] On Behalf Of Steven Yen > Sent: Tuesday, September 30, 2014 2:04 PM > To: r-help > Su

[R] Reading text file with fortran format

2014-10-13 Thread Steven Yen
Hello Any idea how to read a text file with fortran format, WITH MULTIPLE RECORDS? My fortran format is as follows, and I do know I need to change F7.4 to F7.0, and 2F2.0 to 2I2, etc. I just have no idea how to handle the "slash" (/) which dictates a jump to the next record in fortran. Thank yo

[R] Checking if a matrix exists/is defined

2014-10-18 Thread Steven Yen
Hello Can someone help me with the following, specifically in judging whether a matrix exists. I have trouble with the first line below. In this case, matrix obj$hessian exists and is 74 x 74. I receive the error message: Warning message: In all(w$hessian) : coercing argument of type 'double' t

Re: [R] Checking if a matrix exists/is defined

2014-10-19 Thread Steven Yen
AM 10/19/2014, Richard M. Heiberger wrote: all() takes a logical argument, not numeric. See ?all I think you are looking for is.null(obj$hessian) If this isn't what you are looking for, please send a reproducible example to the entire list. Rich On Sun, Oct 19, 2014 at 12:17 AM, Ste

[R] Selecting rows/columns of a matrix

2014-10-26 Thread Steven Yen
Dear I am interested in selecting rows and columns of a matrix with a criterion defined by a binary indicator vector. Let matrix a be > a<-matrix(1:16, 4,4,byrow=T) > a [,1] [,2] [,3] [,4] [1,]1234 [2,]5678 [3,]9 10 11 12 [4,] 13 14 15 16

Re: [R] Selecting rows/columns of a matrix

2014-10-26 Thread Steven Yen
5 11 17 23 29 35 [6,]6 12 18 24 30 36 > (j<-matrix(c(0,1,0,1,0,1))) [,1] [1,]0 [2,]1 [3,]0 [4,]1 [5,]0 [6,]1 > ((a[as.logical(j), as.logical(j)])) [,1] [,2] [,3] [1,]8 20 32 [2,] 10 22 34 [3,] 12 24 36 Steven Yen

[R] Injecting a column of characters to a matrix of numerics

2014-10-29 Thread Steven Yen
before and after. Thanks. Steven Yen --- out<-round(cbind(me,se,t,p),digits) colnames(out)<-c("estimates","s.e.","|t-value|","p-value") rownames(out)<-rownames(me) out estimates s.e. |t-value| p-value (Intercept) 0.223263 0.146167

Re: [R] Injecting a column of characters to a matrix of numerics

2014-10-29 Thread Steven Yen
Wonderful. Works great! Steven Yen At 11:52 AM 10/29/2014, Kevin E. Thorpe wrote: On 10/29/2014 11:41 AM, Steven Yen wrote: Hello I am designing a regression printout, which works out nicely. Then, I try to inject a column of characters to indicate a discrete regressor with a dot (.). Then

[R] Removing rows in a data frame containing string in rownames

2014-11-16 Thread Steven Yen
I like to remove from a data frame rows with labels containing certain string, e.g., "sex" and "rating". Below is a list of the data frame and my failed attempt to the rows. Any clues? Thanks. > out est se t p disc p.(Intercept) 26.430 13.605 1.943 0.053 p.sex

Re: [R] Removing rows in a data frame containing string in rownames

2014-11-16 Thread Steven Yen
t all but the rows whose names contain the character sequences >"sex" or "rating". > >Bill Dunlap >TIBCO Software >wdunlap <http://tibco.com>tibco.com > >On Sun, Nov 16, 2014 at 6:31 PM, Steven Yen ><<mailto:sye...@gmail.com>sye...@gmail.

[R] Multrix-vector multiplication

2015-08-22 Thread Steven Yen
I had trouble with matrix multiplication when a matrix reduces to a vector. In the following, lines 1 and 2 work when matrices u and a are both of order 2. Lines 3 and 5 do not work (message is matrix not conformable) when u is (T x 1) and a is (1 x 2) and This causes a problem for users of other

[R] Calling external file

2015-10-03 Thread Steven Yen
ource' command. This does not work; it complains about a function (fn below) not defined. Compiling the function into a library file does not work either (with all sorts of error messages saying this and that not defined). Steven Yen fn <- function(beta){ f<-... (define f in this r

Re: [R] Calling external file

2015-10-03 Thread Steven Yen
3 - fix the errors I got from making it a package. It does not lie when it > tells you things are undefined and, who knows, they may need to be defined. > > > On 03/10/2015 09:47, Steven Yen wrote: > >> Hi >> I collect a list of calls to a package in a function (routine) so

Re: [R] Calling external file

2015-10-03 Thread Steven Yen
or source it from inside probit.R. Thanks. On Sat, Oct 3, 2015 at 4:47 AM, Steven Yen wrote: > Hi > I collect a list of calls to a package in a function (routine) so that I > do not need to repeat the same sets of codes from program to program. In > the following, inserting the func

[R] Construct a lower-triangular matrix

2015-10-09 Thread Steven Yen
Dear How do you construct a lower triangular matrix from a vector. I want to make vector a <- 1:10 into a triangular matrix 1 0 0 0 2 3 0 0 4 5 6 0 7 8 9 10 Thank you! [[alternative HTML version deleted]] __ R-help@r-project.org mailing

[R] Constructing a symmetric matrix using library(corpcor)

2016-02-17 Thread Steven Yen
Hello I am constructing a symmetric matrix with library "corpcor". In the codes below, I am able to construct a symmetric matrix of order 3 and 4. However, the 5 x 5 matrix does not seem right? Help? Thanks. > library(corpcor)> r <- 1:3> rr <- vec2sm(r, diag = F)> rr <- > rr[upper.tri(rr)]> r

[R] Constructing a symmetric matrix with library(corpcor)

2016-02-21 Thread Steven Yen
I like to compose a symmetric matrix in the pattern as shown below (for 3 x 3 and 4 x 4). For a symmetric matrix of order 5, the result does not seem right. Help? It is possible to write a two-level do loop for the task, but I suppose that is less efficient. > library(corpcor)> r <- 1:3; r[1] 1 2

[R] Retrieving response variable in the probit

2016-05-02 Thread Steven Yen
Can anyone tell me how to retrieve the response (dependent) variable from a probit regression object (as much as model.matrix(obj) retrieves the data matrix). Below is a self-runnable set of codes. Thank you! library(sampleSelection) data<-read.csv("https://dl.dropboxusercontent.com/u/220037024/Ye

[R] grep command

2016-05-03 Thread Steven Yen
Dear all In the grep command below, is there a way to identify only "age" and not "age2"? Thanks. > x<-c("abc","def","rst","xyz","age","age2") > x [1] "abc" "def" "rst" "xyz" "age" "age2" > grep("age2",x) [1] 6 > grep("age",x) # I need to grab "age" only, not "age2" [1] 5 6 Also, I post mess

[R] Grep command

2016-05-03 Thread Steven Yen
Dear all In the grep command below, is there a way to identify only "age" and not "age2"? In other words, I like to greb "age" and "age2" separately, one at a time. Thanks. x<-c("abc","def","rst","xyz","age","age2") x [1] "abc" "def" "rst" "xyz" "age" "age2" grep("age2",x) [1] 6 grep("age

[R] Fwd: Grep command

2016-05-03 Thread Steven Yen
) [1] 6 > grep("age\\b",x) [1] 5 > grep("age2$",x) [1] 6 > grep("age$",x) [1] From: Jim Lemon Date: Wed, May 4, 2016 at 2:19 AM Subject: Re: [R] Grep command To: Steven Yen Does not: abcplus<-c("zxzxabc","zxzxabc2rst") grepl("

[R] gls procedure in nlme

2017-01-04 Thread Steven Yen
I need help with gls{nlme}. Specifically, I am estimating an equation with AR(1) using maximum-likelihood. I am not understanding the correlationoption below. Help appreciated. === library(nlme) eq1<-log(chnimp)~log(chempi)+log(gas)+log(rtwex)+befile6+ affile6+afdec6 reg1<-gls(

[R] Echos for comment line (with #)

2017-02-11 Thread Steven Yen
I need help with what may be a simple option in R (or Rstudio)--to receive an echo of a comment line. Running the following two-line script in plain R, # adding 1+2 I did get the echo: > # adding > 1+2 [1] 3 > However, running the same lines in RStudio, the comment line does not appear in

[R] Calling a procedure

2020-09-20 Thread Steven Yen
Can someone tell me a proper call to a procedure, in this case, pnorm. In what follows, I had expected a = b, but they are not equal. What are wrong with first call and second call? Thank you! try<-function(x,log.p=FALSE){ a<-pnorm(x,log.p)   # first call b<-pnorm(x,log.p=log.p) # second ca

Re: [R] Calling a procedure

2020-09-20 Thread Steven Yen
he variable z. > > > f <- function(x, y = 0, z = FALSE){ >   a <- x >   b <- y >   d <- z >   list(a = a, b = b, d = d) > } > z <- 2 > f(1, z) > f(1, z = z) > > > Hope this helps, > > Rui Barradas > > Às 11:11 de 20/09/20, Steven Y

Re: [R] Calling a procedure

2020-09-20 Thread Steven Yen
d the  variables in with the same  order as the formal > arguments, then you > better  name them as you send them in. > > > > > > On Sun, Sep 20, 2020 at 7:23 AM Steven Yen <mailto:st...@ntu.edu.tw>> wrote: > > > Thanks. So, to be s

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

2020-10-05 Thread Steven Yen
I had to install/use an older version of (R-3.0.3) for a reason. While installing a package from CRAN (either in RStudio or R), I received the following warning message saying unable to access index for repository http://cran.rstudio.com/bin/windows/contrib/3.0. See message below. In this case,

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

2020-10-05 Thread Steven Yen
is 7 years old. You shoudl realy consider to update > to 4.0.2. > > Best, > Uwe Ligges > > > > > On 05.10.2020 09:56, Steven Yen wrote: >> I had to install/use an older version of (R-3.0.3) for a reason. While >> installing a package from CRAN (either in RStudio or

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

2020-10-05 Thread Steven Yen
chive.r-project.org') or use the contrib.url argument. Best, Uwe Ligges On 05.10.2020 10:47, Steven Yen wrote: Thanks for the help. I do update to the latest R-4.0.2. As I said, for reasons that's hard to explain, some of my tasks are better handled with an older version of R, in thi

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

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
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] [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] [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: >

[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] 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] 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] 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

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
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
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 下午

[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

  1   2   >