[R] boa package

2011-08-14 Thread Steven Yen
I am new to R. Have a naive question about the boa package. I loaded the package as instructed, and after entering R boa.menu() I could never got the ready prompt (R hung). Can someone help? Thanks. __ R-help@r-project.org mailing list

[R] Matrix element-by-element multiplication

2011-11-04 Thread Steven Yen
is there a way to do element-by-element multiplication as in Gauss and MATLAB, as shown below? Thanks. --- a 1.000 2.000 3.000 x 1.0002.0003.000 2.0004.0006.000 3.000

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

2011-11-06 Thread Steven Yen
difficult to see R's internal logic, which, while quirky, is useful at the end of the day. Michael PS - It's good form to cc the list at each step so others can follow along and contribute when I say something wrong. It also helps you get quicker answers. On Nov 6, 2011, at 1:06 AM, Steven Yen

Re: [R] Reading data/variables

2011-11-15 Thread Steven Yen
statistics for a dozen variables from a file that appeared to reside in z:/R. Am I not supposed to set the working directory by the line above (which brings me to my preferred working directory each time I run R)? At 06:05 PM 11/15/2011, Steven Yen wrote: Can someone help me with this variable/data

[R] Reading data/variables

2011-11-15 Thread Steven Yen
Can someone help me with this variable/data reading issue? I read a csv file and transform/create an additional variable (called y). The first set of commands below produced different sample statistics for hw11$y and y In the second set of command I renameuse the variable name yy, and sample

Re: [R] Reading data/variables

2011-11-17 Thread Steven Yen
/2011, Sarah Goslee wrote: Hi, The obvious answer is don't use attach() and you'll never have that problem. And see further comments inline. On Tue, Nov 15, 2011 at 6:05 PM, Steven Yen s...@utk.edu wrote: Can someone help me with this variable/data reading issue? I read a csv file and transform

[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

Re: [R] Overwriting a procedure

2014-09-24 Thread Steven Yen
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 sye...@gmail.com wrote: Is there a way to over-write a procedure (subroutine)? I include a default procedure fixx in a list

[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 column? Thanks.

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 sye...@gmail.com wrote: I use the following command

[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,nonmetro,

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 Subject: [R] Reading text file

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

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

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

2014-10-19 Thread Steven Yen
. 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, Steven Yen sye...@gmail.com wrote: Hello

[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
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 At 02:49 PM 10/26

[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 1.527459 0.127173 sex 0.049830 0.039612 1.257973

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

[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
or rating. Bill Dunlap TIBCO Software wdunlap http://tibco.comtibco.com On Sun, Nov 16, 2014 at 6:31 PM, Steven Yen mailto:sye...@gmail.comsye...@gmail.com wrote: 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

[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)) Fisher :

Re: [R] Checking if a logical variable exists

2014-12-14 Thread Steven Yen
- ifelse(!(Fisher %in% names(obj$spec)), FALSE, obj$spec$Fisher) Cheers, Ben On Dec 14, 2014, at 8:07 AM, Steven Yen sye...@gmail.com wrote: 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

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

[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
-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 sye...@gmail.com wrote: Dear I use sm2vec from package corpcor to puts the lower triagonal entries of a symmetric matrix (matrix

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

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.comsye...@gmail.com wrote: I like to multiple the first and second column of a 10 x 3 matrix by 100. The following did not work

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

2015-06-26 Thread Steven Yen
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 7:48 PM, Steven Yen wrote: Thanks

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

2015-06-25 Thread Steven Yen
places; though it may work fine in your test cases, it is wrong to be used in generality e.g. inside a function you provide for more general use, and is best replaced with the use of inherits() / is() everywhere out of principle. Martin Maechler ETH Zurich -- Steven Yen My e-mail alert: https

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) %in% c(integer, numeric

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

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

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

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

[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] Calling external file

2015-10-03 Thread Steven Yen
' 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 routine) re

Re: [R] Calling external file

2015-10-03 Thread Steven Yen
in to MaxLike > 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 fu

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 <sye...@gmail.com> 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 follo

Re: [R] read.fortran format

2016-05-27 Thread Steven Yen
ot;)), 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] 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

Re: [R] read.fortran format

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

[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

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

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

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

[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

[R] Fwd: Grep command

2016-05-04 Thread Steven Yen
x) [1] 6 > grep("age\\b",x) [1] 5 > grep("age2$",x) [1] 6 > grep("age$",x) [1] From: Jim Lemon <drjimle...@gmail.com> Date: Wed, May 4, 2016 at 2:19 AM Subject: Re: [R] Grep command To: Steven Yen <sye...@gmail.com> Does not: abcplus<-c(&

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

2016-07-20 Thread Steven Yen
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 <sye...@gmail.com >> <mailto:sye...@gmail.com>>wrote: >> >> I recentl

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 <sye...@gma

[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

[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
, > 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 Behalf Of

[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

Re: [R] t-test for regression estimate

2016-06-29 Thread Steven Yen
elopment 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 Message- >

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

[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

[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 <sye...@gmail.com> wrote: >> I need to have all elements o

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

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

[R] Problem with Rtools version 3.5.0.4

2018-08-01 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

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

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

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

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

[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

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

Re: [R] Polygon

2018-10-02 Thread Steven Yen
Continue 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 shaded area un

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

Re: [R] Printing with cat in a procedure

2018-12-22 Thread Steven Yen
t;\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 > print &g

Re: [R] Retrievable results in a procedure

2018-12-25 Thread Steven Yen
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 to print only

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

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

[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

Re: [R] Printing matrix/table in a procedure

2019-05-15 Thread Steven Yen
Great! Thanks. On 5/15/2019 7:00 PM, Rui Barradas wrote: > Hello, > > What's wrong with > > test <- function(x){ >   table <- matrix(x, nrow = 4) >   cat("\nTable:\n") >   print(table) >   invisible(list(table = table)) > } > > > Hope this h

[R] Problem with random numbers/seed

2019-06-21 Thread Steven Yen
Dear all, I did all this work with older R (R-3.5.3.patched and older) but now with R3.6 I cannot replicate the results. Below I sample 60 observations from 1:500 using the sample command with a random seed of 123. I get different results. Advice appreciated. Steven Yen > # Run under R-3.

Re: [R] Problem with random numbers/seed

2019-06-21 Thread Steven Yen
>  j<-sample(1:length(x),size=60); y<-x[j] >  summary(j) > > > Now I get the results you got udner the old R. > > Best, > Uwe Ligges > > > > On 21.06.2019 18:39, Steven Yen wrote: >> Thanks. Somewhat of a mystery. The older version I had was >&

Re: [R] Problem with random numbers/seed

2019-06-21 Thread Steven Yen
Unhappy but thanks. Steven On 6/22/2019 1:13 AM, Uwe Ligges wrote: > > > On 21.06.2019 19:09, Steven Yen wrote: >> Now I see that results were replicated but running RNGversion >> I get a warning message. Isn't there a way to do this clean? > > Well, the old RNG is kno

Re: [R] Problem with random numbers/seed

2019-06-21 Thread Steven Yen
Thanks. Somewhat of a mystery. The older version I had was R-3.5.3patched. I cannot get the RNGversion command to run. Can you help? Thanks. On 6/22/2019 12:25 AM, Uwe Ligges wrote: > See the NEWS, the RNG has been changed, use RNGversion > > On 21.06.2019 18:10, Steven Yen wrote: &g

[R] Printing matrix/table in a procedure

2019-05-15 Thread Steven Yen
Dear All, I would like to get a matrix (table) printed in a procedure, as attempted below. Please help. Thanks. test<-function(x){   table<-matrix(x,nrow=4)   cat("\nTable:\n",table) invisible(list(table=table)) } x<-1:20 test(x) -- st...@ntu.edu.tw (S.T. Yen) [[alternative HTML

[R] Warning from installing packages in R3.6.1

2019-09-14 Thread Steven Yen
Since updating to R3.6.1., I have received a WARNING message saying Rtools is required. I get the same message installing online from CRAN and from a .zip file. It looked like installation still went through in both cases, BUT, Another student installed a .zip file and received the following

Re: [R] Warning from installing packages in R3.6.1

2019-09-15 Thread Steven Yen
Can someone help me understand why Rtools is needed when installing a package from CRAN, and from a zipped file? What's the point? On 9/14/2019 10:29 PM, Steven Yen wrote: > Since updating to R3.6.1., I have received a WARNING message saying > Rtools is required. > I get the sam

Re: [R] Warning from installing packages in R3.6.1

2019-09-15 Thread Steven Yen
. Thank you. Steven Yen === > install.packages("C:/Users/Bonnie/Desktop/yenlib1_1.1.0.zip", repos = NULL, type = "win.binary") WARNING: Rtools is required to build R packages but is not currently installed. Please download and install the appropriate version of Rtools be

[R] Plotting in R

2019-07-06 Thread Steven Yen
I have a data frame containing two variables: year and rate (shown below). Which function can I use to plot rate (y-axis) against year (x-axis)? There will be more columns of rate later on. Thank you. year rate 1 1993 0.608 2 1994 0.622 3 1996 0.623 4 1998 0.647 5 2000 0.646 6 2002 0.625 7 2004

[R] Plotting in R

2019-07-06 Thread Steven Yen
I have a data frame containing two variables: year and rate (shown below). Which function can I use to plot rate (y-axis) against year (x-axis)? There will be more columns of rate later on. Thank you. year rate 1 1993 0.608 2 1994 0.622 3 1996 0.623 4 1998 0.647 5 2000 0.646 6 2002 0.625 7 2004

[R] Using older version of R

2019-12-20 Thread Steven Yen
I had to use an older version of R (as old as R3.0.3) for a reason. I myself have no problem installing a package built under a newer version, but my student (who also installed R3.0.3) could not install the package (newer version). Had an error message saying package x is not available

Re: [R] Rtools required

2020-04-29 Thread Steven Yen
Thanks. Updating RStudio to 1.2.5042 did fix the problem. Thank you! On 2020/4/28 下午 11:30, Duncan Murdoch wrote: On 28/04/2020 11:16 a.m., Steven Yen wrote: Thanks. Can you kindly tell me what to read to do it the "standard way"? Start with ?INSTALL, and find more details in the

  1   2   >