Re: [R] Symbolic computation in R-solving system of equations
Ryacas provides an interface to yacas from R. So my suggestion is to search the web to see if yacas can solve your specific problem. Regards Søren -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of jpm miao Sent: 16. august 2012 04:42 To: r-help Subject: [R] Symbolic computation in R-solving system of equations Hi, To my knowledge, Ryacas can do symbolic computation in R, like Mathematica or Maple. I wonder if it (or any other R package) can solve symbolically a system of equations? I have a system of four equations in four variables (non-linear, but not very hard to solve) and wonder if Ryacas or any other package can do it. I do not find the solution in Ryacas. Can it find a symbolic solution to a linear system? Thanks, Miao [[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] Reading one column .csv file
Worked! Thanks. David. -- View this message in context: http://r.789695.n4.nabble.com/Reading-one-column-csv-file-tp4640396p4640462.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.
[R] Question: Random generation from the Zero-truncated Negative Binomial dist.
Dear All, I would be very grateful if someone could answer the following question: I am trying to randomly generate values from the zero-truncated negative binomial distribution. I already found rposnegbin in the package VGAM. However, I need a detailed code since I am trying to export it to WinBugs. I noticed that the way out of this problem for the zero-truncated Poisson distribution is provided on the following page: https://stat.ethz.ch/pipermail/r-help/2005-May/070680.html . I was just wondering is there something similar for ZTNB? Thank you for your time and expertise. Kind regards, Andrius Budnikas [[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] Column Extraction from matrix
Hi all, I have a 4 by 100 matrix. I wish to extract each column and make it into a 2 by 2 matrix. I also want to assign names for each 2X2 matrix. For example set.seed(2) a=matrix(rnorm(400),ncol=100) a1=matrix(a[,1],ncol=2) a2=matrix(a[,2],ncol=2) . . . a100=matrix(a[,100],ncol=2) Any simple ideas. Thanks. B -- View this message in context: http://r.789695.n4.nabble.com/Column-Extraction-from-matrix-tp4640465.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.
[R] Error in family$linkfun(mustart) : Value 1.125 out of range (0, 1)
John/Michael, thanks for your comments. I get the following error when I run my code (the code is attached as is a section of the data set): Error in family$linkfun(mustart) : Value 1.125 out of range (0, 1) If anyone can please provide assistance that would be much appreciated - I'm not sure if it's something wrong with my dataset or a bug in the program list Many thanks, Dinuk On 08/16/12, John j...@surewest.net wrote: On Wed, 15 Aug 2012 17:59:53 +1000 Dinuk Jayasuriya dinuk.jayasur...@anu.edu.au wrote: Hi Jeff, Thank you - your comment was much appreciated. I'm now running an ordered probit regression and get the following error: Error in family$linkfun(mustart) : Value 1.125 out of range (0, 1) I can't decipher (after looking at other posts on google!) why this error occurs - is it something wrong with my dataset? If anyone can advise that would be very helpful. Thanks, Dinuk You need to supply considerably more information before you can expect much help. A subset of the data would help, since otherwise people are guessing. Also, if you look at the example here: http://www.ats.ucla.edu/stat/R/dae/probit.htm you may find some useful pointers. JWDougherty __ 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] Communative Matrix Multiplcation
David Reiner david.rei...@xrtrading.com on Wed, 15 Aug 2012 09:59:10 -0500 writes: As a mathematician, I have to correct the subject line to 'Distributive Matrix operations' -- David Yes, indeed; that was *really* disturbing to me as well, about this thread! {in addition to the fact that he should have used all.equal() and not identical() as someone had pointed out already ..} And at last: Yes, some of the methods for Diagonal() matrices in the 'Matrix' package did have bugs, in earlier versions. NOTE: You can (and often should) update packages also if for some reason you cannot update your version of R! Martin Maechler, ETH Zurich -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Doran, Harold Sent: Tuesday, August 14, 2012 12:55 PM To: Berend Hasselman Cc: 'r-help@r-project.org' Subject: Re: [R] Communative Matrix Multiplcation Thanks, Berend. I updated my R and got same result. I reposted the old sessionInfo(), which was an older version. But, same code, same matrices, different result -Original Message- From: Berend Hasselman [mailto:b...@xs4all.nl] Sent: Tuesday, August 14, 2012 1:49 PM To: Doran, Harold Cc: 'r-help@r-project.org' Subject: Re: [R] Communative Matrix Multiplcation On 14-08-2012, at 19:26, Doran, Harold wrote: I'm not seeing why the following occurs: T1 - (A1 - A2) %*% D T2 - (A1 %*% D) - (A2 %*% D) identical(T1, T2) [1] FALSE __ 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] Column Extraction from matrix
set.seed(2) a=matrix(rnorm(400),ncol=100) #use a list aList-list() for(i in 1:dim(a)[2]){ aList[[i]]-matrix(a[,i],ncol=2) } #get lots of variables for(i in 1:dim(a)[2]){ assign(paste(a,i,sep=),matrix(a[,i],ncol=2)) } On 16.08.2012, at 08:07, bantex wrote: Hi all, I have a 4 by 100 matrix. I wish to extract each column and make it into a 2 by 2 matrix. I also want to assign names for each 2X2 matrix. For example set.seed(2) a=matrix(rnorm(400),ncol=100) a1=matrix(a[,1],ncol=2) a2=matrix(a[,2],ncol=2) . . . a100=matrix(a[,100],ncol=2) Any simple ideas. Thanks. B -- View this message in context: http://r.789695.n4.nabble.com/Column-Extraction-from-matrix-tp4640465.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. __ 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] Variables and greek letters in a plot title
Hello This is a problem I encountered repeatedly and I found no answer that made me really happy. I hope it is not too trivial. I would like to give the concentration of a substance in a plot title: 5 ug/ml substance the '5' would be a variable and the ug should be micrograms (with greek letter mu). It is the mu that causes the problems for me. I failed using various combinations of paste, expression and bquote. I would be very grateful if someone could help me (or point me to the solution, which I might have overlooked). Thank you very much Dominik -- Dominik Refardt Institute of Integrative Biology, ETH Zürich [[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] reshape cast to a sparse matrix?
Yin Aphinyanaphongs yinnersp...@gmail.com on Tue, 14 Aug 2012 09:13:21 -0400 writes: I am using the reshape package to convert a series of values into a binary matrix. The binary matrix is very sparse with many zeros and I'd like to use cast to generate a sparse matrix using any of the sparse matrix packages of choice. Is there functionality to support this use? Well, the Matrix package (part of every R) has several convenient ways to construct sparse matrices, depending on their (special) structure. We mostly advertize sparseMatrix() which has a large 'Examples' section. If you want, you can contact me offline for more help, but you'd definitely have to provide more details, and a selfcontained example. Martin Maechler, ETH Zurich, one of the two 'Matrix' authors. Are there strategies or other packages that that may be useful? Due to memory constraints, it would be best to convert to sparse matrix on the fly rather than build the full matrix and then convert it. Thanks for the help, Yin __ 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] Variables and greek letters in a plot title
Hi Dominik, You can try x - 5 plot(rnorm(50), main=bquote(.(x) * mu * g/m^3 * substance)) Regards, - Jon On Thu, Aug 16, 2012 at 3:37 PM, Dominik Refardt dominik.refa...@gmail.com wrote: Hello This is a problem I encountered repeatedly and I found no answer that made me really happy. I hope it is not too trivial. I would like to give the concentration of a substance in a plot title: 5 ug/ml substance the '5' would be a variable and the ug should be micrograms (with greek letter mu). It is the mu that causes the problems for me. I failed using various combinations of paste, expression and bquote. I would be very grateful if someone could help me (or point me to the solution, which I might have overlooked). Thank you very much Dominik -- Dominik Refardt Institute of Integrative Biology, ETH Zürich [[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] Column Extraction from matrix
-Original Message- I have a 4 by 100 matrix. I wish to extract each column and make it into a 2 by 2 matrix. #make a toy 4x100 matrix: m - matrix(rnorm(400), ncol=100) #use lapply after on-the-fly conversion to a list-like object: a.list - lapply(as.data.frame(m),function(x) matrix(x, ncol=2)) #a list of 4x4 matrices with default names V1...V100 I also want to assign names for each 2X2 matrix. names(a.list) - paste(a, 1:length(a.list), sep=) #a list of 4x4 matrices with default names a1...a100 If you don't care too much about preserving m, set column names on m first, via colnames(m) - paste(a, 1:dim(m)[2], sep=) a.list - lapply(as.data.frame(m),function(x) matrix(x, ncol=2)) #now returns the column names set on m If you really want separate variables cluttering up your workspace you would need to wrap it into a loop like for(i in 1:100) assign(paste('a',i, sep=''), matrix(m[,i], ncol=2)) But I would advise against that unless there is very good reason: it is awkward to reference many objects, and if they are in a named (or unnamed) list you can nearly always use various forms of lapply, or loops, applied to the list instead. For example, to get the determinants of all these little matrices sapply(a.list, det) works much more simply than some awkward loop code that constructs the variable names, uses get to reference them and then has to find somewhere to put all the determinants. *** This email and any attachments are confidential. Any use...{{dropped:8}} __ 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] Variables and greek letters in a plot title
I would like to give the concentration of a substance in a plot title: 5 ug/ml substance Examples of including a variable in text are given in the ?plotmath page, under ## How to combine math and numeric variables. For your case, plot(1:10) conc=5 title(main=bquote(.(conc)~mu*g/ml substance)) works. S *** This email and any attachments are confidential. Any use...{{dropped:8}} __ 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] Communative Matrix Multiplcation
Thanks to you both. I'm not sure all.equal() was right for this situation, is it? If the differences were to the right of the decimal and differed as a function of precision, then I see all.equal() being the right function. But, the differences in the reproducible code were to the left of the decimal, but a lot, so I thought identical was perhaps better. Martin, there seem to be some issues with calculations in the updated Matrix package. I'll send an email to matrix authors. It seems some calculations that were almost instantaneous with older versions are now causing R to hang. I'll provide reproducible examples. From: Martin Maechler [maech...@stat.math.ethz.ch] Sent: Thursday, August 16, 2012 3:42 AM To: David Reiner Cc: Doran, Harold; 'r-help@r-project.org' Subject: Re: [R] Communative Matrix Multiplcation David Reiner david.rei...@xrtrading.com on Wed, 15 Aug 2012 09:59:10 -0500 writes: As a mathematician, I have to correct the subject line to 'Distributive Matrix operations' -- David Yes, indeed; that was *really* disturbing to me as well, about this thread! {in addition to the fact that he should have used all.equal() and not identical() as someone had pointed out already ..} And at last: Yes, some of the methods for Diagonal() matrices in the 'Matrix' package did have bugs, in earlier versions. NOTE: You can (and often should) update packages also if for some reason you cannot update your version of R! Martin Maechler, ETH Zurich -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Doran, Harold Sent: Tuesday, August 14, 2012 12:55 PM To: Berend Hasselman Cc: 'r-help@r-project.org' Subject: Re: [R] Communative Matrix Multiplcation Thanks, Berend. I updated my R and got same result. I reposted the old sessionInfo(), which was an older version. But, same code, same matrices, different result -Original Message- From: Berend Hasselman [mailto:b...@xs4all.nl] Sent: Tuesday, August 14, 2012 1:49 PM To: Doran, Harold Cc: 'r-help@r-project.org' Subject: Re: [R] Communative Matrix Multiplcation On 14-08-2012, at 19:26, Doran, Harold wrote: I'm not seeing why the following occurs: T1 - (A1 - A2) %*% D T2 - (A1 %*% D) - (A2 %*% D) identical(T1, T2) [1] FALSE __ 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] Variables and greek letters in a plot title
On Aug 16, 2012, at 09:37 , Dominik Refardt wrote: Hello This is a problem I encountered repeatedly and I found no answer that made me really happy. I hope it is not too trivial. I would like to give the concentration of a substance in a plot title: 5 ug/ml substance the '5' would be a variable and the ug should be micrograms (with greek letter mu). It is the mu that causes the problems for me. I failed using various combinations of paste, expression and bquote. I would be very grateful if someone could help me (or point me to the solution, which I might have overlooked). Like this? plot(0,0) conc - 5 title(main=bquote(.(conc)* *mu*g/ml* substance)) -- Peter Dalgaard, Professor Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Email: pd@cbs.dk Priv: pda...@gmail.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] twitteR location? - heading off topic
That worked but how do you get the location of one particular tweet. You are teetering on the edge of potential stalking here, since locating a specific tweet implies locating a specific individual. In some countries that can be a problem. Location is currently disabled by default in twitter; a user must choose to enable it for location to be available. That would constitute a clear decision to publish location. No sensible judiciary would regard it as an offence, of itself, to access an individual's location when the individual has themselves has chosen to publish it to a public place such as the web. But intent matters: as they say, it's what you do with it that counts. You might land yourself with having to defend the intent. So you're not wrong to raise the issue. *** This email and any attachments are confidential. Any use...{{dropped:8}} __ 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] Communative Matrix Multiplcation
Thanks to you both. I'm not sure all.equal() was right for this situation, is it? If the differences were to the right of the decimal and differed as a function of precision, then I see all.equal() being the right function. But, the differences in the reproducible code were to the left of the decimal, but a lot, so I thought identical was perhaps better. You are right that the difference was dramatic, and hence your posting was well in place, well, would have, iff it had been earlier, when that version of Matrix was current (... looking it up: the next version after the one you used, was 0.999375-47, CRAN-released: 2011-02-23; and there were *many* releases since, notably 1.0-0 1.0-1 the latter released 2011-10-18.) However, using identical() for comparisons of the results of double precision computations is almost always wrong, in principle: identical() very often can give FALSE notably from such simple changes as algebraical shuffling (commutative, associative, distributive laws), and indeed these things are covered by the BFMFAQ (By Far Most Frequently Asked Question) 7.31. Martin, there seem to be some issues with calculations in the updated Matrix package. I'll send an email to matrix authors. It seems some calculations that were almost instantaneous with older versions are now causing R to hang. I'll provide reproducible examples. Thank you in advance! Martin From: Martin Maechler [maech...@stat.math.ethz.ch] Sent: Thursday, August 16, 2012 3:42 AM To: David Reiner Cc: Doran, Harold; 'r-help@r-project.org' Subject: Re: [R] Communative Matrix Multiplcation David Reiner david.rei...@xrtrading.com on Wed, 15 Aug 2012 09:59:10 -0500 writes: As a mathematician, I have to correct the subject line to 'Distributive Matrix operations' -- David Yes, indeed; that was *really* disturbing to me as well, about this thread! {in addition to the fact that he should have used all.equal() and not identical() as someone had pointed out already ..} And at last: Yes, some of the methods for Diagonal() matrices in the 'Matrix' package did have bugs, in earlier versions. NOTE: You can (and often should) update packages also if for some reason you cannot update your version of R! Martin Maechler, ETH Zurich On 14-08-2012, at 19:26, Doran, Harold wrote: I'm not seeing why the following occurs: T1 - (A1 - A2) %*% D T2 - (A1 %*% D) - (A2 %*% D) identical(T1, T2) [1] FALSE __ 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] Color-coded Biplot of Varimax rotated factors from PCA based factor analysis
Hi Without some data it is difficult to say where is difference. However from code below it seems to me that it is an adaptation from my attempt to produce colour coded points on biplot. http://tolstoy.newcastle.edu.au/R/e4/help/08/08/20012.html fit-princomp(iris[,1:4], cor=T) biplot(fit, xlabs=rep(, nrow(iris))) rrr-apply(fit$scores[,1:2],2, range) par(usr=as.vector(rrr)) points(fit$scores[,1:2], col=rainbow(4)[(as.numeric(iris[,5]))], pch=20) This results in presenting points coloured according to some rules but the points are slightly shifted from those made by biplot itself. So AFAIK you either can use biplot and no colouring or use the code to present faked coloured points slightly shifted. Compare with just biplot(fit) points(fit$scores[,1:2], col=rainbow(4)[(as.numeric(iris[,5]))], pch=20) But maybe something changed from 2008 and now biplot with coloured point is available somewhere. Regards Petr I'm using R for PCA and? factor analysis. I want to create biplots of varimax rotated factors that color-code points by their classification. My research is on streams that are urban and rural. So, I want to color code them by this classification. If you just do a biplot from prcomp or princomp, you cannot add this color. So, I have used some code developed by a graduate student in our statistics department here at NC State University. However, when you compare the two biplots, the observed points are not in the same location. The variable vectors match up, but not the points. I'm not sure why. The code is below. Please help. label=data[,Urban.Rural] indexU-which(label==U) indexR-which(label==R) collab-rep(0,length(data[,1])) collab[indexU]-Blue collab[indexR]-Green library(psych) fit - principal(mydata, nfactors = num.fac, rotate=varimax, scores = TRUE) z1 - sum(fit2$loadings[,1]^2) ### need to scale scores and loadings by these factors z2 - sum(fit2$loadings[,2]^2) biplot(fit$scores[,c(1,2)]/c(z1, z2), loadings(fit)[,c(1,2)]*c(z1, z2), xlabs=rep(, length(collab)), col = c(black, orange)) legend(x=bottomright, legend=c(Urban,Rural), text.col=c(Blue,Green), bg=Grey90) ### scale the plot parameters rrr-apply(fit$scores[,1:2],2, range) (abs(rrr)+.1)*sign(rrr) par(usr=as.vector(rrr)) ### now include the colored points points(fit$scores[,c(1,2)], col=collab, pch=20) [[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] Not able to filter factor, class
Hi After importing data from Excel through ODBC. In the inclusion dataset, class(inclusion$Value) is coming as factor. After filtering the data, length(inclusion$Value == 0),the answer is coming as 4879, but actually Value contains only 225 rows. So how can I How do you know? What does str(inclusion) and dim(inclusion) says about your data. get the length as 225. Can anyone help? setwd(D:/AZ) library(RODBC) cdb_cnct - odbcConnectExcel(AZIF_DC_GVK_NSCLC_MSALL_287papers_02072012_141450_v1_ 4.xls) arm - sqlFetch(cdb_cnct, Arm) inclusion - sqlFetch(cdb_cnct, Inclusion) odbcClose(cdb_cnct) rm(cdb_cnct) names(inclusion) [1] Trial_Design_IDReference_ID Inclusion_Criteria [4] Value F5 F6 class(inclusion$Value) [1] factor nrow(inclusion) [1] 4879 length(inclusion$Value == 0) [1] 4879 length(inclusion$Value == 0) [1] 4879 Any from the above gives you logical vector with same length as inclusion$Value. If you want only TRUE values use ?subset or ?[ to select those values. Regards Petr Notice: The information contained in this electronic mail message is intended only for the use of the designated recipient. This message is privileged and confidential. and the property of GVK BIO or its affiliates and subsidiaries. If the reader of this message is not the intended recipient or an agent responsible for delivering it to the intended recipient, you are hereby notified that you have received this message in error and that any review, dissemination, distribution, or copying of this message is strictly prohibited. If you have received this communication in error, please notify us immediately by telephone +91-40-6692tel:%2B91-40-6692 and destroy any and all copies of this message in your possession (whether hard copies or electronically stored copies). [[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] How to call patchDVI::SweavePDF on an .Rnw which is not the master file?
Dear expeRts, I have a master file master.tex containing the preamble and which inputs (via \input{chapter01}, \input{chapter02}, ...) chapters. The chapters are .Rnw files. My goal is to use patchDVI::SweavePDF to compile the chapters (say, chapter.Rnw) individually (each chapter starts with sourcing Sweave preliminary settings). The first problem is the following. If I execute (in the shell) , | Rscript -e patchDVI::SweavePDF('chapter.Rnw') ` I obtain , | Loading required package: grDevices | Error: ‘chapter.Rnw’ is not ASCII and does not declare an encoding | Execution halted ` Normally one uses \usepackage[utf8]{inputenc} to solve this problem. However, I can't put this into chapter.Rnw since it is only allowed in the preamble, so in master.tex. But there it has no effect. The question is how to solve this. By looking at 'standard Sweave', I found the call , | R CMD Sweave --encoding=utf-8 chapter.Rnw ` which works fine. But I don't know how to pass the --encoding=utf-8 option to Rscript or how to use R CMD ... to solve the problem. The second (follow-up) problem should then be simple: How to call that from Emacs. Ideally, something like the following should work, but one somehow needs too many , ', ... to create the string Rscript ...: , | (add-hook 'Rnw-mode-hook | (lambda () | (add-to-list 'TeX-command-list |'(SweavePDF Rscript -e 'patchDVI::SweavePDF('%s', and-other-options) | TeX-run-command nil t :help Run SweavePDF) t); TODO: not working yet | (add-to-list 'TeX-command-list |'(Sweave R CMD Sweave --encoding=utf-8 %s | TeX-run-command nil t :help Run Sweave) t) | (add-to-list 'TeX-command-list |'(Stangle R CMD Stangle --encoding=utf-8 %s | TeX-run-command nil t :help Run Stangle) t) | (add-to-list 'TeX-command-list |'(make make TeX-run-command nil t :help Run make) t) | (setq TeX-command-default SweavePDF))) ` If anybody already has such a setup, I'd be happy to know about it. Cheers, Marius __ 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] sensitivity and specificity in svyglm??
Sensitivity and specificity are improper scoring rules so beware. They are optimized by a bogus model. Frank Diana Marcela Martinez Ruiz wrote Hello, As obtained from a table svyglm clasificaion, sensitivity and specificity. The funtion ConfusionMatrix () of the library (caret) gives these results but not how to apply it to svyglm. thanks [[alternative HTML version deleted]] __ R-help@ 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. - Frank Harrell Department of Biostatistics, Vanderbilt University -- View this message in context: http://r.789695.n4.nabble.com/sensitivity-and-specificity-in-svyglm-tp4640427p4640478.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] Variables and greek letters in a plot title
Thanks a lot. However it's not completely what I want. There is space missing between the variable and the mu. Can this be added? On Thu, Aug 16, 2012 at 12:09 PM, Miguel Manese jjon...@gmail.com wrote: Hi Dominik, You can try x - 5 plot(rnorm(50), main=bquote(.(x) * mu * g/m^3 * substance)) Regards, - Jon On Thu, Aug 16, 2012 at 3:37 PM, Dominik Refardt dominik.refa...@gmail.com wrote: Hello This is a problem I encountered repeatedly and I found no answer that made me really happy. I hope it is not too trivial. I would like to give the concentration of a substance in a plot title: 5 ug/ml substance the '5' would be a variable and the ug should be micrograms (with greek letter mu). It is the mu that causes the problems for me. I failed using various combinations of paste, expression and bquote. I would be very grateful if someone could help me (or point me to the solution, which I might have overlooked). Thank you very much Dominik -- Dominik Refardt Institute of Integrative Biology, ETH Zürich [[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. -- Dominik Refardt Theoretical Biology Institute of Integrative Biology, ETH Zürich ETH Zentrum, CHN J11 Universitätsstrasse 16 CH-8092 Zürich Switzerland Phone: +41446327102 Fax: +41446321271 Email: dominik.refa...@gmail.com [[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 global variable building a package
Hi, I altered .internal file as Ligges indicated, but I have a problem when I make R CMD build pkg: ERROR packaging into .tar.gz failed The question is the following: what is the problem? I have installed Rtools, Must I do anything else?. Obs.: I work under Windows 7, but the package generated will be used under windows and mac. Thanks in advance. Eva --- El mié, 8/8/12, Uwe Ligges lig...@statistik.tu-dortmund.de escribió: De: Uwe Ligges lig...@statistik.tu-dortmund.de Asunto: Re: [R] Problem with global variable building a package Para: Eva Prieto Castro evapcas...@yahoo.es CC: Greg Snow 538...@gmail.com, R-help@r-project.org Fecha: miércoles, 8 de agosto, 2012 11:24 On 08.08.2012 08:53, Eva Prieto Castro wrote: Hello, Greg: That is one of the solutions I have tried; the problem is that I can't obtain a package in this way, because an glo-internal.R file is generated (glo is the name of the package) and when I try to create the package an error message appears (a parse error). The content of the glo-internal.R file is the following: .glo.env - environment To avoid parser errors, replace environment by something that is syntactically valid, in this case: new.env(). Best, Uwe Ligges where .glo.env is the name of the new environment I create in my source code. What am I doing wrong?. Thanks again for your help. Regards. Eva --- El mar, 7/8/12, Greg Snow 538...@gmail.com escribió: De: Greg Snow 538...@gmail.com Asunto: Re: [R] Problem with global variable building a package Para: Eva Prieto Castro evapcas...@yahoo.es CC: R-help@r-project.org Fecha: martes, 7 de agosto, 2012 23:30 Probably the best thing to do is create an environment within the package that you can assign to and read from. Somewhere in the source code for the package include a line like: my.env - new.env() then within any functions defined after that line you can set variables within the environment with code like: àmy.env$paramA - 3 and other functions can then read my.env$paramA.àThis way you don't need to worry about assign or - and all your functions will have access to the same set of variables (but they won't interfere with the users workspace). On Tue, Aug 7, 2012 at 1:09 AM, Eva Prieto Castro evapcas...@yahoo.es wrote: Hi, My name is Eva and this is my first message here. My English is not very good, but I hope you can understand my question, in the context of an academic project. I have developed several functions in R and the idea is that the user can access functions in order to: 1) Alter parameters in relation with data and type of analysis. 2) Run statistical analysis (Text and pdf files with results will be generated). 3) View the value of the most important parameters. All the parameters I need are stored in a list object, and this list is used in all the functions along the cycle performed by the user, but I would like the user does not need to pass the name of the list as argument when he/she runs the different functions, so I think I need to treat the list as a global variable. Firstly, I used the global assignment operator (ââ¬Å-ââ¬Å); secondly, I used ââ¬Ågetââ¬ï¿½ and ââ¬Åassignââ¬ï¿½ functions and even I used a new.env() in order to use a new environment exclusively for my list. However, when I try to build a package with all my functions I donââ¬â¢t reach this end, because of an error in parse process. My question for you is the following: taking into account that my end is to build a package, what can I do with this ââ¬Åglobalââ¬ï¿½ list?. How can I treat it?. Thanks in advance. Regards, Eva àààà à à [[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. [[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 global variable building a package
I forget one question: Where do I indicate this path? : PATH=c:\Rtools\bin;c:\Rtools\gcc-4.6.3\bin;c:\MiKTeX\miktex\bin; c:\R\R-2.15\bin\i386;c:\windows;c:\windows\system32 Regards, Eva --- El jue, 16/8/12, Eva Prieto Castro evapcas...@yahoo.es escribió: De: Eva Prieto Castro evapcas...@yahoo.es Asunto: Re: [R] Problem with global variable building a package Para: Uwe Ligges lig...@statistik.tu-dortmund.de CC: Greg Snow 538...@gmail.com, R-help@r-project.org Fecha: jueves, 16 de agosto, 2012 10:41 Hi, I altered .internal file as Ligges indicated, but I have a problem when I make R CMD build pkg: ERROR packaging into .tar.gz failed The question is the following: what is the problem? I have installed Rtools, Must I do anything else?. Obs.: I work under Windows 7, but the package generated will be used under windows and mac. Thanks in advance. Eva --- El mié, 8/8/12, Uwe Ligges lig...@statistik.tu-dortmund.de escribió: De: Uwe Ligges lig...@statistik.tu-dortmund.de Asunto: Re: [R] Problem with global variable building a package Para: Eva Prieto Castro evapcas...@yahoo.es CC: Greg Snow 538...@gmail.com, R-help@r-project.org Fecha: miércoles, 8 de agosto, 2012 11:24 On 08.08.2012 08:53, Eva Prieto Castro wrote: Hello, Greg: That is one of the solutions I have tried; the problem is that I can't obtain a package in this way, because an glo-internal.R file is generated (glo is the name of the package) and when I try to create the package an error message appears (a parse error). The content of the glo-internal.R file is the following: .glo.env - environment To avoid parser errors, replace environment by something that is syntactically valid, in this case: new.env(). Best, Uwe Ligges where .glo.env is the name of the new environment I create in my source code. What am I doing wrong?. Thanks again for your help. Regards. Eva --- El mar, 7/8/12, Greg Snow 538...@gmail.com escribió: De: Greg Snow 538...@gmail.com Asunto: Re: [R] Problem with global variable building a package Para: Eva Prieto Castro evapcas...@yahoo.es CC: R-help@r-project.org Fecha: martes, 7 de agosto, 2012 23:30 Probably the best thing to do is create an environment within the package that you can assign to and read from. Somewhere in the source code for the package include a line like: my.env - new.env() then within any functions defined after that line you can set variables within the environment with code like: àmy.env$paramA - 3 and other functions can then read my.env$paramA.àThis way you don't need to worry about assign or - and all your functions will have access to the same set of variables (but they won't interfere with the users workspace). On Tue, Aug 7, 2012 at 1:09 AM, Eva Prieto Castro evapcas...@yahoo.es wrote: Hi, My name is Eva and this is my first message here. My English is not very good, but I hope you can understand my question, in the context of an academic project. I have developed several functions in R and the idea is that the user can access functions in order to: 1) Alter parameters in relation with data and type of analysis. 2) Run statistical analysis (Text and pdf files with results will be generated). 3) View the value of the most important parameters. All the parameters I need are stored in a list object, and this list is used in all the functions along the cycle performed by the user, but I would like the user does not need to pass the name of the list as argument when he/she runs the different functions, so I think I need to treat the list as a global variable. Firstly, I used the global assignment operator (ââ¬Å-ââ¬Å); secondly, I used ââ¬Ågetââ¬ï¿½ and ââ¬Åassignââ¬ï¿½ functions and even I used a new.env() in order to use a new environment exclusively for my list. However, when I try to build a package with all my functions I donââ¬â¢t reach this end, because of an error in parse process. My question for you is the following: taking into account that my end is to build a package, what can I do with this ââ¬Åglobalââ¬ï¿½ list?. How can I treat it?. Thanks in advance. Regards, Eva àààà à à [[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. [[alternative HTML version deleted]] __ R-help@r-project.org mailing
[R] no true negative data, need roc curve
Hi, I want to plot ROC curve for my detection algorithm which detects features in different images at two different thresholds. 6 different images used and obtained tp, fp and fn. No tn in my case. in first threshold run i obtained 6 values of tp,fp and fn. In second threshold run agian i got 6 more. i had calculated tpr and fpr. How to plot ROC in this case. Is this possible to plot ROC curve in this case? If s, please guide me to plot that. thank you. http://r.789695.n4.nabble.com/file/n4640474/in1.png -- View this message in context: http://r.789695.n4.nabble.com/no-true-negative-data-need-roc-curve-tp4640474.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] Variables and greek letters in a plot title
Thanks a lot. Both plot(1:10) conc=5 title(main=bquote(.(conc)~mu*g/ml substance)) and plot(0,0) conc - 5 title(main=bquote(.(conc)* *mu*g/ml* substance)) do exactly what I need. On Thu, Aug 16, 2012 at 1:33 PM, peter dalgaard pda...@gmail.com wrote: On Aug 16, 2012, at 09:37 , Dominik Refardt wrote: Hello This is a problem I encountered repeatedly and I found no answer that made me really happy. I hope it is not too trivial. I would like to give the concentration of a substance in a plot title: 5 ug/ml substance the '5' would be a variable and the ug should be micrograms (with greek letter mu). It is the mu that causes the problems for me. I failed using various combinations of paste, expression and bquote. I would be very grateful if someone could help me (or point me to the solution, which I might have overlooked). Like this? plot(0,0) conc - 5 title(main=bquote(.(conc)* *mu*g/ml* substance)) -- Peter Dalgaard, Professor Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Email: pd@cbs.dk Priv: pda...@gmail.com -- Dominik Refardt Theoretical Biology Institute of Integrative Biology, ETH Zürich ETH Zentrum, CHN J11 Universitätsstrasse 16 CH-8092 Zürich Switzerland Phone: +41446327102 Fax: +41446321271 Email: dominik.refa...@gmail.com [[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] Column Extraction from matrix
Thanks guys for the help. I finally know what to do know :) -- View this message in context: http://r.789695.n4.nabble.com/Column-Extraction-from-matrix-tp4640465p4640482.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] NADA package/cenboxplot() method: maximum censored percentage
Rich, The cenboxplot function uses cenros to estimate the censored values. The cenros function requires at least 2 uncensored observations to be able to do the regression. The cenros function does issue a warning when there are more than 80% censored data, but that is suppressed in cenboxplot. Hope this helps. Dave Date: Wed, 15 Aug 2012 14:28:54 -0700 (PDT) From: Rich Shepard rshep...@appl-ecosys.com To: r-help@r-project.org Subject: [R] NADA package/cenboxplot() method: maximum censored percentage Message-ID: alpine.lnx.2.00.1208151413240.17...@salmo.appl-ecosys.com Content-Type: TEXT/PLAIN; format=flowed; charset=US-ASCII One set of data has censored (less-than detection limits) water chemistry concentrations for 80-100% of all observations. My initial trial-and-error attempts to apply the cenboxplot() method suggests that it has an upper limit to the percentage of censored observations. I do not see this limit in Dennis Helsel's second edition. Has anyone experience plotting censored data and can provide me with the maximum percentage of censored data in a set of observations? TIA, Rich [[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] Big Data reading subsample csv
Hello, I'm most grateful for your time to read this. I have a uber size 30GB file of 6 million records and 3000 (mostly categorical data) columns in csv format. I want to bootstrap subsamples for multinomial regression, but it's proving difficult even with my 64GB RAM in my machine and twice that swap file , the process becomes super slow and halts. I'm thinking about generating subsample indicies in R and feeding them into a system command using sed or awk, but don't know how to do this. If someone knew of a clean way to do this using just R commands, I would be really grateful. One problem is that I need to pick complete observations of subsamples, that is I need to have all the rows of a particular multinomial observation - they are not the same length from observation to observation. I plan to use glmnet and then some fancy transforms to get an approximation to the multinomial case. One other point is that I don't know how to choose sample size to fit around memory limits. Appreciate your thoughts greatly. R.version platform x86_64-pc-linux-gnu arch x86_64 os linux-gnu system x86_64, linux-gnu status major 2 minor 15.1 year 2012 month 06 day22 svn rev59600 language R version.string R version 2.15.1 (2012-06-22) nickname Roasted Marshmallows tags: read.csv(), system(), awk, sed, sample(), glmnet, multinomial, MASS. Yoda [[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] creation of package failed
Hi, Could you indicate the way you resolved?. I am having the same problem you had, and I can't resolve it. What do you mean when you say that folders have be in front?. Thanks in advance. Eva -- View this message in context: http://r.789695.n4.nabble.com/creation-of-package-failed-tp4640165p4640488.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] Column Extraction from matrix
You could also use a 3d array instead of a list: m - matrix(1:400, ncol=100, byrow=TRUE) a - array(m, dim=c(2, 2, 100), dimnames=list(row=c(1, 2), col=c(1, 2), tbl=c(paste0(a, 1:100 a[,,1] # First table by index col row 1 2 1 1 201 2 101 301 a[,,a1] # First table by name col row 1 2 1 1 201 2 101 301 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On Behalf Of bantex Sent: Thursday, August 16, 2012 7:28 AM To: r-help@r-project.org Subject: Re: [R] Column Extraction from matrix Thanks guys for the help. I finally know what to do know :) -- View this message in context: http://r.789695.n4.nabble.com/Column- Extraction-from-matrix-tp4640465p4640482.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. __ 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] NADA package/cenboxplot() method: maximum censored percentage
On Thu, 16 Aug 2012, David L Lorenz wrote: The cenboxplot function uses cenros to estimate the censored values. The cenros function requires at least 2 uncensored observations to be able to do the regression. The cenros function does issue a warning when there are more than 80% censored data, but that is suppressed in cenboxplot. Dave, I've seen the cenros warning when there are 80% censored data, and now understand that I don't see the same warning with cenboxplot. Knowing now that I need at least 2 uncensored observations answers my question; some of the constituents have only a single uncensored value. Others have none, and I knew those could not be analyzed or plotted. Hope this helps. Most certainly does! Thanks very much, 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.
Re: [R] Variables and greek letters in a plot title
plot(rnorm(50), main=bquote(.(x)* * mu * g/m^3 * substance)) John Kane Kingston ON Canada -Original Message- From: dominik.refa...@gmail.com Sent: Thu, 16 Aug 2012 12:50:57 +0200 To: jjon...@gmail.com Subject: Re: [R] Variables and greek letters in a plot title Thanks a lot. However it's not completely what I want. There is space missing between the variable and the mu. Can this be added? On Thu, Aug 16, 2012 at 12:09 PM, Miguel Manese jjon...@gmail.com wrote: Hi Dominik, You can try x - 5 plot(rnorm(50), main=bquote(.(x) * mu * g/m^3 * substance)) Regards, - Jon On Thu, Aug 16, 2012 at 3:37 PM, Dominik Refardt dominik.refa...@gmail.com wrote: Hello This is a problem I encountered repeatedly and I found no answer that made me really happy. I hope it is not too trivial. I would like to give the concentration of a substance in a plot title: 5 ug/ml substance the '5' would be a variable and the ug should be micrograms (with greek letter mu). It is the mu that causes the problems for me. I failed using various combinations of paste, expression and bquote. I would be very grateful if someone could help me (or point me to the solution, which I might have overlooked). Thank you very much Dominik -- Dominik Refardt Institute of Integrative Biology, ETH Z|rich [[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. -- Dominik Refardt Theoretical Biology Institute of Integrative Biology, ETH Z|rich ETH Zentrum, CHN J11 Universitdtsstrasse 16 CH-8092 Z|rich Switzerland Phone: +41446327102 Fax: +41446321271 Email: dominik.refa...@gmail.com [[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. FREE 3D EARTH SCREENSAVER - Watch the Earth right on your desktop! __ 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 plot data in logarithmic scale
Zuki, You did not provide any information on what table$attrib is. Using a log scale for the y-axis doesn't make much sense to me, since the y-axis is the cumulative proportion of observations, from 0 to 1. Perhaps you are interested in the log scale for the x-axis, instead? In any case, log is not an argument to the plot.ecdf function. You could take the log of the values then plot the ecdf, like this: plot.ecdf(log(1:100), axes=F) axis(1, at=log(tix), labels=tix) axis(2) box() Jean Zuki zuk...@gmail.com wrote on 08/15/2012 04:16:06 AM: Hi everyone, I am new in R, just used it for 2 weeks and I have a basic question. I have data, for example table$attrib that I would like to plot its cumulative distribution in logarithmic scale. How do I do that? After browsing internet, I tested this command: plot.ecdf(1:100, log =y, table$attrib) I got a plot, but I am not really sure what 1:100 and log=ydid to produce the plot. Any help is appreciated. Thank you, Zuki [[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] Color-coded Biplot of Varimax rotated factors from PCA based factor analysis
I suggest that you re-post your question, but this time make it easy for readers to help you by providing a simple reproducible example of your problem. Provide some fake data, or a small subset of your data using, for example, the function dput(). Trim the fat from your code. Get rid of any arguments or functions that are not necessary to demonstrate your problem. Include in your code the function library() or require() to load any needed packages. If you make it so that a reader can simply copy and paste your code into R, you will get more help. Jean Barbara Doll bd...@ncsu.edu wrote on 08/15/2012 01:29:09 PM: I'm using R for PCA and? factor analysis. I want to create biplots of varimax rotated factors that color-code points by their classification. My research is on streams that are urban and rural. So, I want to color code them by this classification. If you just do a biplot from prcomp or princomp, you cannot add this color. So, I have used some code developed by a graduate student in our statistics department here at NC State University. However, when you compare the two biplots, the observed points are not in the same location. The variable vectors match up, but not the points. I'm not sure why. The code is below. Please help. label=data[,Urban.Rural] indexU-which(label==U) indexR-which(label==R) collab-rep(0,length(data[,1])) collab[indexU]-Blue collab[indexR]-Green library(psych) fit - principal(mydata, nfactors = num.fac, rotate=varimax, scores = TRUE) z1 - sum(fit2$loadings[,1]^2) ### need to scale scores and loadings by these factors z2 - sum(fit2$loadings[,2]^2) biplot(fit$scores[,c(1,2)]/c(z1, z2), loadings(fit)[,c(1,2)]*c(z1, z2), xlabs=rep(, length(collab)), col = c(black, orange)) legend(x=bottomright, legend=c(Urban,Rural), text.col=c(Blue,Green), bg=Grey90) ### scale the plot parameters rrr-apply(fit$scores[,1:2],2, range) (abs(rrr)+.1)*sign(rrr) par(usr=as.vector(rrr)) ### now include the colored points points(fit$scores[,c(1,2)], col=collab, pch=20) [[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] How to plot data in logarithmic scale
If you don't know what 1:100 is, you should (re)read the Introduction to R document that comes with the software. You can also try typing expressions like this alone at the command line to see what they are. If you don't know what the first argument to the ecdf function is, you need to learn to use the help system, e.g. ?ecdf --- Jeff NewmillerThe . . Go Live... DCN:jdnew...@dcn.davis.ca.usBasics: ##.#. ##.#. 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. Zuki zuk...@gmail.com wrote: Hi everyone, I am new in R, just used it for 2 weeks and I have a basic question. I have data, for example table$attrib that I would like to plot its cumulative distribution in logarithmic scale. How do I do that? After browsing internet, I tested this command: plot.ecdf(1:100, log =y, table$attrib) I got a plot, but I am not really sure what 1:100 and log=ydid to produce the plot. Any help is appreciated. Thank you, Zuki __ 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] legend position help
A quick hack to give you space between the line and point (if you only used solid lines) is to specify lty='ff' to the legend function. If you want more control then look at setting trace=TRUE and plot=FALSE and looking at the printed outcome and the return value from legend. This does not plot the legend, but gives you the information that you can use to create the legend yourself (and could therefore move the pieces that you want moved). On Wed, Aug 15, 2012 at 8:05 PM, Jinsong Zhao jsz...@yeah.net wrote: On 2012-08-16 0:22, Greg Snow wrote: You can use the grconvertY function to find the position in the current user coordinates that corresponds to the top of the device area (instead of using locator). Thank you very much. grconvertX() and grconvertY() work very well. Look at the merge argument to the legend function. I gave merge = FALSE in the command. It gave the result like: ---o However, I hope to get something like: --- o or o --- (I prefer to this one) There should be a space between the point and line. Thanks again. Regards, Jinsong On Wed, Aug 15, 2012 at 10:04 AM, Jinsong Zhao jsz...@yeah.net wrote: Hi there, I draw a multiple figure in one plot, like the following: par(mfcol=c(1,5),mar=c(4,4,0,0)+0.2, oma=c(0,0,3,0)) plot(1:10, type = b) plot(1:10, type = b) plot(1:10, type = b) plot(1:10, type = b) plot(1:10, type = b) Now, I hope to plot the legend like the following: legend(top, legend=c(Example), pch = 21, lty = 1, merge = FALSE, horiz = TRUE, bty=n, xpd = NA) There were two problems: 1) the legend is put inside the fifth figure instead of the top center of the whole plot, i.e., the center of the outer top margin. Now, I use a stupid solution, I replace top in the above command with locator(1). However, using this solution, the plot have to be in an interactive mode, and the position is not accuracy. 2) the point is connected with the line in the legend. I hope there is a space between the two symbols, like --- o instead of ---o. If possible, put the point before the line, like o . Unfortunately, I don't find any way to do that. Any suggestion will be greatly appreciated. Regards, Jinsong __ 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. -- Gregory (Greg) L. Snow Ph.D. 538...@gmail.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] Big Data reading subsample csv
Why not put this into a database, and then you can easily extract the records you want specifying the record numbers. You play the one time expense of creating the database, but then have much faster access to the data as you make subsequent runs. On Thu, Aug 16, 2012 at 9:44 AM, Tudor Medallion tudormedall...@googlemail.com wrote: Hello, I'm most grateful for your time to read this. I have a uber size 30GB file of 6 million records and 3000 (mostly categorical data) columns in csv format. I want to bootstrap subsamples for multinomial regression, but it's proving difficult even with my 64GB RAM in my machine and twice that swap file , the process becomes super slow and halts. I'm thinking about generating subsample indicies in R and feeding them into a system command using sed or awk, but don't know how to do this. If someone knew of a clean way to do this using just R commands, I would be really grateful. One problem is that I need to pick complete observations of subsamples, that is I need to have all the rows of a particular multinomial observation - they are not the same length from observation to observation. I plan to use glmnet and then some fancy transforms to get an approximation to the multinomial case. One other point is that I don't know how to choose sample size to fit around memory limits. Appreciate your thoughts greatly. R.version platform x86_64-pc-linux-gnu arch x86_64 os linux-gnu system x86_64, linux-gnu status major 2 minor 15.1 year 2012 month 06 day22 svn rev59600 language R version.string R version 2.15.1 (2012-06-22) nickname Roasted Marshmallows tags: read.csv(), system(), awk, sed, sample(), glmnet, multinomial, MASS. Yoda [[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. -- Jim Holtman Data Munger Guru What is the problem that you are trying to solve? Tell me what you want to do, not how you want to do it. __ 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] Big Data reading subsample csv
The read.csv.sql function in the sqldf package may make this approach quite simple. On Thu, Aug 16, 2012 at 10:12 AM, jim holtman jholt...@gmail.com wrote: Why not put this into a database, and then you can easily extract the records you want specifying the record numbers. You play the one time expense of creating the database, but then have much faster access to the data as you make subsequent runs. On Thu, Aug 16, 2012 at 9:44 AM, Tudor Medallion tudormedall...@googlemail.com wrote: Hello, I'm most grateful for your time to read this. I have a uber size 30GB file of 6 million records and 3000 (mostly categorical data) columns in csv format. I want to bootstrap subsamples for multinomial regression, but it's proving difficult even with my 64GB RAM in my machine and twice that swap file , the process becomes super slow and halts. I'm thinking about generating subsample indicies in R and feeding them into a system command using sed or awk, but don't know how to do this. If someone knew of a clean way to do this using just R commands, I would be really grateful. One problem is that I need to pick complete observations of subsamples, that is I need to have all the rows of a particular multinomial observation - they are not the same length from observation to observation. I plan to use glmnet and then some fancy transforms to get an approximation to the multinomial case. One other point is that I don't know how to choose sample size to fit around memory limits. Appreciate your thoughts greatly. R.version platform x86_64-pc-linux-gnu arch x86_64 os linux-gnu system x86_64, linux-gnu status major 2 minor 15.1 year 2012 month 06 day22 svn rev59600 language R version.string R version 2.15.1 (2012-06-22) nickname Roasted Marshmallows tags: read.csv(), system(), awk, sed, sample(), glmnet, multinomial, MASS. Yoda [[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. -- Jim Holtman Data Munger Guru What is the problem that you are trying to solve? Tell me what you want to do, not how you want to do it. __ 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. -- Gregory (Greg) L. Snow Ph.D. 538...@gmail.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] no true negative data, need roc curve
To clarify: Is TN = 0 or do you not know TN (N)? On 16.08.2012, at 11:51, vjyns wrote: Hi, I want to plot ROC curve for my detection algorithm which detects features in different images at two different thresholds. 6 different images used and obtained tp, fp and fn. No tn in my case. in first threshold run i obtained 6 values of tp,fp and fn. In second threshold run agian i got 6 more. i had calculated tpr and fpr. How to plot ROC in this case. Is this possible to plot ROC curve in this case? If s, please guide me to plot that. thank you. http://r.789695.n4.nabble.com/file/n4640474/in1.png -- View this message in context: http://r.789695.n4.nabble.com/no-true-negative-data-need-roc-curve-tp4640474.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. __ 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] Pedigrees
I am building several pedigrees and would like to construct the graphs automatically. I used the following program: require(kinship2) pedig = with(Dados, pedigree(id=iid, dadid=fid, momid=mid, sex=sex, famid=famid, missid=0)) for(famid in 1:15){ pedig[famid] - pedig['famid'] pdf(paste(plot, famid, .pdf)) plot(pedig[famid]) dev.off() } Error em `[.pedigreeList`(pedig, famid) : Familiy famid not found but is not working. How to solve the problem? Thanks, - Silvano Cesar da Costa Universidade Estadual de Londrina Centro de Ciências Exatas Departamento de Estatística Fone: (43) 3371-4346 __ 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] multiple boxplots on the same figure - reducing space in between
Hi I have two vectors of integers and I am plotting a box plot that contains both vectors. I have done the following: vec1 -scan(file1) vec2 -scan(file2) boxplot(vec1, vec2, range=0, horizontal=TRUE, names=c(One,Two), boxwex=0.15) I managed to get both boxplots on the same figure but there they are wide apart. Is there a way to reduce the space between them? Currently they look like this: | | one| |--[]-| | | | | | | | | | two| |--[]---| | | |__ I mean to reduce the space between one and two and maybe also two and x-axis. How can I do this? Thanks! -- View this message in context: http://r.789695.n4.nabble.com/multiple-boxplots-on-the-same-figure-reducing-space-in-between-tp4640503.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] ANOVA repeated measures and post-hoc
Check out: http://rtutorialseries.blogspot.com/2011/02/r-tutorial-series-two-way-repeated.html On 8/15/2012 11:32 AM, Diego Bucci wrote: Hi, I performed an ANOVA repeated measures but I still can't find any good news regarding the possibility to perform multiple comparisons. Can anyone help me? Thanks Diego Bucci Fisiologia Veterinaria Dipartimento di Scienze Mediche Veterinarie Università degli Studi di Bologna Via Tolara di Sopra, 50 40064 Ozzano dell'Emilia, BO Tel. 00390512097904 mail diego.buc...@unibo.it [[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. [[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] Error in family$linkfun(mustart) : Value 1.125 out of range (0, 1)
On Aug 16, 2012, at 12:03 AM, Dinuk Jayasuriya wrote: John/Michael, thanks for your comments. I get the following error when I run my code (the code is attached as is a section of the data set): No, it's not (anymore at least). It needs to be a mime-text formated file at the time it hits the R mail-server, and typically those need to be constructed with extension .txt although details may vary among OSes. -- David. Error in family$linkfun(mustart) : Value 1.125 out of range (0, 1) If anyone can please provide assistance that would be much appreciated - I'm not sure if it's something wrong with my dataset or a bug in the program list Many thanks, Dinuk On 08/16/12, John j...@surewest.net wrote: On Wed, 15 Aug 2012 17:59:53 +1000 Dinuk Jayasuriya dinuk.jayasur...@anu.edu.au wrote: Hi Jeff, Thank you - your comment was much appreciated. I'm now running an ordered probit regression and get the following error: Error in family$linkfun(mustart) : Value 1.125 out of range (0, 1) I can't decipher (after looking at other posts on google!) why this error occurs - is it something wrong with my dataset? If anyone can advise that would be very helpful. Thanks, Dinuk You need to supply considerably more information before you can expect much help. A subset of the data would help, since otherwise people are guessing. Also, if you look at the example here: http://www.ats.ucla.edu/stat/R/dae/probit.htm you may find some useful pointers. JWDougherty David Winsemius, MD Alameda, CA, USA __ 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] sum over extremely small numbers
Dear All, I am evaluating the value of loglikelihood and it ends up with the sum of tiny numbers. Below is an example: suppose I would like to calculate sum_i (log (sum_j x [i, j] )), the index of log (x) is in the range, say (-2000, 0). I am aware that exp(-744.5) will be expressed as 0 in 32 bit R and exp Is there a way to improve the result? R example: powd - sample(-2000:0, 100, replace=T) # the power of x [i, j] x - matrix(exp(powd),10)# the value of x sum(log(rowSums(x))) # sum Thank you for your help. Best wishes, Jie [[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] multiple boxplots on the same figure - reducing space in between
Hello, Without data, I've made up my own. Try the following. x - rnorm(100) y - rnorm(100) bp - boxplot(x, y, range = 0, names=c(One,Two)) bx - bxp(bp, horizontal=TRUE, boxwex = 0.15, at = c(1, 1 + 2*0.15)) bx Note that in the call to boxplot you only need the arguments that affect the returned value. See ?boxplot, section Value. And that without the argument 'at' to bxp, its returned value would be bx [1] 1 2 (See also ?bxp) You can make the code more readable with something like bwex - 0.15 and then use it wherever it's needed. Hope this helps, Rui Barradas Em 16-08-2012 16:56, ziqizh...@hotmail.co.uk escreveu: Hi I have two vectors of integers and I am plotting a box plot that contains both vectors. I have done the following: vec1 -scan(file1) vec2 -scan(file2) boxplot(vec1, vec2, range=0, horizontal=TRUE, names=c(One,Two), boxwex=0.15) I managed to get both boxplots on the same figure but there they are wide apart. Is there a way to reduce the space between them? Currently they look like this: | | one| |--[]-| | | | | | | | | | two| |--[]---| | | |__ I mean to reduce the space between one and two and maybe also two and x-axis. How can I do this? Thanks! -- View this message in context: http://r.789695.n4.nabble.com/multiple-boxplots-on-the-same-figure-reducing-space-in-between-tp4640503.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. __ 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] Error in metafor documentation on maximum iterations
I had noticed this oversight a while ago. In an updated version of the metafor package (hopefully to be released in the near future), the argument will be called maxiter (as intended). Using maxit will then work as well, due to partial matching. Thanks for bringing this to my attention though. Also, the package name is metafor (spelled with an f). It's supposed to be a (convoluted) abbreviation for META-analysis FOr R). I suppose metaphor would then be META-analysis PHOr R, but I decided against that (other candidates were metaforR, metafoR, and a few others). Well, at the time, I thought the name metafor was clever. These days, I am not so sure anymore. Best, Wolfgang -- Wolfgang Viechtbauer, Ph.D., Statistician Department of Psychiatry and Psychology School for Mental Health and Neuroscience Faculty of Health, Medicine, and Life Sciences Maastricht University, P.O. Box 616 (VIJV1) 6200 MD Maastricht, The Netherlands +31 (43) 388-4170 | http://www.wvbauer.com -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Michael Weylandt Sent: Thursday, August 16, 2012 04:19 To: John Hodgson Cc: r-help@r-project.org Subject: Re: [R] Error in metafor documentation on maximum iterations Send this to Wolfgang directly. See maintainer(metaphor) Michael On Aug 15, 2012, at 12:13 PM, John Hodgson j...@formby.plus.com wrote: Both the official R documentation and Wolfgang's paper in the Journal of Statistical Science describing this (extremely useful) package, name the control variable for maximum iterations in numeric model fitting as 'maxiter'. The correct name is 'maxit'. A small point concerning an (I guess) infrequently used bit of functionality, but this may help save someone an hour or so's head scratching! John Hodgson __ 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-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] How to extract from a column in a table?
Hi, I have a table in which one column has the name of the objects as shown below. Name Budlamp-Woodcutter Complex - 15 to 60% slope (60/25/15) Budlamp-Woodcutter Complex - 15 to 60% slope (60/25/15) Terrarossa-Blacktail-Pyeatt Complex - 1 to 40% slope (40/35/15/10) Terrarossa-Blacktail-Pyeatt Complex - 1 to 40% slope (40/35/15/10) How can I split the single column into three columns like name (Budlamp-Woodcutter Complex), slope (15 to 60% slope) and percentage (60/25/15) thanks [[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 data structures
hi, i'm trying to understand r data structures. i see that vectors, matrix, factors and arrays have a dimension. there seems to be no mention of dimensionality anywhere for lists or dataframes. can i consider lists and frames to be of fixed dimension 2? thanks, jay s __ 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] r data structures
Hi, On Thu, Aug 16, 2012 at 2:49 PM, Schumacher, Jay S j...@neo.tamu.edu wrote: hi, i'm trying to understand r data structures. i see that vectors, matrix, factors and arrays have a dimension. Out of curiosity, where do you see that vectors and factors have a dimension? I mean -- I guess they're one dimensional, but ... there seems to be no mention of dimensionality anywhere for lists or dataframes. can i consider lists and frames to be of fixed dimension 2? data.frames: sure, I guess lists: no What would you consider the dimension of this list to be: x = list(a=1:10, b='hello', c=matrix(1:100, nrow=10)) -steve -- Steve Lianoglou Graduate Student: Computational Systems Biology | Memorial Sloan-Kettering Cancer Center | Weill Medical College of Cornell University Contact Info: http://cbio.mskcc.org/~lianos/contact __ 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] Reference a variable inside a string and another for object assingments
Hi R community I copied a bit of my R code that gets some data from a database. You won't be able to run the code, but I am a beginner so you will probably understand what going on. I would like to make a variable I can refer to inside the sqlQuery. Instead of writing the start date and time (ex SP.lokaldatotid = '2005-01-01 00:00:00') inside the query I would like to define it in the beginning of the code, so I don't have to fiddle with a lot of dates each time I wan't to change it. I would like to do this for a few of the variables and maybe even make a list/array I can loop through, so I don't have to write the same code multiple times (for SYS and DK1). I have searched for a solution for two days now, but I am not sure what it's called and are probably writing the wrong queries :-) Thank you for your help! Kenneth My code: library(xts) library(RODBC) #Define channnel (i configured my own SYSTEM-DNS, via ODBC) ch - odbcConnect(DI2) # ## GET DATA## # ## SYSTEM spot ## # Hent data fra SQL Server sys - sqlQuery (ch, paste(SELECT SP.lokaldatotid, SP.pris FROM DataIndsamling2.dbo.SpotPriser SP, WHERE (SP.omraade_id= 0 AND SP.lokaldatotid = '2005-01-01 00:00:00'))) #Definer dato og tid kolonne sys$lokaldatotid - as.POSIXct(sys$lokaldatotid) #Make a XTS object sys_xts - xts(sys[,-1], order.by=sys[,1]) # Recalculate data from hours to daily, monthly and yearly averages sys_xts_daily - apply.daily(sys_xts, FUN=mean) sys_xts_monthly - apply.monthly(sys_xts, FUN=mean) sys_xts_yearly - apply.yearly(sys_xts, FUN=mean) ## DK1 spot # # Hent data fra SQL Server dk1 - sqlQuery (ch, paste(SELECT SP.lokaldatotid, SP.pris FROM DataIndsamling2.dbo.SpotPriser SP, WHERE (SP.omraade_id= 5 AND SP.lokaldatotid = '2005-01-01 00:00:00'))) #Definer dato og tid kolonne dk1$lokaldatotid - as.POSIXct(dk1$lokaldatotid) #Lav om til xts object dk1_xts - xts(dk1[,-1], order.by=dk1[,1]) #Data omregnet fra time - daglig, måned, årlige gennemsnit dk1_xts_daily - apply.daily(dk1_xts, FUN=mean) dk1_xts_monthly - apply.monthly(dk1_xts, FUN=mean) dk1_xts_yearly - apply.yearly(dk1_xts, FUN=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] sum over extremely small numbers
On Thu, Aug 16, 2012 at 01:41:17PM -0400, Jie wrote: Dear All, I am evaluating the value of loglikelihood and it ends up with the sum of tiny numbers. Below is an example: suppose I would like to calculate sum_i (log (sum_j x [i, j] )), the index of log (x) is in the range, say (-2000, 0). I am aware that exp(-744.5) will be expressed as 0 in 32 bit R and exp Is there a way to improve the result? R example: powd - sample(-2000:0, 100, replace=T) # the power of x [i, j] x - matrix(exp(powd),10)# the value of x sum(log(rowSums(x))) # sum Hi. The numbers in a row of the matrix x are not only very small, but also very different from each other. In this situation, their maximum may be a good approximation of their sum. For example 2^-1000 + 2^-500 + 2^-100 \approx 2^-100 since (2^-1000 + 2^-500 + 2^-100)/2^-100 is very close to 1. If the numbers are not so different, then the following formula for a vector x, which may be a single row of a matrix, may be helpful log(sum(exp(x))) = max(x) + log(sum(exp(x - max(x Note that exp() is not applied to the original numbers, but to their differences and the main term is exp(0) due to the maximum element of x. So, at least the main term is computed without underflow. The accuracy may be further improved by eliminating exp(0) from the sum in the right hand side and using function log1p(x). set.seed(1234567) x - - runif(10) A - log(sum(exp(x))) y - x[-which.max(x)] B - max(x) + log1p(sum(exp(y - max(x A [1] 1.771461 abs(A - B) [1] 2.220446e-16 See also http://rwiki.sciviews.org/doku.php?id=misc:r_accuracy:computing_using_logarithms Hope this helps. Petr Savicky. __ 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 extract from a column in a table?
Sapana Lohani lohani.sap...@ymail.com wrote on 08/16/2012 01:41:23 PM: Hi, I have a table in which one column has the name of the objects as shown below. You don't provide example data, so I'm not sure what you mean by a table. I will assume that you mean a data frame. Name Budlamp-Woodcutter Complex - 15 to 60% slope (60/25/15) Budlamp-Woodcutter Complex - 15 to 60% slope (60/25/15) Terrarossa-Blacktail-Pyeatt Complex - 1 to 40% slope (40/35/15/10) Terrarossa-Blacktail-Pyeatt Complex - 1 to 40% slope (40/35/15/10) How can I split the single column into three columns like name (Budlamp-Woodcutter Complex), slope (15 to 60% slope) and percentage(60/25/15) thanks # example data frame mydat - data.frame(Name = c(Budlamp-Woodcutter Complex - 15 to 60% slope (60/25/15), Budlamp-Woodcutter Complex - 15 to 60% slope (60/25/15), Terrarossa-Blacktail-Pyeatt Complex - 1 to 40% slope (40/35/15/10), Terrarossa-Blacktail-Pyeatt Complex - 1 to 40% slope (40/35/15/10)), x=1:4) # find where the three splitting strings are dash - regexpr( - , mydat$Name) leftp - regexpr( \\(, mydat$Name) rightp - regexpr(\\), mydat$Name) # define three new columns based on the location of the splitting strings mydat$name - substring(mydat$Name, 1, dash-1) mydat$slope - substring(mydat$Name, dash + attr(dash, match.length), leftp-1) mydat$percentage - substring(mydat$Name, leftp + attr(leftp, match.length), rightp-1) mydat [[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] Reference a variable inside a string and another for object assingments
Perhaps the sprintf function is what you are looking for. It is one way to insert information from a variable into a string. A couple of other options are paste, paste0, and the gsubfn package, but I think sprintf will be simplest for what you are asking. On Thu, Aug 16, 2012 at 1:30 PM, Kenneth Rose kennethros...@gmail.com wrote: Hi R community I copied a bit of my R code that gets some data from a database. You won't be able to run the code, but I am a beginner so you will probably understand what going on. I would like to make a variable I can refer to inside the sqlQuery. Instead of writing the start date and time (ex SP.lokaldatotid = '2005-01-01 00:00:00') inside the query I would like to define it in the beginning of the code, so I don't have to fiddle with a lot of dates each time I wan't to change it. I would like to do this for a few of the variables and maybe even make a list/array I can loop through, so I don't have to write the same code multiple times (for SYS and DK1). I have searched for a solution for two days now, but I am not sure what it's called and are probably writing the wrong queries :-) Thank you for your help! Kenneth My code: library(xts) library(RODBC) #Define channnel (i configured my own SYSTEM-DNS, via ODBC) ch - odbcConnect(DI2) # ## GET DATA## # ## SYSTEM spot ## # Hent data fra SQL Server sys - sqlQuery (ch, paste(SELECT SP.lokaldatotid, SP.pris FROM DataIndsamling2.dbo.SpotPriser SP, WHERE (SP.omraade_id= 0 AND SP.lokaldatotid = '2005-01-01 00:00:00'))) #Definer dato og tid kolonne sys$lokaldatotid - as.POSIXct(sys$lokaldatotid) #Make a XTS object sys_xts - xts(sys[,-1], order.by=sys[,1]) # Recalculate data from hours to daily, monthly and yearly averages sys_xts_daily - apply.daily(sys_xts, FUN=mean) sys_xts_monthly - apply.monthly(sys_xts, FUN=mean) sys_xts_yearly - apply.yearly(sys_xts, FUN=mean) ## DK1 spot # # Hent data fra SQL Server dk1 - sqlQuery (ch, paste(SELECT SP.lokaldatotid, SP.pris FROM DataIndsamling2.dbo.SpotPriser SP, WHERE (SP.omraade_id= 5 AND SP.lokaldatotid = '2005-01-01 00:00:00'))) #Definer dato og tid kolonne dk1$lokaldatotid - as.POSIXct(dk1$lokaldatotid) #Lav om til xts object dk1_xts - xts(dk1[,-1], order.by=dk1[,1]) #Data omregnet fra time - daglig, måned, årlige gennemsnit dk1_xts_daily - apply.daily(dk1_xts, FUN=mean) dk1_xts_monthly - apply.monthly(dk1_xts, FUN=mean) dk1_xts_yearly - apply.yearly(dk1_xts, FUN=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. -- Gregory (Greg) L. Snow Ph.D. 538...@gmail.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] How to extract from a column in a table?
?strsplit -- Bert On Thu, Aug 16, 2012 at 11:41 AM, Sapana Lohani lohani.sap...@ymail.com wrote: Hi, I have a table in which one column has the name of the objects as shown below. Name Budlamp-Woodcutter Complex - 15 to 60% slope (60/25/15) Budlamp-Woodcutter Complex - 15 to 60% slope (60/25/15) Terrarossa-Blacktail-Pyeatt Complex - 1 to 40% slope (40/35/15/10) Terrarossa-Blacktail-Pyeatt Complex - 1 to 40% slope (40/35/15/10) How can I split the single column into three columns like name (Budlamp-Woodcutter Complex), slope (15 to 60% slope) and percentage (60/25/15) thanks [[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. -- Bert Gunter Genentech Nonclinical Biostatistics Internal Contact Info: Phone: 467-7374 Website: http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm __ 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 extract from a column in a table?
Hi, Try this: dat1-readLines(textConnection(Name Budlamp-Woodcutter Complex - 15 to 60% slope (60/25/15) Budlamp-Woodcutter Complex - 15 to 60% slope (60/25/15) Terrarossa-Blacktail-Pyeatt Complex - 1 to 40% slope (40/35/15/10) Terrarossa-Blacktail-Pyeatt Complex - 1 to 40% slope (40/35/15/10) )) dat3-data.frame(dat2[-1,]) colnames(dat3)-Name col2-gsub(.*-\\s(.*slope).*,\\1,dat3$Name) col3-gsub(.*(\\(.*\\)),\\1,dat3$Name) col1-gsub((.*Complex).*,\\1,dat3$Name) dat3New-data.frame(col1,col2,col3) dat3New col1 col2 col3 1 Budlamp-Woodcutter Complex 15 to 60% slope (60/25/15) 2 Budlamp-Woodcutter Complex 15 to 60% slope (60/25/15) 3 Terrarossa-Blacktail-Pyeatt Complex 1 to 40% slope (40/35/15/10) 4 Terrarossa-Blacktail-Pyeatt Complex 1 to 40% slope (40/35/15/10) A.K. - Original Message - From: Sapana Lohani lohani.sap...@ymail.com To: r-help@r-project.org r-help@r-project.org Cc: Sent: Thursday, August 16, 2012 2:41 PM Subject: [R] How to extract from a column in a table? Hi, I have a table in which one column has the name of the objects as shown below. Name Budlamp-Woodcutter Complex - 15 to 60% slope (60/25/15) Budlamp-Woodcutter Complex - 15 to 60% slope (60/25/15) Terrarossa-Blacktail-Pyeatt Complex - 1 to 40% slope (40/35/15/10) Terrarossa-Blacktail-Pyeatt Complex - 1 to 40% slope (40/35/15/10) How can I split the single column into three columns like name (Budlamp-Woodcutter Complex), slope (15 to 60% slope) and percentage (60/25/15) thanks [[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 extract from a column in a table?
Hello, Try the following. x - c( Budlamp-Woodcutter Complex - 15 to 60% slope (60/25/15), Budlamp-Woodcutter Complex - 15 to 60% slope (60/25/15), Terrarossa-Blacktail-Pyeatt Complex - 1 to 40% slope (40/35/15/10), Terrarossa-Blacktail-Pyeatt Complex - 1 to 40% slope (40/35/15/10) ) lapply(strsplit(x, - ), function(.x){ s1 - .x[1] s2 - gsub( \\(.*\\)$, , .x[2]) s3 - gsub(^.*(\\(.*\\)$), \\1, .x[2]) c(s1, s2, s3) }) If you want to have the output in the form of matrix or data.frame, change the above to: xx - lapply(...etc...) mat - do.call(rbind, xx) # matrix dat - data.frame(mat) # data.frame Hope this helps, Rui Barradas Em 16-08-2012 19:41, Sapana Lohani escreveu: Hi, I have a table in which one column has the name of the objects as shown below. Name Budlamp-Woodcutter Complex - 15 to 60% slope (60/25/15) Budlamp-Woodcutter Complex - 15 to 60% slope (60/25/15) Terrarossa-Blacktail-Pyeatt Complex - 1 to 40% slope (40/35/15/10) Terrarossa-Blacktail-Pyeatt Complex - 1 to 40% slope (40/35/15/10) How can I split the single column into three columns like name (Budlamp-Woodcutter Complex), slope (15 to 60% slope) and percentage (60/25/15) thanks [[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 extract from a column in a table?
Hi, Forgot the last part. colnames(dat3New)-c(name,slope,percentage) dat3New name slope percentage 1 Budlamp-Woodcutter Complex 15 to 60% slope (60/25/15) 2 Budlamp-Woodcutter Complex 15 to 60% slope (60/25/15) 3 Terrarossa-Blacktail-Pyeatt Complex 1 to 40% slope (40/35/15/10) 4 Terrarossa-Blacktail-Pyeatt Complex 1 to 40% slope (40/35/15/10) A.K. - Original Message - From: Sapana Lohani lohani.sap...@ymail.com To: r-help@r-project.org r-help@r-project.org Cc: Sent: Thursday, August 16, 2012 2:41 PM Subject: [R] How to extract from a column in a table? Hi, I have a table in which one column has the name of the objects as shown below. Name Budlamp-Woodcutter Complex - 15 to 60% slope (60/25/15) Budlamp-Woodcutter Complex - 15 to 60% slope (60/25/15) Terrarossa-Blacktail-Pyeatt Complex - 1 to 40% slope (40/35/15/10) Terrarossa-Blacktail-Pyeatt Complex - 1 to 40% slope (40/35/15/10) How can I split the single column into three columns like name (Budlamp-Woodcutter Complex), slope (15 to 60% slope) and percentage (60/25/15) thanks [[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] r data structures
On Aug 16, 2012, at 11:49 AM, Schumacher, Jay S wrote: hi, i'm trying to understand r data structures. i see that vectors, matrix, factors and arrays have a dimension. there seems to be no mention of dimensionality anywhere for lists or dataframes. can i consider lists and frames to be of fixed dimension 2? About half of what you have deduced is wrong. Matrices, arrays, and dataframes do have dimensions, at least in technical R parlance, namely they have an attribute which can be queried with dim(). By definition matrices and dataframes have 2 dimensions. Arrays and matrices can be redimensioned, but dataframes cannot. Factors, lists, and atomic vectors do not have dimensions, but they do have lengths. An appropriately structured list (one with vectors all the same length) can be coerced to a dataframe with as.data.frame(). -- David Winsemius, MD Alameda, CA, USA __ 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] sensitivity and specificity in svyglm??
On Thu, Aug 16, 2012 at 9:01 AM, Diana Marcela Martinez Ruiz dianamm...@hotmail.com wrote: Hello, As obtained from a table svyglm clasificaion, sensitivity and specificity. The funtion ConfusionMatrix () of the library (caret) gives these results but not how to apply it to svyglm. predict() will give you fitted values from svyglm on either the training data or new test data. You need to choose a threshold to turn the predicted probabilities into predicted 1s and 0s. At this point you could use ConfusionMatrix to compute sensitivity and specificity, but its uncertainty estimates won't be appropriate for the survey design. -thomas -- Thomas Lumley Professor of Biostatistics University of Auckland __ 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] r data structures
It would be helpful to distinguish between a formal dimension attribute, and a (personal) conceptual model of whether or not any particular R object, or type of object, has dimension. Mention of data frames having dimension can be found in the help page for the dim() function. foo - 1:10 is.vector(foo) [1] TRUE dim(foo) NULL attributes(foo) NULL str(foo) int [1:10] 1 2 3 4 5 6 7 8 9 10 length(foo) [1] 10 bah - matrix(1:10, nrow=2) is.vector(bah)[1] FALSE dim(bah) [1] 2 5 attributes(bah) $dim [1] 2 5 str(bah) int [1:2, 1:5] 1 2 3 4 5 6 7 8 9 10 length(bah) [1] 10 The vector does not have a formal dimension (dim) attribute, but the matrix does. Regarding data frames and lists: ## ## data frame ## junk - data.frame(a=1:3,b=1:3) str(junk) 'data.frame': 3 obs. of 2 variables: $ a: int 1 2 3 $ b: int 1 2 3 attributes(junk) $names [1] a b $row.names [1] 1 2 3 $class [1] data.frame dim(junk) [1] 3 2 ## ## list ## glug - list(a=1, b=letters[3]) str(glug) List of 2 $ a: num 1 $ b: chr c attributes(glug) $names [1] a b dim(glug) NULL length(glug) [1] 2 Conceptually, I would consider data frames to have two dimensions (rows and columns). They do not have a formal dim attribute, but the dim() function does return a value. I personally do not think of lists as having dimension -- I never ask myself, what is the dimension of a list? But I do often enquire as to the length of a list, so might, if forced to, admit that lists have one dimension, length. But I do not think it is helpful to think of lists as having dimension. Certainly, lists do not have two dimensions. -- Don MacQueen Lawrence Livermore National Laboratory 7000 East Ave., L-627 Livermore, CA 94550 925-423-1062 On 8/16/12 11:49 AM, Schumacher, Jay S j...@neo.tamu.edu wrote: hi, i'm trying to understand r data structures. i see that vectors, matrix, factors and arrays have a dimension. there seems to be no mention of dimensionality anywhere for lists or dataframes. can i consider lists and frames to be of fixed dimension 2? thanks, jay s __ 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] r data structures
are these correct/accurate/sensible statements: a vector is a one dimensional object. a matrix is a two dimensional object. a list is a one dimensional object. i'm working from this web page: http://www.agr.kuleuven.ac.be/vakken/statisticsbyR/someDataStructures.htm - On Aug 16, 2012, at 11:49 AM, Schumacher, Jay S wrote: hi, i'm trying to understand r data structures. i see that vectors, matrix, factors and arrays have a dimension. there seems to be no mention of dimensionality anywhere for lists or dataframes. can i consider lists and frames to be of fixed dimension 2? About half of what you have deduced is wrong. Matrices, arrays, and dataframes do have dimensions, at least in technical R parlance, namely they have an attribute which can be queried with dim(). By definition matrices and dataframes have 2 dimensions. Arrays and matrices can be redimensioned, but dataframes cannot. Factors, lists, and atomic vectors do not have dimensions, but they do have lengths. An appropriately structured list (one with vectors all the same length) can be coerced to a dataframe with as.data.frame(). -- David Winsemius, MD Alameda, CA, USA __ 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] Reference a variable inside a string and another for object assingments
I sometimes do this sort of thing with tricks like this: sql - select * from mytable where dt = 'ADATE' dbGetQuery( con, gsub('ADATE', '2012-06-12 23:14', sql) ) Or if mydates is a vector of dates stored as a POSIXt object: for (id in mydates) { dbGetQuery( con, gsub('ADATE', format(id), sql) ) } -Don -- Don MacQueen Lawrence Livermore National Laboratory 7000 East Ave., L-627 Livermore, CA 94550 925-423-1062 On 8/16/12 12:30 PM, Kenneth Rose kennethros...@gmail.com wrote: Hi R community I copied a bit of my R code that gets some data from a database. You won't be able to run the code, but I am a beginner so you will probably understand what going on. I would like to make a variable I can refer to inside the sqlQuery. Instead of writing the start date and time (ex SP.lokaldatotid = '2005-01-01 00:00:00') inside the query I would like to define it in the beginning of the code, so I don't have to fiddle with a lot of dates each time I wan't to change it. I would like to do this for a few of the variables and maybe even make a list/array I can loop through, so I don't have to write the same code multiple times (for SYS and DK1). I have searched for a solution for two days now, but I am not sure what it's called and are probably writing the wrong queries :-) Thank you for your help! Kenneth My code: library(xts) library(RODBC) #Define channnel (i configured my own SYSTEM-DNS, via ODBC) ch - odbcConnect(DI2) # ## GET DATA## # ## SYSTEM spot ## # Hent data fra SQL Server sys - sqlQuery (ch, paste(SELECT SP.lokaldatotid, SP.pris FROM DataIndsamling2.dbo.SpotPriser SP, WHERE (SP.omraade_id= 0 AND SP.lokaldatotid = '2005-01-01 00:00:00'))) #Definer dato og tid kolonne sys$lokaldatotid - as.POSIXct(sys$lokaldatotid) #Make a XTS object sys_xts - xts(sys[,-1], order.by=sys[,1]) # Recalculate data from hours to daily, monthly and yearly averages sys_xts_daily - apply.daily(sys_xts, FUN=mean) sys_xts_monthly - apply.monthly(sys_xts, FUN=mean) sys_xts_yearly - apply.yearly(sys_xts, FUN=mean) ## DK1 spot # # Hent data fra SQL Server dk1 - sqlQuery (ch, paste(SELECT SP.lokaldatotid, SP.pris FROM DataIndsamling2.dbo.SpotPriser SP, WHERE (SP.omraade_id= 5 AND SP.lokaldatotid = '2005-01-01 00:00:00'))) #Definer dato og tid kolonne dk1$lokaldatotid - as.POSIXct(dk1$lokaldatotid) #Lav om til xts object dk1_xts - xts(dk1[,-1], order.by=dk1[,1]) #Data omregnet fra time - daglig, måned, årlige gennemsnit dk1_xts_daily - apply.daily(dk1_xts, FUN=mean) dk1_xts_monthly - apply.monthly(dk1_xts, FUN=mean) dk1_xts_yearly - apply.yearly(dk1_xts, FUN=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. __ 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] r data structures
On Thu, Aug 16, 2012 at 4:50 PM, Schumacher, Jay S j...@neo.tamu.edu wrote: are these correct/accurate/sensible statements: a vector is a one dimensional object. a matrix is a two dimensional object. a list is a one dimensional object. i'm working from this web page: http://www.agr.kuleuven.ac.be/vakken/statisticsbyR/someDataStructures.htm I would say not (personally) -- not everything has a dimension in R (everything does have a length though). To wit, x - 1:4 is.vector(x) # TRUE dim(x) # NULL length(dim(x)) # 0 Michael __ 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] r data structures
yes, thank you, conceptual model (rather than formal dimension attribute) is where i'm coming from at this point. It would be helpful to distinguish between a formal dimension attribute, and a (personal) conceptual model of whether or not any particular R object, or type of object, has dimension. Mention of data frames having dimension can be found in the help page for the dim() function. foo - 1:10 is.vector(foo) [1] TRUE dim(foo) NULL attributes(foo) NULL str(foo) int [1:10] 1 2 3 4 5 6 7 8 9 10 length(foo) [1] 10 bah - matrix(1:10, nrow=2) is.vector(bah)[1] FALSE dim(bah) [1] 2 5 attributes(bah) $dim [1] 2 5 str(bah) int [1:2, 1:5] 1 2 3 4 5 6 7 8 9 10 length(bah) [1] 10 The vector does not have a formal dimension (dim) attribute, but the matrix does. Regarding data frames and lists: ## ## data frame ## junk - data.frame(a=1:3,b=1:3) str(junk) 'data.frame': 3 obs. of 2 variables: $ a: int 1 2 3 $ b: int 1 2 3 attributes(junk) $names [1] a b $row.names [1] 1 2 3 $class [1] data.frame dim(junk) [1] 3 2 ## ## list ## glug - list(a=1, b=letters[3]) str(glug) List of 2 $ a: num 1 $ b: chr c attributes(glug) $names [1] a b dim(glug) NULL length(glug) [1] 2 Conceptually, I would consider data frames to have two dimensions (rows and columns). They do not have a formal dim attribute, but the dim() function does return a value. I personally do not think of lists as having dimension -- I never ask myself, what is the dimension of a list? But I do often enquire as to the length of a list, so might, if forced to, admit that lists have one dimension, length. But I do not think it is helpful to think of lists as having dimension. Certainly, lists do not have two dimensions. -- Don MacQueen Lawrence Livermore National Laboratory 7000 East Ave., L-627 Livermore, CA 94550 925-423-1062 On 8/16/12 11:49 AM, Schumacher, Jay S j...@neo.tamu.edu wrote: hi, i'm trying to understand r data structures. i see that vectors, matrix, factors and arrays have a dimension. there seems to be no mention of dimensionality anywhere for lists or dataframes. can i consider lists and frames to be of fixed dimension 2? thanks, jay s __ 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] r data structures
On Aug 16, 2012, at 1:50 PM, Schumacher, Jay S wrote: are these correct/accurate/sensible statements: a vector is a one dimensional object. a matrix is a two dimensional object. a list is a one dimensional object. i'm working from this web page: http://www.agr.kuleuven.ac.be/vakken/statisticsbyR/someDataStructures.htm You can have as many personal representations of R structures as you want. If you are intent on communication with other useRs, I think you should restrict the use of dimension to objects that return a non-NULL value from dim(). And I think one should use 'length' for the dimension-like aspect for atomic vectors and lists. (I originally used the word attribute, but that is a specific function and applied to such structures would not return a length-value.) Dimensions is R can have other attributes such as names that often need to be accessed or manipulated One further source of confusion is length() applied to matrices or dataframes. It will return a value from matrices that is nrow()*ncol() and from dataframes (which are really lists under the hood) a value that is ncol(). The latter value is rather different than my naive expectation, which was that a dataframe's length would be the number of cases or rows. That webpage obviously has its own definition of dimension (and it's perfectly free to make up its own terms) but it is not one that is in accord with An Introduction to R or with typical R discourse. -- David. - On Aug 16, 2012, at 11:49 AM, Schumacher, Jay S wrote: hi, i'm trying to understand r data structures. i see that vectors, matrix, factors and arrays have a dimension. there seems to be no mention of dimensionality anywhere for lists or dataframes. can i consider lists and frames to be of fixed dimension 2? About half of what you have deduced is wrong. Matrices, arrays, and dataframes do have dimensions, at least in technical R parlance, namely they have an attribute which can be queried with dim(). By definition matrices and dataframes have 2 dimensions. Arrays and matrices can be redimensioned, but dataframes cannot. Factors, lists, and atomic vectors do not have dimensions, but they do have lengths. An appropriately structured list (one with vectors all the same length) can be coerced to a dataframe with as.data.frame(). -- David Winsemius, MD Alameda, CA, USA David Winsemius, MD Alameda, CA, USA __ 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] r data structures
I don't disagree with Michael, but I would add that to me it also depends. If one thinks in terms of subsetting an object (for objects that can be subsetted) To subset a vector, one supplies *one* value for the index: myvector[3] myvector[ 2:5 ] are valid statements. Similarly for a list mylist[4] mylist[ c(1,3) ] are valid statements. Whereas for a matrix or data frame, one must supply *two* index values (even if one of them may be omitted) mydf[ 1 , 3 ] mydf[ , 5 ] mymat[ 2:5 , ] mymat[ 3 , 4:6 ] are valid statements. So from that perspective, it's reasonable to think of vectors and lists having one dimension, and matrices and data frames as having two. Formally, it's a little different, since the underlying structure of a data frame is actually a list: junk - data.frame(a=1:3, b=letters[1:3] ) is.list(junk) [1] TRUE and lists do not, formally, have a dimension attribute. I would add that in everyday more or less casual work with R, matrices, arrays, and data frames are the only objects where I find it useful to think about their dimension. Otherwise it's length. Or maybe neither, for some objects. -Don -- Don MacQueen Lawrence Livermore National Laboratory 7000 East Ave., L-627 Livermore, CA 94550 925-423-1062 On 8/16/12 1:59 PM, R. Michael Weylandt michael.weyla...@gmail.com wrote: On Thu, Aug 16, 2012 at 4:50 PM, Schumacher, Jay S j...@neo.tamu.edu wrote: are these correct/accurate/sensible statements: a vector is a one dimensional object. a matrix is a two dimensional object. a list is a one dimensional object. i'm working from this web page: http://www.agr.kuleuven.ac.be/vakken/statisticsbyR/someDataStructures.htm I would say not (personally) -- not everything has a dimension in R (everything does have a length though). To wit, x - 1:4 is.vector(x) # TRUE dim(x) # NULL length(dim(x)) # 0 Michael __ 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] r data structures
On Thu, Aug 16, 2012 at 5:44 PM, MacQueen, Don macque...@llnl.gov wrote: Whereas for a matrix or data frame, one must supply *two* index values (even if one of them may be omitted) mydf[ 1 , 3 ] mydf[ , 5 ] mymat[ 2:5 , ] mymat[ 3 , 4:6 ] are valid statements. Not quite: x - matrix(rev(1:9), ncol = 3) x[5] x[2:6] x - data.frame(x) x[3] I understand this as meaning, when you don't use special 2D indexing, R falls back on 1D indexing behavior given by the relevant superclass: vector for matrix and list for data.frame. Cheers, RMW __ 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] question about A2R
Dear List I'm trying to install a package not present in cran named A2R ( http://addictedtor.free.fr/graphiques/RGraphGallery.php?graph=79) After running the demo script I retrieve the following error: cannot change value of locked binding for '._a2r_counter' Please could someone give to me a tip about my error? Thank you very much Here is my sessionInfo() R version 2.15.0 (2012-03-30) Platform: x86_64-pc-linux-gnu (64-bit) locale: [1] LC_CTYPE=it_IT.UTF-8 LC_NUMERIC=C [3] LC_TIME=it_IT.UTF-8LC_COLLATE=it_IT.UTF-8 [5] LC_MONETARY=it_IT.UTF-8LC_MESSAGES=it_IT.UTF-8 [7] LC_PAPER=C LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=it_IT.UTF-8 LC_IDENTIFICATION=C attached base packages: [1] splines stats4grid stats graphics grDevices utils [8] datasets methods base other attached packages: [1] fpc_2.0-3 flexmix_2.3-8 multcomp_1.2-12 survival_2.36-14 [5] mvtnorm_0.9-9992 modeltools_0.2-19 lattice_0.20-6mclust_3.5 [9] cluster_1.14.2MASS_7.3-19 A2R_0.0-4 loaded via a namespace (and not attached): [1] tcltk_2.15.0 tools_2.15.0 [[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] Find and install old package to R 2.11 in UNIX
Hi, I'm having trouble installing and using the 'foreign' package in R on a UNIX machine. sessionInfo() R version 2.11.1 (2010-05-31) sparc-sun-solaris2.10 locale: [1] C attached base packages: [1] stats graphics grDevices utils datasets methods base Is there a way to find and install an old 'foreign' package that works with my machine? Does such a method generalize to finding other out-of-date packages for my machine? Thanks! Kevin [[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] Find and install old package to R 2.11 in UNIX
On Aug 16, 2012, at 4:33 PM, Kevin Goulding wrote: Hi, I'm having trouble installing and using the 'foreign' package in R on a UNIX machine. sessionInfo() R version 2.11.1 (2010-05-31) sparc-sun-solaris2.10 locale: [1] C attached base packages: [1] stats graphics grDevices utils datasets methods base Is there a way to find and install an old 'foreign' package that works with my machine? Does such a method generalize to finding other out-of-date packages for my machine? Yes, there is a general method. Install from archived package as source. http://cran.r-project.org/src/contrib/Archive -- David Winsemius, MD Alameda, CA, USA __ 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] Apply a function according to factor levels.
Dear all, I have a question on applying a function to the data according to factor levels. For example, for the data below, what is the best way to apply a function to values according to different levels of samples (1,2,3,4,5)? values ind sample 1 0.03325 1 1 2 0.03305 1 1 3 0.03185 1 1 4 0.03515 1 1 5 0.03375 1 1 6 0.01180 1 2 7 0.01850 1 3 8 0.02915 1 4 9 0.06200 1 5 10 0.03230 2 1 11 0.03345 2 1 12 0.03385 2 1 13 0.03605 2 1 14 0.03225 2 1 15 0.01145 2 2 16 0.01805 2 3 17 0.02950 2 4 18 0.05995 2 5 19 0.03425 3 1 20 0.03575 3 1 21 0.03535 3 1 22 0.03380 3 1 23 0.03410 3 1 24 0.01050 3 2 25 0.01735 3 3 26 0.03140 3 4 27 0.06170 3 5 28 0.03430 4 1 29 0.03185 4 1 30 0.03165 4 1 31 0.03380 4 1 32 0.03235 4 1 33 0.01100 4 2 34 0.01825 4 3 35 0.03045 4 4 36 0.06060 4 5 37 0.03280 5 1 38 0.03350 5 1 39 0.03215 5 1 40 0.03545 5 1 41 0.03285 5 1 42 0.01085 5 2 43 0.01660 5 3 44 0.03060 5 4 45 0.06605 5 5 Thank you. Hannah [[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] Apply a function according to factor levels.
?tapply -- David L Carlson Associate Professor of Anthropology Texas AM University College Station, TX 77843-4352 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On Behalf Of li li Sent: Thursday, August 16, 2012 8:31 PM To: r-help Subject: [R] Apply a function according to factor levels. Dear all, I have a question on applying a function to the data according to factor levels. For example, for the data below, what is the best way to apply a function to values according to different levels of samples (1,2,3,4,5)? values ind sample 1 0.03325 1 1 2 0.03305 1 1 3 0.03185 1 1 4 0.03515 1 1 5 0.03375 1 1 6 0.01180 1 2 7 0.01850 1 3 8 0.02915 1 4 9 0.06200 1 5 10 0.03230 2 1 11 0.03345 2 1 12 0.03385 2 1 13 0.03605 2 1 14 0.03225 2 1 15 0.01145 2 2 16 0.01805 2 3 17 0.02950 2 4 18 0.05995 2 5 19 0.03425 3 1 20 0.03575 3 1 21 0.03535 3 1 22 0.03380 3 1 23 0.03410 3 1 24 0.01050 3 2 25 0.01735 3 3 26 0.03140 3 4 27 0.06170 3 5 28 0.03430 4 1 29 0.03185 4 1 30 0.03165 4 1 31 0.03380 4 1 32 0.03235 4 1 33 0.01100 4 2 34 0.01825 4 3 35 0.03045 4 4 36 0.06060 4 5 37 0.03280 5 1 38 0.03350 5 1 39 0.03215 5 1 40 0.03545 5 1 41 0.03285 5 1 42 0.01085 5 2 43 0.01660 5 3 44 0.03060 5 4 45 0.06605 5 5 Thank you. Hannah [[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] question about A2R
The package hasn't been modified since version 0.0-4 in August 2005. Your only hope is to try to contact the author: Package: A2R Type: Package Title: Romain Francois misc functions Version: 0.0-4 Date: 2005-08-05 Author: Romain Francois francoisrom...@free.fr Maintainer: Romain Francois francoisrom...@free.fr Description: Some functions of Romain Francois collection License: GPL version 2 or newer Depends: R (= 2.1.1), grid URL: http://addictedtor.free.fr/packages Built: R 2.2.1; ; 2006-01-04 23:25:37; unix -- David L Carlson Associate Professor of Anthropology Texas AM University College Station, TX 77843-4352 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On Behalf Of Guido Leoni Sent: Thursday, August 16, 2012 6:41 PM To: r-h...@stat.math.ethz.ch Subject: [R] question about A2R Dear List I'm trying to install a package not present in cran named A2R ( http://addictedtor.free.fr/graphiques/RGraphGallery.php?graph=79) After running the demo script I retrieve the following error: cannot change value of locked binding for '._a2r_counter' Please could someone give to me a tip about my error? Thank you very much Here is my sessionInfo() R version 2.15.0 (2012-03-30) Platform: x86_64-pc-linux-gnu (64-bit) locale: [1] LC_CTYPE=it_IT.UTF-8 LC_NUMERIC=C [3] LC_TIME=it_IT.UTF-8LC_COLLATE=it_IT.UTF-8 [5] LC_MONETARY=it_IT.UTF-8LC_MESSAGES=it_IT.UTF-8 [7] LC_PAPER=C LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=it_IT.UTF-8 LC_IDENTIFICATION=C attached base packages: [1] splines stats4grid stats graphics grDevices utils [8] datasets methods base other attached packages: [1] fpc_2.0-3 flexmix_2.3-8 multcomp_1.2-12 survival_2.36-14 [5] mvtnorm_0.9-9992 modeltools_0.2-19 lattice_0.20-6mclust_3.5 [9] cluster_1.14.2MASS_7.3-19 A2R_0.0-4 loaded via a namespace (and not attached): [1] tcltk_2.15.0 tools_2.15.0 [[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] Apply a function according to factor levels.
Hello, Or ?aggregate, depending on the wanted output. With the dataset provided by the op, apply function mean. dat - read.table(text= values ind sample 1 0.03325 1 1 2 0.03305 1 1 3 0.03185 1 1 [...etc...] 44 0.03060 5 4 45 0.06605 5 5 , header = TRUE) tapply(dat$values, dat$sample, mean) # named vector 12345 0.033556 0.011120 0.017750 0.030220 0.062060 aggregate(values ~ sample, data = dat, mean) # data.frame sample values 1 1 0.033556 2 2 0.011120 3 3 0.017750 4 4 0.030220 5 5 0.062060 Hope this helps, Rui Barradas Em 17-08-2012 02:41, David L Carlson escreveu: ?tapply -- David L Carlson Associate Professor of Anthropology Texas AM University College Station, TX 77843-4352 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On Behalf Of li li Sent: Thursday, August 16, 2012 8:31 PM To: r-help Subject: [R] Apply a function according to factor levels. Dear all, I have a question on applying a function to the data according to factor levels. For example, for the data below, what is the best way to apply a function to values according to different levels of samples (1,2,3,4,5)? values ind sample 1 0.03325 1 1 2 0.03305 1 1 3 0.03185 1 1 4 0.03515 1 1 5 0.03375 1 1 6 0.01180 1 2 7 0.01850 1 3 8 0.02915 1 4 9 0.06200 1 5 10 0.03230 2 1 11 0.03345 2 1 12 0.03385 2 1 13 0.03605 2 1 14 0.03225 2 1 15 0.01145 2 2 16 0.01805 2 3 17 0.02950 2 4 18 0.05995 2 5 19 0.03425 3 1 20 0.03575 3 1 21 0.03535 3 1 22 0.03380 3 1 23 0.03410 3 1 24 0.01050 3 2 25 0.01735 3 3 26 0.03140 3 4 27 0.06170 3 5 28 0.03430 4 1 29 0.03185 4 1 30 0.03165 4 1 31 0.03380 4 1 32 0.03235 4 1 33 0.01100 4 2 34 0.01825 4 3 35 0.03045 4 4 36 0.06060 4 5 37 0.03280 5 1 38 0.03350 5 1 39 0.03215 5 1 40 0.03545 5 1 41 0.03285 5 1 42 0.01085 5 2 43 0.01660 5 3 44 0.03060 5 4 45 0.06605 5 5 Thank you. Hannah [[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-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] GEE with R: double overdispersion?
Dear R users, I work with a descrete variable (sclae 0 - 27) which is highly skwed to the right (many zeros and small numbers). I measure this variable on a control and intervention cohort 5 times a year. When I analyze analyze this varoable at each time point separately and use GLM with family quasi-Poisson (descrete outcome and two binary variables, gender and cohort, are predictors), I observe an overdispersion. When I use GEE with R software, does GEE R package takes care only about over-dispersion regarding the repeated measure design per se, or it takes care about the over-dispersion within the cohort as well which I observe with GLM method when I choose quasipoisson family? If so what options in GEE should I use to control both types of overdispersion? I need to take care about the double effect of overdispersion (related to repeated measures and within cohort overdispersion) and wonder how GEE package takes care about it. Thank you very much for you help and ideas! ** Electronic Mail is not secure, may not be read every day, and should not be used for urgent or sensitive issues [[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] specific matrix element tranformation
Hi guys, I am trying to write a function that allows me to perform specific transformations to each element of a 2 by 2 matrix to generate a 3 by 3 matrix. Input into function-2 by 2 matrix Output from function -3 by 3 matrix For example: # a is my original 2 by 2 matrix #b is my new 3 by 3 matrix set.seed(2) a=matrix(rnorm(4),ncol=2) #let's say these are the transformations i wish to perform b[1,1]=a[1,1]+1 b[1,2]=a[2,1]*a[2,2] b[1,3]=a[2,2]+a[1,1] b[2,1]=a[1,1]-5 b[2,2]=sqrt(a[2,2]) b[2,3]=a[1,1]/a[2,2] b[3,1]=a[2,2]-3 b[3,2]=a[1,1]*[a[1,2]+a[2,2]) b[3,3]=sqrt(a[1,1])/a[1,2]) Thanks. Cheers, B -- View this message in context: http://r.789695.n4.nabble.com/specific-matrix-element-tranformation-tp4640550.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] How to extract from a column in a table?
HI, Slightly different way to do this: dat1-readLines(textConnection(Name Budlamp-Woodcutter Complex - 15 to 60% slope (60/25/15) Budlamp-Woodcutter Complex - 15 to 60% slope (60/25/15) Terrarossa-Blacktail-Pyeatt Complex - 1 to 40% slope (40/35/15/10) Terrarossa-Blacktail-Pyeatt Complex - 1 to 40% slope (40/35/15/10) )) dat2-data.frame(dat1) dat3-data.frame(Name=dat2[2:5,],slope=dat2[2:5,],percentage=dat2[2:5,]) dat3$Name-gsub((.*Complex)\\s-\\s(.*slope).*(\\(.*\\)),\\1,dat3$Name) dat3$slope-gsub((.*Complex)\\s-\\s(.*slope).*(\\(.*\\)),\\2,dat3$slope) dat3$percentage-gsub((.*Complex)\\s-\\s(.*slope).*(\\(.*\\)),\\3,dat3$percentage) dat3 # Name slope percentage #1 Budlamp-Woodcutter Complex 15 to 60% slope (60/25/15) #2 Budlamp-Woodcutter Complex 15 to 60% slope (60/25/15) #3 Terrarossa-Blacktail-Pyeatt Complex 1 to 40% slope (40/35/15/10) #4 Terrarossa-Blacktail-Pyeatt Complex 1 to 40% slope (40/35/15/10) A.K. From: Sapana Lohani lohani.sap...@ymail.com To: arun smartpink...@yahoo.com Cc: R help r-help@r-project.org Sent: Thursday, August 16, 2012 7:08 PM Subject: Re: [R] How to extract from a column in a table? Thank you :) From: arun smartpink...@yahoo.com To: Sapana Lohani lohani.sap...@ymail.com Cc: R help r-help@r-project.org Sent: Thursday, August 16, 2012 1:06 PM Subject: Re: [R] How to extract from a column in a table? Hi, Forgot the last part. colnames(dat3New)-c(name,slope,percentage) dat3New name slope percentage 1 Budlamp-Woodcutter Complex 15 to 60% slope (60/25/15) 2 Budlamp-Woodcutter Complex 15 to 60% slope (60/25/15) 3 Terrarossa-Blacktail-Pyeatt Complex 1 to 40% slope (40/35/15/10) 4 Terrarossa-Blacktail-Pyeatt Complex 1 to 40% slope (40/35/15/10) A.K. - Original Message - From: Sapana Lohani lohani.sap...@ymail.com To: r-help@r-project.org r-help@r-project.org Cc: Sent: Thursday, August 16, 2012 2:41 PM Subject: [R] How to extract from a column in a table? Hi, I have a table in which one column has the name of the objects as shown below. Name Budlamp-Woodcutter Complex - 15 to 60% slope (60/25/15) Budlamp-Woodcutter Complex - 15 to 60% slope (60/25/15) Terrarossa-Blacktail-Pyeatt Complex - 1 to 40% slope (40/35/15/10) Terrarossa-Blacktail-Pyeatt Complex - 1 to 40% slope (40/35/15/10) How can I split the single column into three columns like name (Budlamp-Woodcutter Complex), slope (15 to 60% slope) and percentage (60/25/15) thanks [[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] install.packages umask configuration
Hello, I've been trying to setup a site library that allows the users to manage the R packages themselves, but am having an issue with permissions. As seen below, when installing a package using install.packages, the umask used is always 022. Instead, I would like it to be 002, allowing any user to update packages that were installed by another user. Can someone explain how to get install.packages to respect the Sys.umask setting or another way to ensure that any user can update any package? Background information: OS: CentOS release 6.2 (Final) Kernel: Linux 2.6.32-220.el6.i686 #1 SMP i686 i386 GNU/Linux R was installed via R package on EPEL: http://dl.fedoraproject.org/pub/epel/6/i386/R-2.15.1-1.el6.i686.rpm Additonal configuration: $ echo 'R_LIBS_SITE=/usr/lib/R/site-library:${R_LIBS_SITE}' /usr/lib/R/etc/Renviron.site $ mkdir /usr/lib/R/site-library $ chmod 775 /usr/lib/R/site-library $ chgrp users /usr/lib/R/site-library/ Example: [user1@new-host-3 ~]$ ls -lah /usr/lib/R/site-library/ total 8.0K drwxrwxr-x. 2 root users 4.0K Aug 16 22:08 . drwxr-xr-x. 8 root root 4.0K Aug 16 22:08 .. [user1@new-host-3 ~]$ R R version 2.15.1 (2012-06-22) -- Roasted Marshmallows Copyright (C) 2012 The R Foundation for Statistical Computing ISBN 3-900051-07-0 Platform: i686-redhat-linux-gnu (32-bit) R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. Natural language support but running in an English locale R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. Sys.umask() [1] 22 Sys.umask(2) Sys.umask() [1] 2 install.packages(combinat) Installing package(s) into /usr/lib/R/site-library (as lib is unspecified) --- Please select a CRAN mirror for use in this session --- CRAN mirror 1: Argentina (La Plata) 2: Argentina (Mendoza) 3: Australia (Canberra) 4: Australia (Melbourne) 5: Austria 6: Belgium 7: Brazil (PR) 8: Brazil (RJ) 9: Brazil (SP 1)10: Brazil (SP 2) 11: Canada (BC) 12: Canada (NS) 13: Canada (ON) 14: Canada (QC 1) 15: Canada (QC 2)16: Chile 17: China (Beijing 1)18: China (Beijing 2) 19: China (Beijing 3)20: China (Guangzhou) 21: China (Hefei)22: China (Xiamen) 23: Colombia (Bogota)24: Colombia (Cali) 25: Denmark 26: Ecuador 27: France (Toulouse)28: France (Lyon 1) 29: France (Lyon 2) 30: Germany (Berlin) 31: Germany (Goettingen) 32: Germany (Wiesbaden) 33: Greece 34: India 35: Indonesia36: Iran 37: Ireland 38: Italy (Milano) 39: Italy (Padua)40: Italy (Palermo) 41: Japan (Hyogo)42: Japan (Tsukuba) 43: Japan (Tokyo)44: Korea 45: Latvia 46: Mexico (Mexico City) 47: Mexico (Texcoco) 48: Netherlands (Amsterdam) 49: Netherlands (Utrecht)50: New Zealand 51: Norway 52: Philippines 53: Poland (Oswiecim)54: Poland (Wroclaw) 55: Russia 56: Singapore 57: Slovakia 58: South Africa 59: Spain (Madrid) 60: Sweden 61: Switzerland 62: Taiwan (Taichung) 63: Taiwan (Taipei) 64: Thailand 65: UK (Bristol) 66: UK (London) 67: UK (St Andrews) 68: USA (CA 1) 69: USA (CA 2) 70: USA (IA) 71: USA (IN) 72: USA (KS) 73: USA (MD) 74: USA (MI) 75: USA (MO) 76: USA (OH) 77: USA (OR) 78: USA (PA 1) 79: USA (PA 2) 80: USA (TN) 81: USA (TX 1) 82: USA (TX 2) 83: USA (WA 1) 84: USA (WA 2) 85: Venezuela86: Vietnam Selection: 78 trying URL 'http://lib.stat.cmu.edu/R/CRAN/src/contrib/combinat_0.0-8.tar.gz' Content type 'application/x-gzip' length 7973 bytes opened URL == downloaded 7973 bytes * installing *source* package combinat ... ** Creating default NAMESPACE file ** R ** preparing package for lazy loading ** help *** installing help indices converting help for package combinat finding HTML links ... done combn html dmnom html hcube html nsimplexhtml permn html rmultinomialhtml x2u html xsimplexhtml ** building package indices ** testing if installed package can be loaded * DONE
Re: [R] Apply a function according to factor levels.
Hi, Try this: dat1-read.table(text= no. values ind sample 1 0.03325 1 1 2 0.03305 1 1 3 0.03185 1 1 4 0.03515 1 1 - - 42 0.01085 5 2 43 0.01660 5 3 44 0.03060 5 4 45 0.06605 5 5 ,sep=,header=TRUE) dat2-within(dat1,{sample-as.factor(sample)}) ddply(dat2,.(sample), function(x) mean(x$values)) # sample V1 #1 1 0.033556 #2 2 0.011120 #3 3 0.017750 #4 4 0.030220 #5 5 0.062060 A.K. - Original Message - From: li li hannah@gmail.com To: r-help r-help@r-project.org Cc: Sent: Thursday, August 16, 2012 9:31 PM Subject: [R] Apply a function according to factor levels. Dear all, I have a question on applying a function to the data according to factor levels. For example, for the data below, what is the best way to apply a function to values according to different levels of samples (1,2,3,4,5)? values ind sample 1 0.03325 1 1 2 0.03305 1 1 3 0.03185 1 1 4 0.03515 1 1 5 0.03375 1 1 6 0.01180 1 2 7 0.01850 1 3 8 0.02915 1 4 9 0.06200 1 5 10 0.03230 2 1 11 0.03345 2 1 12 0.03385 2 1 13 0.03605 2 1 14 0.03225 2 1 15 0.01145 2 2 16 0.01805 2 3 17 0.02950 2 4 18 0.05995 2 5 19 0.03425 3 1 20 0.03575 3 1 21 0.03535 3 1 22 0.03380 3 1 23 0.03410 3 1 24 0.01050 3 2 25 0.01735 3 3 26 0.03140 3 4 27 0.06170 3 5 28 0.03430 4 1 29 0.03185 4 1 30 0.03165 4 1 31 0.03380 4 1 32 0.03235 4 1 33 0.01100 4 2 34 0.01825 4 3 35 0.03045 4 4 36 0.06060 4 5 37 0.03280 5 1 38 0.03350 5 1 39 0.03215 5 1 40 0.03545 5 1 41 0.03285 5 1 42 0.01085 5 2 43 0.01660 5 3 44 0.03060 5 4 45 0.06605 5 5 Thank you. Hannah [[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] Apply a function according to factor levels.
Got it. Thanks so much. Hannah 2012/8/16 arun smartpink...@yahoo.com Hi, Try this: dat1-read.table(text= no. values ind sample 1 0.03325 1 1 2 0.03305 1 1 3 0.03185 1 1 4 0.03515 1 1 - - 42 0.01085 5 2 43 0.01660 5 3 44 0.03060 5 4 45 0.06605 5 5 ,sep=,header=TRUE) dat2-within(dat1,{sample-as.factor(sample)}) ddply(dat2,.(sample), function(x) mean(x$values)) # sample V1 #1 1 0.033556 #2 2 0.011120 #3 3 0.017750 #4 4 0.030220 #5 5 0.062060 A.K. - Original Message - From: li li hannah@gmail.com To: r-help r-help@r-project.org Cc: Sent: Thursday, August 16, 2012 9:31 PM Subject: [R] Apply a function according to factor levels. Dear all, I have a question on applying a function to the data according to factor levels. For example, for the data below, what is the best way to apply a function to values according to different levels of samples (1,2,3,4,5)? values ind sample 1 0.03325 1 1 2 0.03305 1 1 3 0.03185 1 1 4 0.03515 1 1 5 0.03375 1 1 6 0.01180 1 2 7 0.01850 1 3 8 0.02915 1 4 9 0.06200 1 5 10 0.03230 2 1 11 0.03345 2 1 12 0.03385 2 1 13 0.03605 2 1 14 0.03225 2 1 15 0.01145 2 2 16 0.01805 2 3 17 0.02950 2 4 18 0.05995 2 5 19 0.03425 3 1 20 0.03575 3 1 21 0.03535 3 1 22 0.03380 3 1 23 0.03410 3 1 24 0.01050 3 2 25 0.01735 3 3 26 0.03140 3 4 27 0.06170 3 5 28 0.03430 4 1 29 0.03185 4 1 30 0.03165 4 1 31 0.03380 4 1 32 0.03235 4 1 33 0.01100 4 2 34 0.01825 4 3 35 0.03045 4 4 36 0.06060 4 5 37 0.03280 5 1 38 0.03350 5 1 39 0.03215 5 1 40 0.03545 5 1 41 0.03285 5 1 42 0.01085 5 2 43 0.01660 5 3 44 0.03060 5 4 45 0.06605 5 5 Thank you. Hannah [[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.htmlhttp://www.r-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[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] Linear mixed model using R
Dear all, I am trying to use R to fit mixed models. Take the following example, where ind is a random effect and sample is fixed. I wanted to fit Model 1: values = ind + sample Model 2: values =ind * sample Model 3: values=ind(sample) + sample Tried to use the below for mod1, but it did not work. Can anyone give some help on this. Thanks so much. mod1 - lme(values ~ sample + random=~ 1|ind, data=y) values ind sample 1 0.03325 1 1 2 0.03305 1 1 3 0.03185 1 1 4 0.03515 1 1 5 0.03375 1 1 6 0.01180 1 2 7 0.01850 1 3 8 0.02915 1 4 9 0.06200 1 5 10 0.03230 2 1 11 0.03345 2 1 12 0.03385 2 1 13 0.03605 2 1 14 0.03225 2 1 15 0.01145 2 2 16 0.01805 2 3 17 0.02950 2 4 18 0.05995 2 5 19 0.03425 3 1 20 0.03575 3 1 21 0.03535 3 1 22 0.03380 3 1 23 0.03410 3 1 24 0.01050 3 2 25 0.01735 3 3 26 0.03140 3 4 27 0.06170 3 5 28 0.03430 4 1 29 0.03185 4 1 30 0.03165 4 1 31 0.03380 4 1 32 0.03235 4 1 33 0.01100 4 2 34 0.01825 4 3 35 0.03045 4 4 36 0.06060 4 5 [[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] Unequal splits from a column
Hi I am new to R so am struggling with the commands here I have one column in a table that looks like slope (60/25/15) slope (90/10) slope (40/35/15/10) slope (40/25/25/10) I want to have 4 columns with just the number inside the parenthesis. when there is no number that cell can have 0. I want the output like this 60 25 15 0 90 10 0 0 40 35 15 10 40 25 25 10 Can somebody help me?? Thanks [[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] specific matrix element tranformation
Hi guys, After a long while I came up with this : set.seed(2) a-matrix(rnorm(4),ncol=2) abc-function(a) { b=matrix(NA,nrow=3,ncol=3) b[1,1]=a[1,1]+1 b[1,2]=a[2,1]*a[2,2] b[1,3]=a[2,2]+a[1,1] b[2,1]=a[1,1]-5 b[2,2]=sqrt(a[2,2]) b[2,3]=a[1,1]/a[2,2] b[3,1]=a[2,2]-3 b[3,2]=a[1,1]*(a[1,2]+a[2,2]) b[3,3]=sqrt(a[1,1])/a[1,2] return(b=matrix(c(b[1,1],b[1,2],b[1,3],b[2,1],b[2,2],b[2,3], b[3,1],b[3,2],b[3,3]),ncol=3)) } How can I improve on it? Cheers, B -- View this message in context: http://r.789695.n4.nabble.com/specific-matrix-element-tranformation-tp4640550p4640554.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] no true negative data, need roc curve
hi, TN=0 in all cases, with this how can i plot the ROC, i need help in this regard. thank you. Date: Thu, 16 Aug 2012 09:47:20 -0700 From: ml-node+s789695n4640509...@n4.nabble.com To: vijay...@outlook.com Subject: Re: no true negative data, need roc curve To clarify: Is TN = 0 or do you not know TN (N)? On 16.08.2012, at 11:51, vjyns wrote: Hi, I want to plot ROC curve for my detection algorithm which detects features in different images at two different thresholds. 6 different images used and obtained tp, fp and fn. No tn in my case. in first threshold run i obtained 6 values of tp,fp and fn. In second threshold run agian i got 6 more. i had calculated tpr and fpr. How to plot ROC in this case. Is this possible to plot ROC curve in this case? If s, please guide me to plot that. thank you. http://r.789695.n4.nabble.com/file/n4640474/in1.png -- View this message in context: http://r.789695.n4.nabble.com/no-true-negative-data-need-roc-curve-tp4640474.html Sent from the R help mailing list archive at Nabble.com. __ [hidden email] 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. __ [hidden email] 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. If you reply to this email, your message will be added to the discussion below: http://r.789695.n4.nabble.com/no-true-negative-data-need-roc-curve-tp4640474p4640509.html To unsubscribe from no true negative data, need roc curve, click here. NAML -- View this message in context: http://r.789695.n4.nabble.com/no-true-negative-data-need-roc-curve-tp4640474p4640557.html Sent from the R help mailing list archive at Nabble.com. [[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] Problem Installign Packages
To Whom It May Concern, In attempting to install the e1071 package, I get the message below after selecting the mirror site. -- Please select a CRAN mirror for use in this session --- Warning: unable to access index for repository http://mirror.fcaglp.unlp.edu.ar/CRAN/bin/windows/contrib/2.15 I seem to have the problem with any other package that I attempt to install. Please advise. Ziad Elmously http://www.kantar.com/disclaimer.html [[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] Linear mixed model using R
1. Post on R-sig-mixed-models, not here. 2. Models 2 and 3 make no sense (to me, anyway). What do you think they mean? (Don't answer here -- explain on the mixed models list). -- Bert On Thu, Aug 16, 2012 at 9:13 PM, li li hannah@gmail.com wrote: Dear all, I am trying to use R to fit mixed models. Take the following example, where ind is a random effect and sample is fixed. I wanted to fit Model 1: values = ind + sample Model 2: values =ind * sample Model 3: values=ind(sample) + sample Tried to use the below for mod1, but it did not work. Can anyone give some help on this. Thanks so much. mod1 - lme(values ~ sample + random=~ 1|ind, data=y) Your syntax is wrong. Re-read ?lme (random is a separate argument, not part of the formula). values ind sample 1 0.03325 1 1 2 0.03305 1 1 3 0.03185 1 1 4 0.03515 1 1 5 0.03375 1 1 6 0.01180 1 2 7 0.01850 1 3 8 0.02915 1 4 9 0.06200 1 5 10 0.03230 2 1 11 0.03345 2 1 12 0.03385 2 1 13 0.03605 2 1 14 0.03225 2 1 15 0.01145 2 2 16 0.01805 2 3 17 0.02950 2 4 18 0.05995 2 5 19 0.03425 3 1 20 0.03575 3 1 21 0.03535 3 1 22 0.03380 3 1 23 0.03410 3 1 24 0.01050 3 2 25 0.01735 3 3 26 0.03140 3 4 27 0.06170 3 5 28 0.03430 4 1 29 0.03185 4 1 30 0.03165 4 1 31 0.03380 4 1 32 0.03235 4 1 33 0.01100 4 2 34 0.01825 4 3 35 0.03045 4 4 36 0.06060 4 5 [[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. -- Bert Gunter Genentech Nonclinical Biostatistics Internal Contact Info: Phone: 467-7374 Website: http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm __ 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] no true negative data, need roc curve
TN=0 in all cases, i had only tp, fp and fn for 6 images (two sets). suggest me how plot the roc curve. -- View this message in context: http://r.789695.n4.nabble.com/no-true-negative-data-need-roc-curve-tp4640474p4640558.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] ANOVA repeated measures and post-hoc
Hi Diego, I am struggeling with this question also for some time and there does not seem to be an easy and general solution to this problem. At least I haven't found one. However, if you have just one repeated-measures factor, use the solution describe by me here: http://stats.stackexchange.com/a/15532/442 Furthermore, you might wanna check the package phia with accompanying vignette (but it uses multivariate tests). For running the ANOVA you could also check my new package afex. Cheers, Henrik Diego Bucci schrieb: Hi, I performed an ANOVA repeated measures but I still can't find any good news regarding the possibility to perform multiple comparisons. Can anyone help me? Thanks Diego Bucci Fisiologia Veterinaria Dipartimento di Scienze Mediche Veterinarie Università degli Studi di Bologna Via Tolara di Sopra, 50 40064 Ozzano dell'Emilia, BO Tel. 00390512097904 mail diego.buc...@unibo.it [[alternative HTML version deleted]] -- Dipl. Psych. Henrik Singmann PhD Student Albert-Ludwigs-Universität Freiburg, Germany http://www.psychologie.uni-freiburg.de/Members/singmann __ 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] Unequal splits from a column
Hello, Try the following. x - c(slope (60/25/15), slope (90/10), slope (40/35/15/10), slope (40/25/25/10)) dat - data.frame(X = x) lst - unlist(lapply(dat, function(.x) gsub(slope \\((.*)\\)$, \\1, .x))) lst - strsplit(lst, /) keep - seq_len(max(unlist(lapply(lst, length vec - rep(0, length(keep)) result - do.call(rbind, lapply(lst, function(.x) as.integer(c(.x, vec)[keep]))) Now, in your case, just substitute 'dat' by the name of your vector. (I think this solution is too complicated but it predicts for the case where the input vector is in fact a list.) Hope this helps, Rui Barradas Em 17-08-2012 06:05, Sapana Lohani escreveu: Hi I am new to R so am struggling with the commands here I have one column in a table that looks like slope (60/25/15) slope (90/10) slope (40/35/15/10) slope (40/25/25/10) I want to have 4 columns with just the number inside the parenthesis. when there is no number that cell can have 0. I want the output like this 60 25 15 0 90 10 0 0 40 35 15 10 40 25 25 10 Can somebody help me?? Thanks [[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.