[R] optim with constraints

2009-12-06 Thread Steven
p the constraints so that the two parametrs of Weibull to be pisotive? Or should I use other function like"nlm"? Many thanks! Any comments are greatly appreciated! Steven __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/list

Re: [R] optim with constraints

2009-12-06 Thread Steven
0.25, 0.06), weibull.like, mydata = mydata, method = "L-BFGS-B", : non-finite finite-difference value [2] What does that mean? Much appreciate your help! Steven On Dec 7, 1:15 am, "Prof. John C Nash" wrote: > As per  ?optim > > > Usage: > > >      optim

[R] hist{graphics}

2019-07-12 Thread Steven
# Can someone help with this simple frequency histogram problem (n = 15)? # I use four class limits: [90,95], [95,100], [100,105], [105,110]. # These coincide with the limits obtain by pretty {base}. # Proper frequencies would be: (1,5,6,3). # But hist{graphics} gives me a histogram showing freque

Re: [R] hist{graphics}

2019-07-12 Thread Steven
Never mind. Thanks. I found that adding parameter right=F to the call fixes it. On 2019/7/12 下午 05:10, Steven wrote: # Can someone help with this simple frequency histogram problem (n = 15)? # I use four class limits: [90,95], [95,100], [100,105], [105,110]. # These coincide with the limits

[R] Printing vector

2019-07-21 Thread Steven
Is there a convenient way to print a vector into rows of a specified column length? What I need is to print in the old FORTRAN format, viz., format(10F8.2) which would print, for instance, a vector of 25 into two rows of 10 plus an incomplete row of 5. I managed to write a procedure for that ta

Re: [R] Printing vector

2019-07-21 Thread Steven
Dear All: Below is what I meant. Procedure print0 allows me to print a vector of length 53 in four rows of 10 plus 1 row of 3 (Ido not like the NA). This is silly. I am hoping that there is a candid way to print the matrix. Thank you. Steven Yen === n<-53; x<-runif(n); # x<-

Re: [R] Printing vector

2019-07-23 Thread Steven
's message did not reach me at all (not even in the junk mail box). But, obviously Bill had received it. Hmm. Steven Yen William Dunlap 於 2019/7/23 上午 12:33 寫道: > The following mimics Fortran printing with format > F.. > > print1 <- function (x, perLine = 10, fWidt

Re: [R] Printing vector

2019-07-23 Thread Steven
Very nice indeed. Thank you gentlemen. Steven Michael Friendly 於 2019/7/24 上午 01:23 寫道: Nice to see William Dunlap take the trouble to mimic the classic Fortran behavior of printing for numbers that don't fit in the given width :) -Michael On 7/22/19 6:33 p.m., William Dunlap

Re: [R] Printing vector

2019-07-23 Thread Steven
Thank you Lei. I incorporate Bill Dunlap's idea of flagging with FORTRAN stars when field width is short. It works great and serves what I need. Thank you all. I love R! Steven Linus Chen 於 2019/7/23 下午 05:46 寫道: Dear Steven, The function "write()" has a parameter "

[R] Rtools required

2020-04-28 Thread Steven
Dear All I updated to R-4.0.0. and also installed the latest Rtools 4.0 (to now the new default folder c:\rtools40). While compiling a package (binary) I received the follow marning message saying Rtools is required. Any clues? Thanks. Steven Yen WARNING: Rtools is required to build R

Re: [R] Rtools required

2020-04-29 Thread Steven
Thanks John. Where is file .Renviron located? It must be a hidden file. I cannot find it. On 2020/4/28 下午 08:29, Fox, John wrote: Dear Steven, Did you follow the instruction on the Rtools webpage to add PATH="${RTOOLS40_HOME}\usr\bin;${PATH}" to your .Renviron file? I

Re: [R] Rtools required

2020-04-29 Thread Steven
environ") > Sys.which("make")   make "C:\\rtools40\\usr\\bin\\make.exe" On 2020/4/28 下午 08:29, Fox, John wrote: Dear Steven, Did you follow the instruction on the Rtools webpage to add PATH="${RTOOLS40_HOME}\usr\bin

Re: [R] Rtools required

2020-04-30 Thread Steven
gs into it." -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) On Wed, Apr 29, 2020 at 6:48 PM Steven wrote: Thanks to all - very helpful. I search from c:\ and now find file .Renviron located in C:\Users\USER\Documents. That does it. I would like to pose an addi

Re: [R] Rtools required

2020-04-30 Thread Steven
ed to build a package". This is nonsense of course as they are, as I said, simply installing. I tell them to user an older RStudio version, specifically 1.1.463 that's free of that warning. Any idea? Steven Yen On 2020/4/30 上午 06:30, Fox, John wrote: Dear Steven, It's possible th

Re: [R] Rtools required

2020-05-01 Thread Steven
re in C:\Users\USER\AppData\Local\Temp\RtmpauyB5Q\downloaded_packages Packages -> Install Packages from local file > utils:::menuInstallLocal() package ‘yenlib1’ successfully unpacked and MD5 sums checked > On 2020/4/30 下午 04:38, Jeroen Ooms wrote: On Wed, Apr 29, 2020 at 11:37 PM Steven

[R] one-way ANOVA model, with one factor, an unbalanced design and unequal variances

2011-04-21 Thread Steven
hich seems to indicate that the aov function assumes equal variances. My question: is there an R function that performs a one-way ANOVA while not assuming a balanced design *or* equal variances? Does the oneway.test function, for example, assume a balanced design? Thanks, Steven -- View this

[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] analysis of covariance and constrained parameters

2018-02-16 Thread Steven Orzack
edge that these coefficients MUST BE 0 into my hypothesis testing. Knowing that these coefficients are 0 could influence the results of anova and AIC comparisons since it reduces the number of degrees of freedom associated with model. Many thanks for suggestions in advance! -- Steven Orzack Fres

[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] Loop Function to Create Multiple Scatterplots

2018-05-20 Thread STEVEN MANCINI
(wd) mydata <- read.csv("Glutamate.Genes.V1.csv") mydata plot(mydata$Age..weeks.post.conception., mydata$GluA1..GRIA1..Expression) plot(mydata$Age..weeks.post.conception., mydata$GluA2..GluR2.GRIA2..Expression), etc Thank you for your time and help. Regards, Steven ___

[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] Content Management System Built on R

2017-04-07 Thread Steven Nagy
d to R. Let me know if you know any user friendly CMS built on R. Thanks, Steven [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help

[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
deltaMethod from library "car" useful. Its just that, if linearHypothesis had provide the standard errors and t-statistics then the operation would have been easier, with a one-line command for each coefficient. Thank you again. On 6/28/2016 6:28 PM, Fox, John wrote: > Dear Steven, &

Re: [R] t-test for regression estimate

2016-06-29 Thread Steven Yen
Thanks John. Yes, by using verbose=T, I get the value of the hypothesis. But tell me again, how would I get the variance (standard error)? On 6/29/2016 11:56 AM, Fox, John wrote: > Dear Steven, > > OK -- that makes sense, and there was also a previous request for > linearHypothesis

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] PDF extraction with tm package

2016-07-21 Thread Steven Kang
Hi R users, I’m having some issues trying to extract texts from PDF file using tm package. Here are the steps that were carried out: 1. Downloaded and installed the following programs: - Xpdf (Copied the ‘bin32’, ‘bin64’, ‘doc’ folders into ‘C:\Program Files\Xpdf’ directory; also added C:\Progr

[R] Converting string to data frame

2016-07-28 Thread Steven Kang
fields and everything appeared to be fine except when the pipe wasn’t inserted as intended for the empty fields (ie as there are 5 fields, there should be 5 pipes, but this isn’t the case for records with empty field). Any suggestion would be much appreciated. Thanks. Steven [[alter

[R] poLCA - Latent Class Analysis - How long should analysis take?

2015-06-11 Thread Steven King
This is the script i am working from. library(poLCA) f <- cbind(bq70,bq72_1,bq72_2,bq72_3,bq72_4,bq72_5,bq72_6,bq72_7,bq73a_1,bq73a_2,bq73a_3,bq73a_4)~ zq88+zq89+dm_zq101_2+dm_zq101_3+dm_zq101_4+dm_zq101_5+dm_zq101_6+dm_zq101_7+dm_zq101_8+dm_zq101_9 for(i in 2:14){max_II<--100 min_bic<-10

[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] x11() hangs in 3.2.1

2015-07-31 Thread Steven Backus
I'm on RHEL 6.6, R version 3.2.1 Patched (2015-07-30 r68761) -- "World-Famous Astronaut". Issuing the x11() command hangs R and does not complete. A window is partially drawn then freezes. Does anyone know of a solution? Thanks, Steve -- Steven J. Backus

Re: [R] x11() hangs in 3.2.1

2015-07-31 Thread Steven Backus
igure and build > logs for warnings/errors. It is possible that you are missing an > X11 header or lib someplace. The config.log file has lots of errors but nothing obviously related to this problem. Thanks for your help, Steve -- Steven J. BackusComputer Sy

[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
Thanks. This worked!! :) Fisher <- ifelse(!("Fisher" %in% names(obj$spec)), FALSE, obj$spec$Fisher) Steven At 08:43 AM 12/14/2014, Ben Tupper wrote: Hi, Does this work for you? It simply tests if the name Fisher is found among the names of the elements of spec. obj = lis

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

Re: [R] Date extract Year

2015-03-08 Thread Steven Archambault
My date column is the excel numeric date format. For instance, in excel, that first date is 11 September 2012. On Mar 8, 2015, at 10:41 AM, Frederic Ntirenganya wrote: > Hi Steve, > > Can you please explain to us your date column? thanks. > > Regards, > Fredo. > On Mar 8, 2015 7:32 PM, "Steve

[R] Panel Data--filling in missing dates in a span only

2015-03-10 Thread Steven Archambault
Hi folks, I have this panel data (below), with observations missing in each of the panels. I want to fill in years for the missing data, but only those years within the span of the existing data. For instance, BC-0002 needs on year, 1995. I do not want any years after the last observation. str

[R] print and rbind within a for loop

2015-03-25 Thread Steven LeBlanc
rbind() to do anything is quite puzzling. Best Regards, Steven [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the postin

Re: [R] print and rbind within a for loop

2015-03-25 Thread Steven LeBlanc
return(result) } } Once again, commenting out the return() statement shows the correct output via the print() statement. Best Regards, Steven On Mar 25, 2015, at 12:51 PM, David R Forrest wrote: > From looking at it it looks like nothing is done with the results of rbind(), >

Re: [R] print and rbind within a for loop

2015-03-25 Thread Steven LeBlanc
Hi Dave, Bill, Thank you. That was it! Best Regards, Steven On Mar 25, 2015, at 1:11 PM, David R Forrest wrote: > I'm away from a computer that can check syntax, but make sure the return is > outside of the for loop. To my eye it looks inside. [[alternative HTML vers

[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
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 ticks -1.96 and 1.96. 2. Better yet, to draw vertical lines at x = -1.96 and x = 1.96. Thanks. Steven On 10/3/2018 12:51 AM, Rui Barradas wrote: > Hello, > > Cont

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
Thank you all - print works wonders. On 12/22/2018 10:36 PM, Eric Berger wrote: > Hi Steven, > Here's one way, using print > > try5<-function(A,B){ > C<-A+B > #cat("\nA =",A,"\nC = ",C) > cat("\nA = ") > print(A) > cat

[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] Using apply() with functions I wrote

2014-07-24 Thread Pfeiffer, Steven
Hello! Does apply() not work with customized functions? Here is a simple example: AddSeven<-function(n){n+7} AddSeven(3) [1] 10 M<-matrix(nrow=2,ncol=2,data=c(1,2,3,4),byrow=TRUE) M [,1] [,2] [1,]12 [2,]34 apply(x=M,margin

Re: [R] Using apply() with functions I wrote

2014-07-24 Thread Pfeiffer, Steven
ge > is certainly not wisdom." > Clifford Stoll > > > > > On Thu, Jul 24, 2014 at 10:07 AM, Pfeiffer, Steven > wrote: > > Hello! > > > > Does apply() not work with customized functions? Here is a simple > example: > > > > AddSeven<

[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
Thank you Rich. It works like a charm! Earlier I worked around by judging its determinant: dd<-NULL if (invH) dd<-det(obj$hessian) if (invH & exists("dd")){ ... } Now I do if (!is.null(obj$hessian) & invH){ ... } which is more direct. Thanks again. Steven At 01:50

[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
ommand got ignored. Hmm... Steven At 10:22 PM 11/16/2014, William Dunlap wrote: >Try grepl() to do pattern matching in strings. � ("%in%" checks for >equality.) � E.g., using your original 'out' do >� � out[ !grepl("sex|rating", rownames(out), ] >to ge

[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

  1   2   3   4   5   6   7   8   9   >