Re: [R] reshape non-square matrix
On Tue, 4 Mar 2014, Chirag Gupta wrote: Jeff This works fine for smaller ones but I have a big dataframe. Its ~35000 X 30. When I try this command, it says "Using as id variables". Thank you. You asked for a solution regarding a matrix. Now you talk about data frames. And in responding to Arun you have complained that it "takes away the names of the variables", leading me to question whether you really want what you have asked for because the "m,n,value" format has no room for the original names. (There are potential solutions to that problem, but they are outside of the scope of your original question.) Since you apparently don't know the difference between a matrix and a data frame, I will pass on responding further to this thread until you provide a reproducible example. This is because there are several potential problems introduced by applying this algorithm to arbitrary data frames. You should (re)read the Introduction to R regarding data frames and matrices (note particularly that each column of a data frame can be of a different type), and you should read [1] paying particular attention to how small amounts of sample data can be provided in your reproducible example. Also, please read the Posting Guide mentioned at the bottom of this email. In particular, that document requests that you NOT use HTML email format because what we see is usually not what you saw when you do that (which makes it very hard to understand what you are trying to tell us). [1] http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example On Sat, Mar 1, 2014 at 12:38 AM, Jeff Newmiller wrote: library(reshape2) mx <- matrix( 1:12, nrow=3 ) mxdf <- melt( mx ) names( mxdf ) <- c( "m", "n", "value" ) --- Jeff Newmiller The . . Go Live... DCN: Basics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/Batteries O.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --- Sent from my phone. Please excuse my brevity. On February 28, 2014 5:49:26 PM PST, Chirag Gupta wrote: >Hi list > >I have a matrix of size m x n (m and n are different, hence non >square!) >I want to melt it in such a way that I get a df of 3 columns. m ,n and >cell >value in the original matrix. > >Any suggestions? -- Chirag Gupta Department of Crop, Soil, and Environmental Sciences, 115 Plant Sciences Building, Fayetteville, Arkansas 72701 --- Jeff NewmillerThe . . Go Live... DCN:Basics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/BatteriesO.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k ---__ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] format for as.Date and inserting missing rows in a data frame
Hi > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- > project.org] On Behalf Of Stefano Sofia > Sent: Tuesday, March 04, 2014 11:58 AM > To: r-help@r-project.org > Subject: [R] format for as.Date and inserting missing rows in a data > frame > > Dear R users, > I have a very long data frame (50 years, more than 1.5 million rows) of > daily rainfall data from about 80 raingouges. > The data frame that I have been given looks like > > Raingouge_number Station_number Year Month Day Rainfall > 2004 2230 1951 1 1 2.60 > 2004 2230 1951 1 2 0.40 > 2004 2230 1951 1 3 0.00 > 2004 2230 1951 1 4 0.00 > 2004 2230 1951 1 5 0.20 > 2004 2230 1951 1 6 0.00 > 2004 2230 1951 1 7 0.00 > 2004 2230 1951 1 8 0.00 > 2004 2230 1951 1 9 0.00 > 2004 2230 1951 1 10 0.00 > ... > > There could be some missing days. I have two questions. > 1st question: > In order to handle eventual missing days I think that I have to > transform three separate numbers (Year, Month and Day) to Date. > Is there a format in as.Date suitable for this transformation or before > all I have to set all the months and days to two digits, remove spaces > and then apply as.Date with format "%Y%m%d"? This shall do it if you put dataframe name instead of ... as.Date(paste(...$Year, ...$Month, ...$Day, sep="."), format="%Y.%m.%d") > > 2nd question > In case of missing day, the corresponding row will be missing and then > I have to insert this new row and put -999.9 as Rainfall. Is there an > easy way to do that? Why? What is wrong with NA? What do you want to do with -999.9? Anyway, you can get sequence of dates ?seq.Date and merge it with your data. ?merge I do not help you to put -999.9 instead of NA as I consider it extremely silly. Regards Petr > > > Thank you for your help > Stefano > > > > > AVVISO IMPORTANTE: Questo messaggio di posta elettronica può contenere > informazioni confidenziali, pertanto è destinato solo a persone > autorizzate alla ricezione. I messaggi di posta elettronica per i > client di Regione Marche possono contenere informazioni confidenziali e > con privilegi legali. Se non si è il destinatario specificato, non > leggere, copiare, inoltrare o archiviare questo messaggio. Se si è > ricevuto questo messaggio per errore, inoltrarlo al mittente ed > eliminarlo completamente dal sistema del proprio computer. Ai sensi > dell’art. 6 della DGR n. 1394/2008 si segnala che, in caso di necessità > ed urgenza, la risposta al presente messaggio di posta elettronica può > essere visionata da persone estranee al destinatario. > IMPORTANT NOTICE: This e-mail message is intended to be received only > by persons entitled to receive the confidential information it may > contain. E-mail messages to clients of Regione Marche may contain > information that is confidential and legally privileged. Please do not > read, copy, forward, or store this message unless you are an intended > recipient of it. If you have received this message in error, please > forward it to the sender and delete it completely from your computer > system. > > [[alternative HTML version deleted]] Tento e-mail a jakékoliv k němu připojené dokumenty jsou důvěrné a jsou určeny pouze jeho adresátům. Jestliže jste obdržel(a) tento e-mail omylem, informujte laskavě neprodleně jeho odesílatele. Obsah tohoto emailu i s přílohami a jeho kopie vymažte ze svého systému. Nejste-li zamýšleným adresátem tohoto emailu, nejste oprávněni tento email jakkoliv užívat, rozšiřovat, kopírovat či zveřejňovat. Odesílatel e-mailu neodpovídá za eventuální škodu způsobenou modifikacemi či zpožděním přenosu e-mailu. V případě, že je tento e-mail součástí obchodního jednání: - vyhrazuje si odesílatel právo ukončit kdykoliv jednání o uzavření smlouvy, a to z jakéhokoliv důvodu i bez uvedení důvodu. - a obsahuje-li nabídku, je adresát oprávněn nabídku bezodkladně přijmout; Odesílatel tohoto e-mailu (nabídky) vylučuje přijetí nabídky ze strany příjemce s dodatkem či odchylkou. - trvá odesílatel na tom, že příslušná smlouva je uzavřena teprve výslovným dosažením shody na všech jejích náležitostech. - odesílatel tohoto emailu informuje, že není oprávněn uzavírat za společnost žádné smlouvy s výjimkou případů, kdy k tomu byl písemně zmocněn nebo písemně pověřen a takové pověření nebo plná moc byly adresátovi tohoto emailu případně osobě, kterou adresát zastupuje, předloženy nebo jejich existence je adresátovi či osobě jím zastoupené známá. This e-mail and any documents attached to it may be confidential and are intended only for its intended recipients. If you received this e-mail by mistake, please immediately inform its sender. Delete the contents of this e-mail with all attachments and its copies from your system. If you are not the intended recipient of this e-mail, you are not authorized to use, disseminate, copy or disclose this e-mail in any manner. The sender of this e-mail
Re: [R] reshape non-square matrix
Jeff This works fine for smaller ones but I have a big dataframe. Its ~35000 X 30. When I try this command, it says "Using as id variables". Thank you. On Sat, Mar 1, 2014 at 12:38 AM, Jeff Newmiller wrote: > library(reshape2) > mx <- matrix( 1:12, nrow=3 ) > mxdf <- melt( mx ) > names( mxdf ) <- c( "m", "n", "value" ) > > --- > Jeff NewmillerThe . . Go Live... > DCN:Basics: ##.#. ##.#. Live > Go... > Live: OO#.. Dead: OO#.. Playing > Research Engineer (Solar/BatteriesO.O#. #.O#. with > /Software/Embedded Controllers) .OO#. .OO#. rocks...1k > --- > Sent from my phone. Please excuse my brevity. > > On February 28, 2014 5:49:26 PM PST, Chirag Gupta > wrote: > >Hi list > > > >I have a matrix of size m x n (m and n are different, hence non > >square!) > >I want to melt it in such a way that I get a df of 3 columns. m ,n and > >cell > >value in the original matrix. > > > >Any suggestions? > > -- *Chirag Gupta* Department of Crop, Soil, and Environmental Sciences, 115 Plant Sciences Building, Fayetteville, Arkansas 72701 [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] problem with previous code
Hi Elio, If you change the last line of the code: m1[indx2N] <- m2[indx1] to m1[indx2N] <- m2[sort(indx1)] sum(m1[rownames(m1)=="p79",]) #[1] 191 sum(m2[rownames(m2)=="p79",]) #[1] 191 The problem is in the order of the colnames/rownames in each of the datasets. I tested it on something like: m1 <- matrix(0,12,12,dimnames=rep(list(paste0("a",1:12)),2)) set.seed(49) m2 <- matrix(sample(0:2,4*4,replace=TRUE),ncol=4,dimnames=rep(list(c("a4","a6","a9","a12")),2)) which didn't show the problem. But, if I change the order of colnames: m1 <- matrix(0,12,12,dimnames=rep(list(paste0("a",c(1:3,8:12,4:7))),2)) set.seed(49) m2 <- matrix(sample(0:2,4*4,replace=TRUE),ncol=4,dimnames=rep(list(c("a9","a4","a6","a12")),2)) vec1 <- paste0(rownames(m1)[row(m1)],colnames(m1)[col(m1)]) vec2 <- paste0(rownames(m2)[row(m2)],colnames(m2)[col(m2)]) indx <- match(vec1,vec2) indx1 <- indx[!is.na(indx)] indx2 <- match(vec2,vec1) indx2N <- indx2[!is.na(indx2)] m1[indx2N] <- m2[sort(indx1)] m1 Hope this helps. A.K. On Tuesday, March 4, 2014 3:16 PM, Elio Shijaku wrote: Hi Arun, Sorry to disturb, but while trying your code to combine two matrices of unequal dimensions, I noticed a problem, the sum for each variable does not match, but the overall variables sum does match for both matrices, something isn't going right, perhaps the variables are getting mixed up, any idea?? Here is the code you sent me and the zipped files for testing: dat1 <- read.table("mtest.txt",header=TRUE) dim(dat1) dat2 <- read.table("1998res_x.txt",header=TRUE) dim(dat2) m1 <- as.matrix(dat1) m2 <- as.matrix(dat2) vec1 <- paste0(rownames(m1)[row(m1)],colnames(m1)[col(m1)]) vec2 <- paste0(rownames(m2)[row(m2)],colnames(m2)[col(m2)]) indx <- match(vec1,vec2) indx1 <- indx[!is.na(indx)] indx2 <- match(vec2,vec1) indx2N <- indx2[!is.na(indx2)] m1[indx2N] <- m2[indx1] Thanks a lot!! Best, Elio __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Is this a mistake in 'An Introduction to R'?
In 'An Introduction to R', section 11.7 on nonlinear least squares fitting, the following example is given for obtaining the standard errors of the estimated parameters: "To obtain the approximate standard errors (SE) of the estimates we do: sqrt(diag(2*out$minimum/(length(y) - 2) * solve(out$hessian)))The 2 in the line above represents the number of parameters." I know the inverted Hessian is multiplied by the mean square error and that the denominator of the MSE is the degrees of freedom (number of samples - number of parameters) but why does the numerator of the MSE (which is the RSS) get multiplied by the number of parameters? I have read through explanations of the method for obtaining the SE but I don't see where the MSE gets multiplied by the number of parameters or why this is needed as shown in the example? Thanks for any help! Geoff Loveman Tech lead SMERAS QQ Maritime Life Support -- View this message in context: http://r.789695.n4.nabble.com/Is-this-a-mistake-in-An-Introduction-to-R-tp4686217.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] reshape non-square matrix
Hi, You didn't provide any reproducible example to start with. Using Jeff's example mx <- matrix( 1:12, nrow=3 ) dimnames(mx) <- list(1:nrow(mx),1:ncol(mx)) ## setNames(as.data.frame.table(mx),c("m","n","value")) m n value 1 1 1 1 2 2 1 2 3 3 1 3 4 1 2 4 5 2 2 5 6 3 2 6 7 1 3 7 8 2 3 8 9 3 3 9 10 1 4 10 11 2 4 11 12 3 4 12 mx1 <- matrix(1:12,nrow=3,ncol=4,dimnames=list(1:3,c("Col1","Col2","Col3","Col4"))) setNames(as.data.frame.table(mx1),c("m","n","value")) m n value 1 1 Col1 1 2 2 Col1 2 3 3 Col1 3 4 1 Col2 4 5 2 Col2 5 6 3 Col2 6 7 1 Col3 7 8 2 Col3 8 9 3 Col3 9 10 1 Col4 10 11 2 Col4 11 12 3 Col4 12 A.K. On Tuesday, March 4, 2014 9:39 PM, Chirag Gupta wrote: This takes away names of all the variables On Sat, Mar 1, 2014 at 9:30 AM, arun wrote: > >Hi, >You could try: >#If mat1 is the matrix >dimnames(mat1) <- list(1:nrow(mat1),1:ncol(mat1)) >setNames(as.data.frame.table(mat1),c("m","n","value")) >A.K. > > > >On Friday, February 28, 2014 11:40 PM, Chirag Gupta >wrote: >Hi list > >I have a matrix of size m x n (m and n are different, hence non square!) >I want to melt it in such a way that I get a df of 3 columns. m ,n and cell >value in the original matrix. > >Any suggestions? > >-- >*Chirag Gupta* > >Department of Crop, Soil, and Environmental Sciences, >115 Plant Sciences Building, Fayetteville, Arkansas 72701 > > [[alternative HTML version deleted]] > >__ >R-help@r-project.org mailing list >https://stat.ethz.ch/mailman/listinfo/r-help >PLEASE do read the posting guide http://www.R-project.org/posting-guide.html >and provide commented, minimal, self-contained, reproducible code. > > -- Chirag Gupta Department of Crop, Soil, and Environmental Sciences, 115 Plant Sciences Building, Fayetteville, Arkansas 72701 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] cross validation with variables which have one factor only
Dear R-team I did a model selection by AIC which explain me the habitat use of my animals in six different study sites (See attached files: cross_val_CORINE04032014.csv and cross_val_CORINE04032014.r). Sites were used as random factor because they are distributed over the Alps and so very different. In this way I also removed variables which exist in one study area only to do the model selection. In next, I tried to do a cross validation with the estimated best model for its prediction per site. That means I used model of five sites togehther against the remaining site. In this step I received an error: > val_10_fold_minger <- cv.glm(data= minger, glmfit = best_model_year, K = 10) Error in `contrasts<-`(`*tmp*`, value = contr.funs[1 + isOF[nn]]) : contrasts can be applied only to factors with 2 or more levels So for some of the model variables used in the model formula below there are actually not two factor levels (example=C324F where absence :153 but presence: 0 ) best_model_year <- glm(dung1_b ~ C231F+C324F+C332F, family=binomial(logit), minger) Does somebody know is there a possibility in cross validation methods which can deal with variables which have one factor only? Kindly Maik __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] reshape non-square matrix
This takes away names of all the variables On Sat, Mar 1, 2014 at 9:30 AM, arun wrote: > > > Hi, > You could try: > #If mat1 is the matrix > dimnames(mat1) <- list(1:nrow(mat1),1:ncol(mat1)) > setNames(as.data.frame.table(mat1),c("m","n","value")) > A.K. > > > On Friday, February 28, 2014 11:40 PM, Chirag Gupta > wrote: > Hi list > > I have a matrix of size m x n (m and n are different, hence non square!) > I want to melt it in such a way that I get a df of 3 columns. m ,n and cell > value in the original matrix. > > Any suggestions? > > -- > *Chirag Gupta* > Department of Crop, Soil, and Environmental Sciences, > 115 Plant Sciences Building, Fayetteville, Arkansas 72701 > > [[alternative HTML version deleted]] > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > > -- *Chirag Gupta* Department of Crop, Soil, and Environmental Sciences, 115 Plant Sciences Building, Fayetteville, Arkansas 72701 [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] format for as.Date and inserting missing rows in a data frame
Hi, May be this helps: dat <- read.table(text="Raingouge_number Station_number Year Month Day Rainfall 2004 2230 1951 1 1 2.60 2004 2230 1951 1 2 0.40 2004 2230 1951 1 3 0.00 2004 2230 1951 1 4 0.00 2004 2230 1951 1 5 0.20 2004 2230 1951 1 6 0.00 2004 2230 1951 1 7 0.00 2004 2230 1951 1 9 0.00 2004 2230 1951 1 10 0.00 2004 2230 1951 1 11 0.20",sep="",header=TRUE) dat <- within(dat,Date <- as.Date(paste(Year,Month,Day),format="%Y %m %d")) dat2 <- data.frame(Date=seq(dat$Date[1],dat$Date[length(dat$Date)],by="day")) res <- merge(dat,dat2,all=TRUE) res$Rainfall[is.na(res$Rainfall)] <- -999 res A.K. On Tuesday, March 4, 2014 5:58 AM, Stefano Sofia wrote: Dear R users, I have a very long data frame (50 years, more than 1.5 million rows) of daily rainfall data from about 80 raingouges. The data frame that I have been given looks like Raingouge_number Station_number Year Month Day Rainfall 2004 2230 1951 1 1 2.60 2004 2230 1951 1 2 0.40 2004 2230 1951 1 3 0.00 2004 2230 1951 1 4 0.00 2004 2230 1951 1 5 0.20 2004 2230 1951 1 6 0.00 2004 2230 1951 1 7 0.00 2004 2230 1951 1 8 0.00 2004 2230 1951 1 9 0.00 2004 2230 1951 1 10 0.00 ... There could be some missing days. I have two questions. 1st question: In order to handle eventual missing days I think that I have to transform three separate numbers (Year, Month and Day) to Date. Is there a format in as.Date suitable for this transformation or before all I have to set all the months and days to two digits, remove spaces and then apply as.Date with format "%Y%m%d"? 2nd question In case of missing day, the corresponding row will be missing and then I have to insert this new row and put -999.9 as Rainfall. Is there an easy way to do that? Thank you for your help Stefano AVVISO IMPORTANTE: Questo messaggio di posta elettronica può contenere informazioni confidenziali, pertanto è destinato solo a persone autorizzate alla ricezione. I messaggi di posta elettronica per i client di Regione Marche possono contenere informazioni confidenziali e con privilegi legali. Se non si è il destinatario specificato, non leggere, copiare, inoltrare o archiviare questo messaggio. Se si è ricevuto questo messaggio per errore, inoltrarlo al mittente ed eliminarlo completamente dal sistema del proprio computer. Ai sensi dell’art. 6 della DGR n. 1394/2008 si segnala che, in caso di necessità ed urgenza, la risposta al presente messaggio di posta elettronica può essere visionata da persone estranee al destinatario. IMPORTANT NOTICE: This e-mail message is intended to be received only by persons entitled to receive the confidential information it may contain. E-mail messages to clients of Regione Marche may contain information that is confidential and legally privileged. Please do not read, copy, forward, or store this message unless you are an intended recipient of it. If you have received this message in error, please forward it to the sender and delete it completely from your computer system. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Building R for better performance
Greetings, I'm a software engineer with Intel. Recently I've been investigating R performance on Intel Xeon and Xeon Phi processors and RH Linux. I've also compared the performance of R built with the Intel compilers and Intel Math Kernel Library to a "default" build (no config options) that uses the GNU compilers. To my dismay, I've found that the GNU build always runs on a single CPU core, even during matrix operations. The Intel build runs matrix operations on multiple cores, so it is much faster on those operations. Running the benchmark-2.5 on a 24 core Xeon system, the Intel build is 13x faster than the GNU build (21 seconds vs 275 seconds). Unfortunately, this advantage is not documented anywhere that I can see. Building with the Intel tools is very easy. Assuming the tools are installed in /opt/intel/composerxe, the process is simply (in bash shell): $ . /opt/intel/composerxe/bin/compilervars.sh intel64 $ ./configure --with-blas="-L/opt/intel/composerxe/mkl/lib/intel64 -lmkl_intel_lp64 -lmkl_intel_thread -lmkl_core -liomp5 -lpthread -lm" --with-lapack CC=icc CFLAGS=-O2 CXX=icpc CXXFLAGS=-O2 F77=ifort FFLAGS=-O2 FC=ifort FCFLAGS=-O2 $ make $ make check My questions are: 1) Do most system admins and/or R installers know about this performance difference, and use the Intel tools to build R? 2) Can we add information on the advantage of building with the Intel tools, and how to do it, to the installation instructions and FAQ? I can post my data if anyone is interested. Thanks, Jonathan Anspach Sr. Software Engineer Intel Corp. jonathan.p.ansp...@intel.com 713-751-9460 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] (no subject)
Dear all, I have a problem reading xlsx files in R. Could anybody help me how to resolve the problem? install.packages("xlsx", dependencies=TRUE) library(xlsx) library(rJava) data <- read.xlsx("3.1.xlsx", sheetIndex = 3.1) data <- read.xlsx("3.1.xlsx", sheetName= "a",as.data.frame=TRUE, header=TRUE) data <- read.xlsx("3.1.xlsx", 1) the error message is : Error in .jcall("RJavaTools", "Ljava/lang/Object;", "invokeMethod", cl, :  java.lang.OutOfMemoryError: GC overhead limit exceeded I also have problem in reading Rmpi library. I installed it correctly however when I read it by library(Rmpi) I received an error message: Error : .onLoad failed in loadNamespace() for 'Rmpi', details:  call: inDL(x, as.logical(local), as.logical(now), ...)  error: unable to load shared object 'C:/Users/Amir/Documents/R/win-library/3.0/Rmpi/libs/x64/Rmpi.dll':  LoadLibrary failure: The specified module could not be found. Error: package or namespace load failed for âRmpiâ My many many thanks your help in advance. Best, Amir [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Numbers at risk below cumulative incidence function plot
Hi guys I am using cmprsk-package for CIF plot but I would like to plot the numbers at risk for the different causes of failure at specific timepoints below a cumulative incidence function plotIs anybody know how can I make that plot or which package shall I use to make it?Thanks in advance! Sophia [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Specifying strip.names in Lattice plots
Hi Rich The first arguments for strip.default are which.given, which.panel, var.name, factor.levels, which means they take the names from the factors of each strip without a reproducible example here is something that may help data(esoph) levels(esoph$alcgp) xyplot(ncontrols ~ncases|alcgp, esoph, as.table = TRUE, par.settings = list(strip.background = list(col = "transparent"), axis.text = list(cex = 0.65), par.xlab.text = list(cex = 0.75), par.ylab.text = list(cex = 0.75) ), scales = list(x = list(alternating = FALSE, relation= "same", rot = 0), y = list(alternating = FALSE, relation= "same", rot = 0) ), strip= strip.custom(factor.levels = paste(gsub("[a-z/]","", levels(esoph$alcgp)), "g/day"), par.strip.text = list(cex = 0.65) ), ) If you have multiple conditioning see library(latticeExtra) ?useOuterStrips which have the arguments strip and strip.left there and you fill the text there levels(esoph$alcgp)) useOuterStrips(strip = strip.custom(factor.levels = paste(gsub("[a-z/]","", levels(esoph$alcgp)), "g/day"), par.strip.text = list(cex = 0.75)), strip.left = strip.custom(factor.levels = as.character(levels(esoph$agegp)), par.strip.text = list(cex = 0.75)), xyplot(ncontrols ~ncases|alcgp*agegp, esoph, as.table = TRUE, par.settings = list(strip.background = list(col = "transparent"), axis.text = list(cex = 0.65), par.xlab.text = list(cex = 0.75), par.ylab.text = list(cex = 0.75) ), scales = list(x = list(alternating = FALSE, relation= "same", rot = 0), y = list(alternating = FALSE, relation= "same", rot = 0) ), ) ) ## useOuterStrips Duncan Duncan Mackay Department of Agronomy and Soil Science University of New England Armidale NSW 2351 Email: home: mac...@northnet.com.au -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Rich Shepard Sent: Wednesday, 5 March 2014 05:49 To: r-help@r-project.org Subject: [R] Specifying strip.names in Lattice plots I've read Deepayan's book, ?strip, and ?strip.default, without learning how to specify strip names on xyplots. The following command produces the attached plot: xyplot(cbind(dalles.disch.ts, dalles.temp.ts), strip.left, main = "Columbia River @ The Dalles", xlab = "Date (Year.Month)", ylab = c("Temperature (C)","Discharge (cfs)")) However, when I try to specify names for each strip using panel functions I either get a blank plot or error messages. What I want to learn how to do is either 1) put the ylab in the strip or 2) eliminate the strip as redundant. TIA, Rich __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] [R-pkgs] New package on CRAN: greport
The first submission of the new greport package is now on CTAN. This package facilitates graphical reporting of clinical trials an is highly tied to LaTeX, Hmisc, and lattice. It creates hyperlinks and pop-up tooltips in the resulting pdf report. Tables are greatly de-emphasized, but hyperlinks take you from primary graphics to supporting tables in an appendix, which are hyperlinked back to the graphic. The package's web page, with example pdf reports, is at http://biostat.mc.vanderbilt.edu/Greport -- Frank E Harrell Jr Professor and Chairman School of Medicine Department of Biostatistics Vanderbilt University ___ R-packages mailing list r-packa...@r-project.org https://stat.ethz.ch/mailman/listinfo/r-packages __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] phlyloclim help
I suspect the space in the filename could be the throwing the parser off--you may need some "" around the filename or fill the space with an underscore. Clint Clint BowmanINTERNET: cl...@ecy.wa.gov Air Quality Modeler INTERNET: cl...@math.utah.edu Department of Ecology VOICE: (360) 407-6815 PO Box 47600FAX:(360) 407-7534 Olympia, WA 98504-7600 USPS: PO Box 47600, Olympia, WA 98504-7600 Parcels:300 Desmond Drive, Lacey, WA 98503-1274 On Mon, 3 Mar 2014, Dana Ikeda wrote: Hello! I'm trying to run a niche.equivalency.test and keep getting the following error: Error in file(fname, "r") : cannot open the connection In addition: Warning message: In file(fname, "r") : cannot open file 'C:/Users/Dana/Desktop/NicheIDresults/out/Populus arizona_proj.asc': No such file or directory Here's my code: app<-paste("C:/Users/Dana/Desktop/maxent/maxent.jar", sep="") files<-list.files(path = "G:/Research/Climate/WorldClim/Current/world/Fremont_genetics/AllPops/ascii/subset1", pattern = '[.]asc', all.files = FALSE, full.names = FALSE, recursive = FALSE, ignore.case = FALSE, include.dirs = FALSE, no.. = FALSE) env<-stack(files) as(env,'SpatialGridDataFrame') p<-read.csv("FremontPops_CAAZ.csv") dir<-paste("C:/Users/Dana/Desktop/NicheIDresults") test<-niche.equivalency.test(p, env, n=99, maxent.exe, dir) Maxent runs fine, and I can see the Populus arizona_proj.asc file in the "out" directory. Any ideas on what is going on? Thank you! Cheers, Dana -- Dana Ikeda, PhD Candidate Cottonwood Ecology Group Department of Biological Sciences Northern Arizona University Flagstaff, AZ 86011 [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to set up the plot region
Hi, Jim Thank you very much for your suggestion. But, x11() seems to be invalid for my computer. I have tried to use mar() to resolve this question. Thanks a lot. Best, Yichun > -åå§é®ä»¶- > å件人: "Jim Lemon" > åéæ¶é´: 2014å¹´3æ4æ¥ ææäº > æ¶ä»¶äºº: "å¼ ä»¥æ¥" > æé: r-help@r-project.org > 主é¢: Re: [R] How to set up the plot region > > On 03/04/2014 12:40 AM, å¼ ä»¥æ¥ wrote: > > Dear friends, > > > > > > I have a question don't know how to do. I want to plot two graphs in one > > column of one plot. Also, I want to make every graph to be a square with > > width to be 8cm, and their gap is 2cm. How do I set up in par()? Thank you > > very much. > > > > > > Yichun > > > Hi Yichun, > Your question is not entirely clear, but I'll try to make some > suggestions. If what you mean is the "figure" region (that's the plot > and the margins around it), you want something like this: > > x11(width=3.15,height=7.09) > layout(matrix(c(1,3,2),ncol=1),heights=c(1,0.25,1)) > plot(1:5) > plot(1:5) > > If you just want plots with nothing around them, maybe this: > > x11(width=3.15,height=7.09) > layout(matrix(c(1,3,2),ncol=1),heights=c(1,0.25,1)) > par(mar=c(0,0,0,0)) > plot(1:5,axes=FALSE) > box() > plot(1:5,axes=FALSE) > box() > > Jim -- Dr Yichun Zhang State Key Laboratory of Palaeobiology and Stratigraphy, Nanjing Institute of Geology and Palaeontology 39 East Beijing Road, Nanjing, China, 210008 [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Specifying strip.names in Lattice plots
I've read Deepayan's book, ?strip, and ?strip.default, without learning how to specify strip names on xyplots. The following command produces the attached plot: xyplot(cbind(dalles.disch.ts, dalles.temp.ts), strip.left, main = "Columbia River @ The Dalles", xlab = "Date (Year.Month)", ylab = c("Temperature (C)","Discharge (cfs)")) However, when I try to specify names for each strip using panel functions I either get a blank plot or error messages. What I want to learn how to do is either 1) put the ylab in the strip or 2) eliminate the strip as redundant. TIA, Rich col-riv-ts.pdf Description: Adobe PDF document __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Non-negative solution to an underdetermined linear system
On 04-03-2014, at 12:38, klq...@mail.bg wrote: > I don't have any cost function to minimize. My task is to create the "best" > matrix, matching the row sums, the column sums, row sumproducts (with the > rows from another constant matrix) and also column sumproducts - it's a > transportation problem of finding OD matrix corresponding the total tonnage > and tonne-kilometres. Maybe the more suitable function would be "lsei", but > it retuns also negative values for some X-es. Do you have an idea where in > the code to put some verification for non-negative results? > From the manual entry of lsei it seems that you should specify matrix G and vector h (inputs of lsei). Berend PS: Please do not post in HTML (see the posting guide). > Thanks in advance. > > Best Regards. > > > - Цитат от Berend Hasselman (b...@xs4all.nl), на 27.02.2014 в 21:09 - > >> >> On 27-02-2014, at 13:22, klq...@mail.bg wrote: >> >>> >>> >>> >>> Dear R users, >>> >>> >>> I have to find optimal solution of an underdetermined linear system, but >>> only with positive variables. I tried the function from this post >>> https://stat.ethz.ch/pipermail/r-help/2007-October/143408.html , but it's >>> solution includes also negative values. >>> >>> >> >> Have a look at package limSolve. Maybe (and only maybe) function linp can be >> of use. >> >> Berend >> >>> Thanks in advance. >>> >>> >>> Best Regards. >>> >>> - >>> >>> Майски празници на остров Лефкада, Гърция от 158 евро >>> Безкрайните романтични пясъци съчетани с узо... >>> Дати: 30/04/14 - 05/04/14 >>> http://www.arrivalsidi.com/%D0%BC%D0%B0%D0%B9%D1%81%D0%BA%D0%B8-%D0%BF%D1%80%D0%B0%D0%B7%D0%BD%D0%B8%D1%86%D0%B8/%D0%BC%D0%B0%D0%B9%D1%81%D0%BA%D0%B8-%D0%BF%D1%80%D0%B0%D0%B7%D0%BD%D0%B8%D1%86%D0%B8-%D0%B2-%D0%BB%D0%B5%D1%84%D0%BA%D0%B0%D0%B4%D0%B0 >>> [[alternative HTML version deleted]] >>> >>> __ >>> R-help@r-project.org mailing list >>> https://stat.ethz.ch/mailman/listinfo/r-help >>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html >>> and provide commented, minimal, self-contained, reproducible code. >> >> > > > > - > Mail.BG: Безплатен e-mail адрес. Най-добрите характеристики на българския > пазар - 20 GB пощенска кутия, 1 GB прикрепен файл, безплатен POP3, мобилна > версия, SMS известяване и други. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] From data frame to time series matrix and plot [RESOLVED]
On Mon, 3 Mar 2014, Rich Shepard wrote: I'm missing something simple here so a pointer is needed. Figured it out: I created two ts() objects, one for each parameter, then plotted them using cbind. Just need to tweak how the dates display on the x axis, but that should be doable. Rich __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Shortest connected path in a matrix
I have a binary rectangular T/F matrix; I need to be able to calculate the shortest path (i.e., Pythagorean distance) between a populated cell in row j and any populated cell in some row j+n. For instance, if I have a chessboard with random black/white square colors, I need the shortest distance (linear distance, not number of steps) for a king to get from a specified black space on the first row, to _any_ black space in a specified further row, traveling only on black spaces. Any idea? Thanks, -bryan [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Using indirect arguments in tapply
HI, I would use ?with() instead of ?attach. sMean <- with(sorted,tapply(PRICE,ITEM,mean)) sMean #Double Single Triple # 352.4 379.9 563.5 parameter <- data.frame(Pname,Iname,stringsAsFactors=FALSE) with(sorted,tapply(get(parameter[["Pname"]]),get(parameter[["Iname"]]),mean)) #Double Single Triple # 352.4 379.9 563.5 A.K. On Tue, 3/4/14, Barry King wrote: Subject: [R] Using indirect arguments in tapply To: "r-help@r-project.org" Date: Tuesday, March 4, 2014, 9:01 AM I am reading parameters from an Excel file but am having trouble using them in tapply. Here is a mini-version of my problem. sorted <- data.frame(c("Single","Single","Double","Double","Double", "Triple"), c(324.5, 435.3, 568.3, 345.4, 143.5, 563.5)) colnames(sorted) <- c("ITEM","PRICE") attach(sorted) sMean <- tapply(PRICE,ITEM,mean) # works but cannot use column names directly # since reading them from an Excel file into # a parameter file Pname <- c("PRICE") Iname <- c("ITEM") parameter <- data.frame(Pname,Iname) # This mimics reading the specific column names # from Excel # Now I want to indirectly reference the PRICE and ITEM columns but this does # not work as expected sMean2 <- tapply(parameter$Pname, parameter$Iname, mean) -- Any assistance would be greatly appreciated. __ *Barry E. King, Ph.D.* Chief Modeler Qualex Consulting Services, Inc. barry.k...@qlx.com O: (317)940-5464 M: (317)507-0661 __ [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] From data frame to time series matrix and plot [UPDATE]
On Tue, 4 Mar 2014, Rich Shepard wrote: Would xyplot() be a better function for these data? Here's the syntax for the xyplot() command; the output is attached. What have I done incorrectly here? xyplot(col.riv.ts, data = NULL, screens = 1, cut = FALSE, auto.key = TRUE) Data: structure(c(16126, 16127, 16128, 16129, 16130, 16131, 128000, 126000, 135000, 136000, 153000, 172000, 3.4, 3.5, 3.7, 4, 4.2, 4.1), .Dim = c(6L, 3L), .Dimnames = list(c("[787,]", "[788,]", "[789,]", "[790,]", "[791,]", "[792,]"), c("date", "disch", "temp" ))) Rich col.riv.ts-3.pdf Description: Adobe PDF document __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Using indirect arguments in tapply
Hello, Try instead sMean2 <- tapply(parameter[[Pname]], parameter[[Iname]], mean) Hope this helps, Rui Barradas Em 04-03-2014 17:01, Barry King escreveu: I am reading parameters from an Excel file but am having trouble using them in tapply. Here is a mini-version of my problem. sorted <- data.frame(c("Single","Single","Double","Double","Double", "Triple"), c(324.5, 435.3, 568.3, 345.4, 143.5, 563.5)) colnames(sorted) <- c("ITEM","PRICE") attach(sorted) sMean <- tapply(PRICE,ITEM,mean) # works but cannot use column names directly # since reading them from an Excel file into # a parameter file Pname <- c("PRICE") Iname <- c("ITEM") parameter <- data.frame(Pname,Iname) # This mimics reading the specific column names # from Excel # Now I want to indirectly reference the PRICE and ITEM columns but this does # not work as expected sMean2 <- tapply(parameter$Pname, parameter$Iname, mean) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] From data frame to time series matrix and plot [UPDATE]
On Mon, 3 Mar 2014, Rich Shepard wrote: I would like to plot (separately) time series for the 'disch' and 'tempMean' columns but have not had success in passing the correct syntax to the plot() function and having the x-axis labels as human-readable dates rather than the epoch time (which is what I assume is in the date class). Significant progress has been made, but I'm still not using the correct syntax. 1) I modified the original data frame to 3 columns: date, disch, and temp. 2) Using ts() I converted the data frame to a ts object. 3) After reading ?plot.ts and ?ts.plot I determined that the latter is appropriate for a multivariate time series on a single set of axes: plot.ts(col.riv.ts, plot.type = "single", xylabels = c("Date","Amount")) Warning messages: 1: In plot.window(xlim, ylim, log, ...) : "xylabels" is not a graphical parameter 2: In title(main = main, xlab = xlab, ylab = ylab, ...) : "xylabels" is not a graphical parameter 3: In axis(1, ...) : "xylabels" is not a graphical parameter 4: In axis(2, ...) : "xylabels" is not a graphical parameter 5: In box(...) : "xylabels" is not a graphical parameter But, not only have I not correctly specified xylabels, but the dates are not correctly presented (that is, as dates rather than numbers), and there are other options which I need to better understand. Would xyplot() be a better function for these data? Rich col.riv.ts-1.pdf Description: Adobe PDF document __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Using indirect arguments in tapply
I am reading parameters from an Excel file but am having trouble using them in tapply. Here is a mini-version of my problem. sorted <- data.frame(c("Single","Single","Double","Double","Double", "Triple"), c(324.5, 435.3, 568.3, 345.4, 143.5, 563.5)) colnames(sorted) <- c("ITEM","PRICE") attach(sorted) sMean <- tapply(PRICE,ITEM,mean) # works but cannot use column names directly # since reading them from an Excel file into # a parameter file Pname <- c("PRICE") Iname <- c("ITEM") parameter <- data.frame(Pname,Iname) # This mimics reading the specific column names # from Excel # Now I want to indirectly reference the PRICE and ITEM columns but this does # not work as expected sMean2 <- tapply(parameter$Pname, parameter$Iname, mean) -- Any assistance would be greatly appreciated. __ *Barry E. King, Ph.D.* Chief Modeler Qualex Consulting Services, Inc. barry.k...@qlx.com O: (317)940-5464 M: (317)507-0661 __ [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] [R-pkgs] rms package updated
Changes are listed below. NOTE: The next release of rms will replace the survfit.formula function with a new function named npsurv ("nonparametric survival estimates") so as to not conflict with the survival package. This is a NON-DOWNWARD-COMPATIBLE change. To get Kaplan-Meier estimates in the NEXT release use npsurv() instead of survfit(). The web site for more information about rms is http://biostat.mc.vanderbilt.edu/Rrms Changes in version 4.1-3 (2014-03-02) * num.intercepts: removed (is in Hmisc) * survfit.formula, cph, psm: changed to use inputAttributes attribute of Surv objects (introduced earlier in survival package so that rms could drop its customized Surv function) * Exported survfit.formula * Changed survival fitting functions and residuals to use units.Surv Changes in version 4.1-2 (2014-02-28) * psm: Fixed bug to allow computation of Dxy with left censoring * val.prob: Fixed recently introduced bug that made calibration intercept and slope always 0,1. Thanks: lars.engerst...@lio.se * plot.Predict: added between to leave space between panels * orm.fit: fixed error in kmid calculation when heavy ties at first level of y. Thanks: Yuwei Zhu * setPb: changed default to now use tktcl to show progress bars for simulations * predictrms: fixed bug with type='terms' * val.surv: handle case where survival estimates=0 or 1 when using log-log transform Changes in version 4.1-1 (2014-01-22) * Removed use of under.unix in anova.rms, latex.summary, plot.nomogram * Removed use of oldUnclass, oldClass, is.category * Fixed class of Rq object; had failed with bootcov. Thanks: Max Gordon * survplot: preserved par() * Srv: removed, changed all uses to Surv() for new survival package that preserves attributes for Surv inputs * survplot.survfit, survdiffplot: added conf='diffbands' * predictrms: fixed num. intercepts calculation order * survplot, survdiffplot: used original standard error for survdiffplot, and fun * dyx.cens: allow left-censoring -- Frank E Harrell Jr Professor and Chairman School of Medicine Department of Biostatistics Vanderbilt University ___ R-packages mailing list r-packa...@r-project.org https://stat.ethz.ch/mailman/listinfo/r-packages __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] [R-pkgs] New version of Hmisc package on CRAN
Recent changes include the following. Changes in version 3.14-2 (2014-02-26) * latex.default: improved logic using new function in Misc: latexBuild * latex.default: fixed bug with ctable=TRUE with no caption by removing default label * latex.default: improved formatting for insert.top * latex.default: added tests, fixed insert.bottom * latex.summaryM: return stat summary key as legend attribute, use this according to insert.bottom argument * latex.summary.formula.response: fixed bug related to computation of cdec. Thanks: Kevin Thorpe * latex.default: added new argument star: ctables uses this to spread over two columns when the LaTeX document is in \twocolumn mode. Thanks: David Whiting Changes in version 3.14-1 (2014-02-25) * Added latexNeedle function * Change latexTherm, latexNeedle to use user LaTeX macro \tooltipn to do the pop-up * latex.default: changed line breaks around \end{tabular} * latex.summaryM: put insert.bottom text in minipage so \tooltip will not devote wide space to it * sas.get: added defaultencoding argument and logic (Thanks: Reinhold Koch) * plot.summaryP: omit tick marks for proportion > 1.0 * format.df (used by latex): fixed na.blank logic for character var * latex: removed newlines when ending environments, added hyperref argument * latex: added center='centerline', fixed 'centering' * upData, cleanup.import, dataframeReduce: changed argument pr to print * rcspline.eval: added more evasive action in case of extreme ties Changes in version 3.14-0 (2014-01-22) * Added trans argument to varclus * Removed recode, existsFunction functions, under.unix object, survfitKM, functions used only by S-Plus: comment, mem, mulbar.chart, p.sunflowers * as.category, is.category, untangle.special: removed * Removed reference to .R. from many functions * Remove oldClass, oldUnclass, getFunction * latex.default: changed 'rotate' to 'sideways' for ctable mode. Thanks: Simon Zehnder * gView: removed * ldBands: removed * summaryP: new function - graphical replacement for tables of proportions * ynbind: new function for combining related yes/no variables into a matrix with a label * added file argument to prn * summaryP: added autoarrange * added addMarginal and nobsY functions * pBlock: new function for blocking variables for summaryP * summaryP: changed text positioning to grid absolutes, added text.at argument * scat1d, histSpike: if grid used and y has grid units, fixed logic for frac * plsmo, panel.plsmo: added scat1d.opts argument * label.Surv, units.Surv: added, removed ::: in survival calls * summarize: added keepcolnames argument * Suppressed startup message unless options(Hverbose=TRUE) is set * summaryS: new function - multi-panel lattice xy and dot plots * summaryD: added ylab argument * dotchart3: quit letting left margin be less than pre-existing one * multLines: new function * Improved nobsY to respect subject IDs when counting number of subjects, and to return an attribute 'formula' without id variable; changed bpplotM, summaryP, summaryS to use this * Removed nobsY calculations from bpplotM, summaryP, summaryS, enhanced nobsY to allow stratification by treatment * panel.bpplot: added violin and violin.opts arguments * summaryS: added medvPanel support during-plot vertical violin plots * plot.summaryP: padded x-axis limits * latexTabular: added translate and hline arguments; moved to its own file and help page * latexTherm: added tooltip using LaTeX ocgtools package * summaryP: stopped reversing order of panels * summaryM: added table.env argument, changed how model.frame built * latex.summaryM: changed to print proportions by default, added round='auto' * character.table: added xpd=NA; thanks: Dale * summaryP: added latex method * latex.default: added insert.top argument * summaryM: added stratification (multiple tables) -- Frank E Harrell Jr Professor and Chairman School of Medicine Department of Biostatistics Vanderbilt University ___ R-packages mailing list r-packa...@r-project.org https://stat.ethz.ch/mailman/listinfo/r-packages __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Non-negative solution to an underdetermined linear system
I don't have any cost function to minimize. My task is to create the "best" matrix, matching the row sums, the column sums, row sumproducts (with the rows from another constant matrix) and also column sumproducts - it's a transportation problem of finding OD matrix corresponding the total tonnage and tonne-kilometres. Maybe the more suitable function would be "lsei", but it retuns also negative values for some X-es. Do you have an idea where in the code to put some verification for non-negative results? Thanks in advance. Best Regards. - ЦиÑÐ°Ñ Ð¾Ñ Berend Hasselman (b...@xs4all.nl), на 27.02.2014 в 21:09 - On 27-02-2014, at 13:22, klq...@mail.bg wrote: Dear R users, I have to find optimal solution of an underdetermined linear system, but only with positive variables. I tried the function from this post https://stat.ethz.ch/pipermail/r-help/2007-October/143408.html , but it's solution includes also negative values. Have a look at package limSolve. Maybe (and only maybe) function linp can be of use. Berend Thanks in advance. Best Regards. - ÐайÑки пÑазниÑи на оÑÑÑов ÐеÑкада, ÐÑÑÑÐ¸Ñ Ð¾Ñ 158 евÑо ÐезкÑайниÑе ÑоманÑиÑни пÑÑÑÑи ÑÑÑеÑани Ñ Ñзо... ÐаÑи: 30/04/14 - 05/04/14 http://www.arrivalsidi.com/%D0%BC%D0%B0%D0%B9%D1%81%D0%BA%D0%B8-%D0%BF%D1%80%D0%B0%D0%B7%D0%BD%D0%B8%D1%86%D0%B8/%D0%BC%D0%B0%D0%B9%D1%81%D0%BA%D0%B8-%D0%BF%D1%80%D0%B0%D0%B7%D0%BD%D0%B8%D1%86%D0%B8-%D0%B2-%D0%BB%D0%B5%D1%84%D0%BA%D0%B0%D0%B4%D0%B0 [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. - Mail.BG: ÐезплаÑен e-mail адÑеÑ. Ðай-добÑиÑе Ñ Ð°ÑакÑеÑиÑÑики на бÑлгаÑÑÐºÐ¸Ñ Ð¿Ð°Ð·Ð°Ñ - 20 GB поÑенÑка кÑÑиÑ, 1 GB пÑикÑепен Ñайл, безплаÑен POP3, мобилна веÑÑиÑ, SMS извеÑÑÑване и дÑÑги. http://mail.bg [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] format for as.Date and inserting missing rows in a data frame
Dear R users, I have a very long data frame (50 years, more than 1.5 million rows) of daily rainfall data from about 80 raingouges. The data frame that I have been given looks like Raingouge_number Station_number Year Month Day Rainfall 2004 2230 1951 1 1 2.60 2004 2230 1951 1 2 0.40 2004 2230 1951 1 3 0.00 2004 2230 1951 1 4 0.00 2004 2230 1951 1 5 0.20 2004 2230 1951 1 6 0.00 2004 2230 1951 1 7 0.00 2004 2230 1951 1 8 0.00 2004 2230 1951 1 9 0.00 2004 2230 1951 1 10 0.00 ... There could be some missing days. I have two questions. 1st question: In order to handle eventual missing days I think that I have to transform three separate numbers (Year, Month and Day) to Date. Is there a format in as.Date suitable for this transformation or before all I have to set all the months and days to two digits, remove spaces and then apply as.Date with format "%Y%m%d"? 2nd question In case of missing day, the corresponding row will be missing and then I have to insert this new row and put -999.9 as Rainfall. Is there an easy way to do that? Thank you for your help Stefano AVVISO IMPORTANTE: Questo messaggio di posta elettronica può contenere informazioni confidenziali, pertanto è destinato solo a persone autorizzate alla ricezione. I messaggi di posta elettronica per i client di Regione Marche possono contenere informazioni confidenziali e con privilegi legali. Se non si è il destinatario specificato, non leggere, copiare, inoltrare o archiviare questo messaggio. Se si è ricevuto questo messaggio per errore, inoltrarlo al mittente ed eliminarlo completamente dal sistema del proprio computer. Ai sensi dellâart. 6 della DGR n. 1394/2008 si segnala che, in caso di necessità ed urgenza, la risposta al presente messaggio di posta elettronica può essere visionata da persone estranee al destinatario. IMPORTANT NOTICE: This e-mail message is intended to be received only by persons entitled to receive the confidential information it may contain. E-mail messages to clients of Regione Marche may contain information that is confidential and legally privileged. Please do not read, copy, forward, or store this message unless you are an intended recipient of it. If you have received this message in error, please forward it to the sender and delete it completely from your computer system. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] alternative to wireframe()
Hi I am slowly getting enough of wireframe() from the package lattice, as it is to complicated for what I need and does not really do what I want. I am using it to produce a (surprise!) wireframe plot (see example below). The plot function is part of plot.tss in a package which I am working on, and the plot looks nice, but I would like to have the option to use it as part of a layout(), which does not work. Also, I did not get a real handle if I have to wrap the wireframe function into a print(). So I am looking for a simpler alternative, which produces a similar plot to the one created by the example below. I would prefer a different legend and I would like to have the 3D plot respect the layout() command above. Any suggestions which function I could use? Thanks, Rainer --8<---cut here---start->8--- library(lattice) x <- structure(list(threshold1 = c(21, 74.5, 128, 181.5, 235, 21, 74.5, 128, 181.5, 235, 21, 74.5, 128, 181.5, 235, 21, 74.5, 128, 181.5, 235, 21, 74.5, 128, 181.5, 235), threshold2 = c(0, 0, 0, 0, 0, 61.25, 61.25, 61.25, 61.25, 61.25, 122.5, 122.5, 122.5, 122.5, 122.5, 183.75, 183.75, 183.75, 183.75, 183.75, 245, 245, 245, 245, 245), overallAccuracy = c(0.606076276664512, 0.606076276664512, 0.606076276664512, 0.606076276664512, 0.606076276664512, 0.594182288299935, 0.597026502908856, 0.605559146735617, 0.606076276664512, 0.606076276664512, 0.6120232708468, 0.62262443438914, 0.633742727860375, 0.611376858435682, 0.606076276664512, 0.618616677440207, 0.630122818358112, 0.706658047834518, 0.695151906916613, 0.606076276664512, 0.393923723335488, 0.405429864253394, 0.482740788623142, 0.58655462184874, 0.606076276664512), sensitivity = c(0, 0, 0, 0, 0, 0.012471283229406, 0.0118148999015425, 0.00393829996718083, 0, 0, 0.130620282244831, 0.126025598949787, 0.0912372825730226, 0.0141122415490647, 0, 0.598949786675418, 0.594355103380374, 0.526419428946505, 0.296685264194289, 0, 1, 0.995405316704956, 0.927469642271086, 0.661962586150312, 0), specificity = c(1, 1, 1, 1, 1, 0.972269624573379, 0.977389078498293, 0.996587030716723, 1, 1, 0.924914675767918, 0.945392491467577, 0.986348122866894, 0.99957337883959, 1, 0.631399317406143, 0.653370307167236, 0.823805460750853, 0.954138225255973, 1, 0, 0.0219709897610922, 0.193686006825939, 0.537542662116041, 1), tss = c(0, 0, 0, 0, 0, -0.0152590921972152, -0.010796021600164, 0.000525330683904368, 0, 0, 0.0555349580127491, 0.0714180904173634, 0.0775854054399168, 0.0136856203886551, 0, 0.230349104081562, 0.24772541054761, 0.350224889697358, 0.250823489450262, 0, 0, 0.0173763064660479, 0.121155649097025, 0.199505248266353, 0), kappa = c(0, 0, 0, 0, 0, -0.0182824920390604, -0.0129583064846108, 0.000635541910639162, 0, 0, 0.0639760122213153, 0.0828765513813943, 0.0918579943188013, 0.0165372451769894, 0, 0.223843122923358, 0.242311121014362, 0.363093208690974, 0.28206036774748, 0, 0, 0.0137627491763651, 0.100591615720438, 0.187264280971332, 0), pP = c(0L, 0L, 0L, 0L, 0L, 38L, 36L, 12L, 0L, 0L, 398L, 384L, 278L, 43L, 0L, 1825L, 1811L, 1604L, 904L, 0L, 3047L, 3033L, 2826L, 2017L, 0L), pA = c(0L, 0L, 0L, 0L, 0L, 130L, 106L, 16L, 0L, 0L, 352L, 256L, 64L, 2L, 0L, 1728L, 1625L, 826L, 215L, 0L, 4688L, 4585L, 3780L, 2168L, 0L), aA = c(4688L, 4688L, 4688L, 4688L, 4688L, 4558L, 4582L, 4672L, 4688L, 4688L, 4336L, 4432L, 4624L, 4686L, 4688L, 2960L, 3063L, 3862L, 4473L, 4688L, 0L, 103L, 908L, 2520L, 4688L), aP = c(3047L, 3047L, 3047L, 3047L, 3047L, 3009L, 3011L, 3035L, 3047L, 3047L, 2649L, 2663L, 2769L, 3004L, 3047L, 1222L, 1236L, 1443L, 2143L, 3047L, 0L, 14L, 221L, 1030L, 3047L), n = 7735L), .Names = c("threshold1", "threshold2", "overallAccuracy", "sensitivity", "specificity", "tss", "kappa", "pP", "pA", "aA", "aP", "n"), class = "TSS", link = .Primitive("&"), largerPres1 = TRUE, largerPres2 = FALSE, threshold1 = c(21, 74.5, 128, 181.5, 235), threshold2 = c(0, 61.25, 122.5, 183.75, 245), dimension = 2) columns <- c("tss", "sensitivity", "specificity") column.col <- rainbow(length(columns)) xp <- rep(x$threshold1, length(columns)) yp <- rep(x$threshold2, length(columns)) zp <- NULL for (i in 1:length(columns)) { zp <- c(zp, x[[columns[i]]]) } grp <- rep(columns, each=length(x$tss)) ### layout(matrix(1:4, ncol=2), c(1,2,3,4)) ### wireframe( zp ~ xp * yp, xlab = "threshold 1", ylab = "threshold 2", zlab = paste(columns, collapse="\n"), groups = grp, par.settings = simpleTheme( alpha = 0.7, col = column.col, ), scales = list(arrows = FALSE), auto.key = TRUE ) --8<---cut here---end--->8--- -- Rainer M. Krug email: RMKruggmailcom pgpZjhGpBQc3e.pgp Description: PGP signature __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://ww
Re: [R] delayedAssign list members
> delayedAssign("foo$bar", 2) > > foo$bar # 1 > > `foo$bar` # 2 Yes, you assign to the new variable `foo$bar`, not to bar component of the foo variable! You can use an environment for doing what you want: e <- new.env() e$bar <- 1 delayedAssign("bar", 2, assign.env = e) e$bar But notice also the eval.env= argument of delayedAssign()… Depending on what you want do, you have to provide this also. Note also that the use of environments, as well as playing with lazy evaluation are advanced techniques you should really well understand, or you will encounter many other surprises. Take care, for instance, about how you save and reload, or dump(), etc. environment objects, if that happens to be something you want do too. So, unless you really find an advantage with this, you would be better to continue using plain list() and try to forget about delayedAssign(). Best, Philippe Grosjean On 04 Mar 2014, at 09:23, "Shan Huang" wrote: > I am fascinated by lazy evaluation mechanism provided by delayedAssign. Like > > > > delayedAssign("foo", { > > Sys.sleep(1) # or any other time consuming operations > > 1 > > } > > > > Time consuming operations will be evaluated only if object "foo" is used. > > But when I try: > > > > foo <- list() > > foo$bar <- 1 > > delayedAssign("foo$bar", 2) > > foo$bar # 1 > > `foo$bar` # 2 > > > > Shows that delayedAssign can't be applied to list members, instead symbol > with "$" will be assigned. > > What I actually want is a lazy evaluation wrapper for large complex > hierarchical datasets. Like: > > > > MyDatasets <- list( > > Dataset1 = complexData1 > > Dataset2 = complexData2 > > ) > > > > There is no need for loading whole datasets when I only use Dataset1. And I > want to implement some > > incremental updating mechanism fetching data from remote host. > > Can any one give me some tips to implement this? > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] sub function problem
Hi, Despite OS is not provided, we can guess it is Windows, since Tinn-R works only on Windows. The error message is quite clear, I think: R must start a socket server in order for Tinn-R to communicate with it. Did you look at ?startSocketServer in the svSocket package? Then, you would have a clue of what it is. Now, why is your communication between Tinn-R and R broken once you have crashed R (or for some reasons, R did not close completely and a zombie R process remains in memory)? Simply because the zombie process has still the corresponding socket open, and you cannot start another R process and create a server on the same port. You have to kill the zombie first! In Linux, people are used to that kind of situation, but many Windows users have difficulties to deal with this. See for instance here: http://www.techrepublic.com/blog/windows-and-office/quick-tip-kill-rogue-processes-with-taskkill-in-microsoft-windows/3585/ Best, Philippe Grosjean On 04 Mar 2014, at 08:33, PIKAL Petr wrote: > Hi > > I also used Tinn-R but an old version 1.18.5.6 and did not experience such > error. Maybe you could try to use plain Notepad for your code just to check > if it is Tinn-R issue. > > I have no idea what the error means. However for anybody to have sensible > answer you definitelly need to reveal your OS, R version, Tinn-R version and > code which leads to such error. > > Regards > Petr > >> -Original Message- >> From: Massimiliano Tripoli [mailto:mtrip...@istat.it] >> Sent: Monday, March 03, 2014 5:39 PM >> To: PIKAL Petr >> Cc: r-help@r-project.org >> Subject: Re: [R] sub function problem >> >> Hi Petr, >> thanks for your response. >> You're right. I counted incorrectly the numbers of spaces at the >> beginning of the sub function directly called as you can see at the >> end. >> If the string has a length more than 10 it works correctly returning >> the same string of input except if there are some spaces at the >> beginning, that correctly it reduces to one as it expected. >> But what about the error 10061 that I usually encountered ? In this >> case I used Tinn-R (I know it's not a Tinn-R forum sorry). Is it >> correlated with it. >> >> Thanks >> >> >> >> - Messaggio originale - >> Da: "PIKAL Petr" >> A: "Massimiliano Tripoli" , r-help@r-project.org >> Inviato: Lunedì, 3 marzo 2014 10:36:02 >> Oggetto: RE: [R] sub function problem >> >> Hi >> >> Everything works for me as expected. Nothing happens R starts as usual. >> >> You can shorten your function >> >> corregge2 <- function(stringa){ >> nc <- nchar(stringa) >> stringa <- sub("^ ", "", stringa) >> stringa <- sub(" +$", "", stringa) >> if (nc <9) stringa <- NA >> if (nc == 9) stringa <- paste("0",stringa,sep="") if (nc == 10) stringa >> <- paste("00",stringa,sep="") stringa } >> >> What if your string has length more than 10? >> >> Regards >> Petr >> >>> -Original Message- >>> From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- >>> project.org] On Behalf Of Massimiliano Tripoli >>> Sent: Friday, February 28, 2014 5:44 PM >>> To: r-help@r-project.org >>> Subject: [R] sub function problem >>> >>> >>> Dear all, >>> >>> I write a R function that it should handles strings like removing >>> spaces at the beginning or returning NA according an IF condition. >>> Here you are the code: >>> >>> corregge.CF <- function(stringa){ >>> nc <- nchar(stringa) >>> stringa <- sub("^ ", "", stringa) >>> stringa <- sub(" +$", "", stringa) if (nc == 1) stringa <- NA if >>> (nc == 2) stringa <- NA if (nc == 3) stringa <- NA if (nc == 4) >>> stringa <- NA if (nc == 5) stringa <- NA if (nc == 6) stringa <- NA >> if >>> (nc == 7) stringa <- NA if (nc == 8) stringa <- NA if (nc == 9) >>> stringa <- paste("0",stringa,sep="") if (nc == 10) stringa <- >>> paste("00",stringa,sep="") >>>stringa >>> } >>> >>> I had this result: >>> corregge.CF <- function(stringa){ >>> + nc <- nchar(stringa) >>> + stringa <- sub("^ ", "", stringa) >>> + stringa <- sub(" +$", "", stringa) if (nc == 1) stringa <- NA >>> + if (nc == 2) stringa <- NA if (nc == 3) stringa <- NA if (nc == 4) >>> + stringa <- NA if (nc == 5) stringa <- NA if (nc == 6) stringa <- NA >>> + if (nc == 7) stringa <- NA if (nc == 8) stringa <- NA if (nc == 9) >>> + stringa <- paste("0",stringa,sep="") if (nc == 10) stringa <- >>> + paste("00",stringa,sep="") >>> + stringa >>> + } corregge.CF (" fsfhsfh") >>> [1] NA nchar(" fsfhsfh") >>> [1] 8 sub("^ ", "", " fghaghf") >>> [1] "fghaghf" >>> >>> And restarting R I had this message: >>> >>> Error:10061 >>> R is not in server mode. >>> Please, start R and/or run the startSocket Server function available >>> in svSocket package! >>> >>> Anyone could help me, >>> Thanks in advance >>> >>> >>> >>> -- >>> Massimiliano Tripoli >>> Collaboratore T.E.R. scado il 31/12/2014 ISTAT - DCCN - Direzione >>> Centrale della Contabilità N
[R] delayedAssign list members
I am fascinated by lazy evaluation mechanism provided by delayedAssign. Like delayedAssign("foo", { Sys.sleep(1) # or any other time consuming operations 1 } Time consuming operations will be evaluated only if object "foo" is used. But when I try: foo <- list() foo$bar <- 1 delayedAssign("foo$bar", 2) foo$bar # 1 `foo$bar` # 2 Shows that delayedAssign can't be applied to list members, instead symbol with "$" will be assigned. What I actually want is a lazy evaluation wrapper for large complex hierarchical datasets. Like: MyDatasets <- list( Dataset1 = complexData1 Dataset2 = complexData2 ) There is no need for loading whole datasets when I only use Dataset1. And I want to implement some incremental updating mechanism fetching data from remote host. Can any one give me some tips to implement this? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.