Re: [R] Summary using by() returns character arrays in a list
Hi But i still wonder what is wrong on aggregate? aggregate(iris, list(iris$Species), summary) gives you somewhat complicated data frame with numeric values, which you can extract as you wish. names(aggregate(iris, list(iris$Species), summary)[2]) [1] Sepal.Length aggregate(iris, list(iris$Species), summary)[,2] Min. 1st Qu. Median Mean 3rd Qu. Max. [1,] 4.3 4.8005.0 5.006 5.2 5.8 [2,] 4.9 5.6005.9 5.936 6.3 7.0 [3,] 4.9 6.2256.5 6.588 6.9 7.9 Regards Petr -Original Message- From: Alex van der Spek [mailto:do...@xs4all.nl] Sent: Wednesday, October 10, 2012 4:03 PM To: PIKAL Petr Cc: Alex van der Spek; r-help@r-project.org Subject: RE: [R] Summary using by() returns character arrays in a list Thank you Petr, Try this str(by(iris, iris$Species, summary)) and you will see what is actually returned is a list of 3, each element containing a character table, not a numeric table. The rownames of these tables are empty but should contain the names of the summary stats. I have a workaround now. Modified the summary.data.frame method to output numeric values and not the character strings. The rownames I set afterwards in a for loop. Still would like to know how to do this internal to summary.data.frame though. Regards, Alex van der Spek Hi -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On Behalf Of Alex van der Spek Sent: Wednesday, October 10, 2012 2:48 PM To: r-help@r-project.org Subject: [R] Summary using by() returns character arrays in a list I use by() to generate a summary statistics like so: Lbys - by(dat[Nidx], dat$LipTest, summary) where Nidx is an index vector with names picking out the columns in the data frame dat. This returns a list of character arrays (see below for str() output) where the columns are named correctly but the rownames are empty strings and the values are strings prepended with the summary statistic's name (e.g. Min., Median ). Without knowledge of your data it is difficult to understand what is wrong. If I use iris data set as input everything goes as expected data(iris) summary(iris) Sepal.LengthSepal.Width Petal.LengthPetal.Width Min. :4.300 Min. :2.000 Min. :1.000 Min. :0.100 1st Qu.:5.100 1st Qu.:2.800 1st Qu.:1.600 1st Qu.:0.300 Median :5.800 Median :3.000 Median :4.350 Median :1.300 Mean :5.843 Mean :3.057 Mean :3.758 Mean :1.199 3rd Qu.:6.400 3rd Qu.:3.300 3rd Qu.:5.100 3rd Qu.:1.800 Max. :7.900 Max. :4.400 Max. :6.900 Max. :2.500 Species setosa:50 versicolor:50 virginica :50 by(iris, iris$Species, summary) iris$Species: setosa Sepal.LengthSepal.Width Petal.LengthPetal.Width Min. :4.300 Min. :2.300 Min. :1.000 Min. :0.100 1st Qu.:4.800 1st Qu.:3.200 1st Qu.:1.400 1st Qu.:0.200 Median :5.000 Median :3.400 Median :1.500 Median :0.200 Mean :5.006 Mean :3.428 Mean :1.462 Mean :0.246 3rd Qu.:5.200 3rd Qu.:3.675 3rd Qu.:1.575 3rd Qu.:0.300 Max. :5.800 Max. :4.400 Max. :1.900 Max. :0.600 Species setosa:50 versicolor: 0 virginica : 0 I am reading the code of summary.data.frame() but can't figure out how I can change the action of that function to return list of numeric matrices with as rownames the summary statistic's name (Min., Max. etc) and as values the numeric values of the calculated summary statistic. Just what do you not like on such output and how do you want the output structured? Maybe you want aggregate, but without simple data it is hard to say. aggregate(iris[1:2], list(iris$Species), summary) Regards Petr Any help much appreciated! Regards, Alex van der Spek str(Lbys) List of 2 $: 'table' chr [1:6, 1:19] Min. :-0.190 1st Qu.: 9.297 Median :10.373 Mean :10.100 ... ..- attr(*, dimnames)=List of 2 .. ..$ : chr [1:6] ... .. ..$ : chr [1:19] Cell_3_SOSGVF. Cell_3_SOSq..ms.ms. Cell_3_Airflow..cfm. Cell_3_Float..in.. ... $ T38: 'table' chr [1:6, 1:19] Min. :8.648 1st Qu.:8.920 Median :9.018 Mean :9.027 ... ..- attr(*, dimnames)=List of 2 .. ..$ : chr [1:6] ... .. ..$ : chr [1:19] Cell_3_SOSGVF. Cell_3_SOSq..ms.ms. Cell_3_Airflow..cfm. Cell_3_Float..in.. ... - attr(*, dim)= int 2 - attr(*, dimnames)=List of 1 ..$ dat$LipTest: chr [1:2] T38 - attr(*, call)= language by.data.frame(data = dat[Nidx], INDICES = dat$LipTest, FUN = summary) - attr(*, class)= chr by __ 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
[R] rank() not doing really what I want
Greetings! I have the following vector already in decreasing order: 125, 124, 111, 108, 107, 107, 105, I want to find out the rank, so I do the following: rank(-x, ties.method=min) Then I get the following: 1, 2, 3, 4, 5, 5, 7, but that is not what I want. I want it to give: 1. ,2, 3, 4, 5 ,5, 6, There should be no jumps in the sequence. How would that be possible? Thanks, Henri-Paul -- Henri-Paul Indiogine Curriculum Instruction Texas AM University TutorFind Learning Centre http://www.tutorfind.ca Email: hindiog...@gmail.com Skype: hindiogine __ 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] Exporting each row in the table as new table
Hi -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On Behalf Of kallu Sent: Thursday, October 11, 2012 3:05 PM To: r-help@r-project.org Subject: [R] Exporting each row in the table as new table Dear all, I am new to R and I am familiar with very basic stuff. I am trying to create tables in text format from each row of my table and export these tables with specific attribute in the table. I tried after reading some forums but nothing worked. Can you please help me. ex: dataGT IDState YearGrowth 1 IA 199925 2 IA 200027 3 KS 199935 4 KS 200031 5 KY 199914 6 KY 200018 7 NE 199934 8 NE 200038 I am trying to have each row of the table as new table and need to export that table with name of of the ID. Please help me if possible. Thank you Kalyani Well, be more specific. How do you want the output by formated based on above example. From what you say it seems to me that you want split(dataGT, dataGT$id) but cut me into pieces if I know why. Regards Petr -- View this message in context: http://r.789695.n4.nabble.com/Exporting- each-row-in-the-table-as-new-table-tp4645844.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] rank() not doing really what I want
If they are already in decreasing order, you might be able to work something out like (untested): cumsum(c(1, diff(x) 0)) Cheers, Michael On Fri, Oct 12, 2012 at 8:05 AM, Henri-Paul Indiogine hindiog...@gmail.com wrote: Greetings! I have the following vector already in decreasing order: 125, 124, 111, 108, 107, 107, 105, I want to find out the rank, so I do the following: rank(-x, ties.method=min) Then I get the following: 1, 2, 3, 4, 5, 5, 7, but that is not what I want. I want it to give: 1. ,2, 3, 4, 5 ,5, 6, There should be no jumps in the sequence. How would that be possible? Thanks, Henri-Paul -- Henri-Paul Indiogine Curriculum Instruction Texas AM University TutorFind Learning Centre http://www.tutorfind.ca Email: hindiog...@gmail.com Skype: hindiogine __ 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] Any better way of optimizing time for calculating distances in the mentioned scenario??
Dear All, I'm dealing with a case, where 'manhattan' distance of each of 100 vectors is calculated from 1 other vectors. For achieving this, following 4 scenarios are tested: 1) scenario 1: x-read.table(query.vec) v-read.table(query.vec2) d-matrix(nrow=nrow(v),ncol=nrow(x)) for (i in 1:nrow(v)){ + d[i,]- sapply(1:nrow(x),function(z){dist(rbind(v[i,],x[z,]),method=manhattan)}) + } print(d[1,1:10]) time taken for running the code is : real1m33.088s user1m32.287s sys 0m0.036s 2) scenario2: x-read.table(query.vec) v-read.table(query.vec2) v-as.matrix(v) d-matrix(nrow=nrow(v),ncol=nrow(x)) for (i in 1:nrow(v)){ + tmp_m-matrix(rep(v[i,],nrow(x)),nrow=nrow(x),byrow=T) + d[i,]- rowSums(abs(tmp_m - x)) + } print(d[1,1:10]) time taken for running the code is: real0m0.882s user0m0.854s sys 0m0.025s 3) scenario3: x-read.table(query.vec) v-read.table(query.vec2) v-as.matrix(v) d-matrix(nrow=nrow(v),ncol=nrow(x)) for (i in 1:nrow(v)){ + d[i,]-sapply(1:nrow(x),function(z){dist(rbind(v[i,],x[z,]),method=manhattan)}) + } print(d[1,1:10]) time taken for running the code is: real1m3.817s user1m3.543s sys 0m0.031s 4) scenario4: x-read.table(query.vec) v-read.table(query.vec2) v-as.matrix(v) d-dist(rbind(v,x),method=manhattan) m-as.matrix(d) m2-m[1:nrow(v),(nrow(v)+1):nrow(x)] print(m2[1,1:10]) time taken for running the code: real0m0.445s user0m0.401s sys 0m0.041s Queries: 1) Though scenario 4 is optimum, this scenario failed when matrix 'v' having more no. of rows. An error occurred while converting distance object 'd' to a matrix 'm'. For E.g: m-as.matrix(d) the above command resulted in error: Error: cannot allocate vector of size 922.7 MB. So, what can be done to convert a larger dist object into a matrix or how allocation size can be increased? 2) Here I observed that 'dist()' function calculates the distances across all vectors present in a given matrix or dataframe. Is it not possible to calculate distances of specific vectors from other vectors present in a matrix using 'dist()' function? Which means, suppose if a matrix 'x' having 20 rows, is it not possible using 'dist()' to calculate only distance of 1st row vector from other 19 vectors. 3) Any other ideas to optimize the problem i'm facing with. Regards, Purnachander __ 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] extracting groups from hclust() for a very large matrix
Le jeudi 11 octobre 2012 à 15:50 -0700, Christopher R. Dolanc a écrit : Hello, I'm having trouble figuring out how to see resulting groups (clusters) from my hclust() output. I have a very large matrix of 4371 plots and 29 species, so simply looking at the graph is impossible. There must be a way to 'print' the results to a table that shows which plots were in what group, correct? I've attached the matrix I'm working with (the whole thing since the point is its large size). I can't see it (probably removed by the server). Anyways, you should be able to reproduce the same thing with a small reproducible example: I don't see anything related to a large matrix below, apart maybe the vegemite() error. I've been able to run the following code to get the groups I need: VTM.Dist- vegdist(VTM.Matrix) VTM.HClust- hclust(VTM.Dist, method=ward) plot(VTM.HClust, hang=-1) It takes a while, but it does run. Then, I can extract 8 groups, which I'd like to experiment with, but is about how many I'd like: rect.hclust(VTM.HClust, 8) VTM.8groups- cutree(VTM.HClust, 8) But, instead of listing the plots by name, it only tells me *how many* plots are in the eight groups: table(VTM.8groups) VTM.8groups 12345678 137 173 239 356 709 585 908 1264 Just remove the call to table(). This function is precisely made to tell you how many times each value (here group) is present. If you want the list of plots and their groups, it's here: VTM.8groups The vegemite() function also doesn't work for this reason - I have way too many plots so they number in the thousands, which vegemite doesn't like. vegemite(VTM.Matrix, VTM.HClust) Error in vegemite(VTM.Matrix, VTM.HClust) : Cowardly refusing to use longer than 1 char symbols: Use scale Does anybody know how I can get a simple list of plots in each category? I would think this would be something like a summary command. Perhaps a different clustering method? Thanks, Chris Dolanc __ 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] In vegan package: running adonis (or similar) on a distance matrix
Roey Angel angel at mpi-marburg.mpg.de writes: Hi, Using Vegan package I was wondering if there's a way to use a distance matrix as an input for adonis (or any of the other similar hypothesis testing functions) instead of the usual species by sample table. Working in the field of microbial ecology, what I'm trying to do is to overcome the problem of having to use discrete units such as species or OTUs, which are problematic in microbial ecology (if not outright theoretically false). What I have instead is a phylometric distance matrix between all my samples based on a phylogenetic tree. Dear Roye Angel, According to the documentation, this can be done. See description of the first argument ('formula') in ?adonis. Your distances (dissmilarities) must be in standard R form and inherit from class dist. If they are in some other form, you should change them to dist class. This may succeed with command as.dist(). Cheers, Jari Oksanen __ 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] rank() not doing really what I want
Hi Michael! 2012/10/12 R. Michael Weylandt michael.weyla...@gmail.com: If they are already in decreasing order, you might be able to work something out like (untested): cumsum(c(1, diff(x) 0)) Thanks seems to work. Thanks a bunch! Henri-Paul -- Henri-Paul Indiogine Curriculum Instruction Texas AM University TutorFind Learning Centre http://www.tutorfind.ca Email: hindiog...@gmail.com Skype: hindiogine __ 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] GAM without intercept
Smooth terms are constrained to sum to zero over the covariate values. This is an identifiability constraint designed to avoid confounding with the intercept (particularly important if you have more than one smooth). If you remove the intercept from you model altogether (m2) then the smooth will still sum to zero over the covariate values, which in your case will mean that the smooth is quite a long way from the data. When you include the intercept (m1) then the intercept is effectively shifting the constrained curve up towards the data, and you get a nice fit. So it's not quite true that m2 has nothing to do with the data. The curve you get is as close to the data as a curve constrained to average to zero can get. best, Simon On 10/10/12 23:22, SAEC wrote: Hi everybody, I am trying to fit a GAM model without intercept using library mgcv. However, the result has nothing to do with the observed data. In fact the predicted points are far from the predicted points obtained from the model with intercept. For example: #First I generate some simulated data: library(mgcv) x-seq(0,10,length=100) y-x^2+rnorm(100) #then I fit a gam model with and without intercept m1-gam(y~s(x,k=10,bs='cs')) m2-gam(y~s(x,k=10,bs='cs')-1) #and now I obtain predicted values for the interval 0-1 x1-seq(0,10,0.1) y1-predict(m1,newdata=list(x=x1)) y2-predict(m2,newdata=list(x=x1)) #plotting predicted values plot(x,y,ylim=c(0,100)) lines(x1,y1,lwd=4,col='red') lines(x1,y2,lwd=4,col='blue') In this example you can see that the red line are the predicted points from the model with intercept which fit pretty good to the data, but the blue line (without intercept) is far from the observed points. Probably I missunderstanding some key elements in gam modelling or using incorrect syntaxis. I don't know what the problem is. Any ideas will be helpful. Sergio -- Simon Wood, Mathematical Science, University of Bath BA2 7AY UK +44 (0)1225 386603 http://people.bath.ac.uk/sw283 __ 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] get: problem with environments
Dear Prof. Lumley, Thank You very much for Your reply. I implemented Your idea not to directly call get from sapply, but inside a function, supplied to sapply. In this way the 3-rd parent frame is always the correct one, no matter whether I invoke testfun2() all by itself or inside another function. So my code is finally stable. It is quite tricky that when I call get() directly from sapply(), like this: sapply(X=, FUN=get, envir=parent.frame()), actually envir is an argument not to get, but to sapply, so it is evaluated in the environment of the caller, i.e. in the environment of testfun1, whose parent is the workspace, which of course does not contain the variables in the body of testfun1. In testfun2() sapply() calls get() from within a function and the envir argument to get() is supplied directly to it, i.e. it is evaluated in the environment of get(). Its first parent is the environment of the function calling get(), its second parent is the environment of sapply() and its third parent is the environment of testfun2(), which I need. That is why testfun2() works. I hope I have correctly understood this matter. Please correct me if I am wrong. Nevertheless the code is finally stable and it is thanks to Your suggestion. Best regards, Martin Ivanov Оригинално писмо От: Thomas Lumley Относно: Re: [R] get: problem with environments До: R. Michael Weylandt Изпратено на: Четвъртък, 2012, Октомври 11 01:52:14 EEST On Thu, Oct 11, 2012 at 11:18 AM, R. Michael Weylandt wrote: Thanks Prof Lumley, I'm still not sure how this gets to the call stack of 5 or 6 the OP reported or the difference between GUI amp; Terminal. Any thoughts there? I don't see how the terminal version is getting 5 and 6 rather than 1 and 2, but my testfun2() lets the OP do what he was originally trying to do. The difference between testfun() and print(testfun()) (ie, 1 vs 2, or 5 vs 6) is because of lazy evaluation: in print(testfun()), testfun() is called from inside print() when it needs the value to do method dispatch. I can't reproduce the value of 5, so I can't help much. For anyone wanting to experiment further, it would probably be simpler to use testfun-function() sys.nframe() rather than looking at whether a variable is found or not. I can't see how testfun() typed at the global command prompt can return anything other than 1, but maybe something is getting in between the console and the evaluator. For example: testfun() [1] 1 print(testfun()) [1] 2 capture.output(testfun()) [1] quot;[1] 6quot; I don't see why a pure console program should do this on Linux, though. -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] ks.test not working?
Hello, First of all, you should say which packages you are using. There is a function ks.boot in package Matching and there are functions pgev in several packages. For instance, package evd. Apparently there is nothing wrong with ks.test, you simply are unable to call ks.boot. So, write a ks_boot function with the same arguments as ks.test plus an extra 'nboots' argument. ks_boot - function(x, y, ..., alternative = c(two.sided, less, greater), exact = NULL, nboots = 1000){ alt - match.arg(alternative) n - length(x) D - numeric(nboots) p - numeric(nboots) for(i in seq_len(nboots)){ idx - sample(n, n, replace = TRUE) ks - ks.test(x[idx], y, ..., alternative = alt, exact = exact) D[i] - ks$statistic p[i] - ks$p.value } list(D = mean(D), p.value = mean(p), nboots = nboots) } Hope this helps, Rui Barradas Em 12-10-2012 04:09, louise.wil...@csiro.au escreveu: Hi, I am performing GEV analysis on temperature/precipitation data and want to use the ks.boot function but I am unsure of how to implement it using the pgev distribution. For example: ks.test(data,pgev,shape,location,scale) ks.boot(data,(distribution parameters?),alternative=pgev,nboots=1000) Any advice? Apologies in advance if I have used the wrong email address. Regards, Louise Wilson Louise Wilson Climate Projections Project Officer CSIRO Climate Adaptation Flagship National Resource Management (NRM) Pacific-Australia Climate Change Science and Adaptation Planning Program (PACCSAP) CSIRO Marine and Atmospheric Research Private Bag 1 (107-121 Station St) Aspendale, Victoria 3195 P: +61 3 9239 4619 | F: +61 3 9239 | E: louise.wil...@csiro.aumailto:louise.wil...@csiro.au [[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] Repeating a series of commands
This is pretty confusing writeup, but if you have iterations, then yes, you need a loop or a recursion. A loop is probably easier, take a look at ?for or ?apply for this. there are several derivates of apply for example, say your outputs are what the code below gives you for each file, then first make a vector with the files filevec-c(f1.csv,f2.csv) then you can easily get the results (a$z,b$z) as another vector by using outputs - sapply(filevec,function(x){ contents-read.csv(x); something- ifelse( x$Z==L,sample(1:4,length(x$Z),replace=TRUE), ifelse(x$Z==M,sample(5:8,length(x$Z),replace=TRUE), ifelse(x$Z==U,sample(9:10,length(x$Z),replace=TRUE),))); return(something) }) and if you want to do this several times: m- matrix(ncol=length(filevec),nrow=10) myResult- as.data.frame(m) for(i in 1:10){ outputs - sapply(filevec,function(x){ contents-read.csv(x); something- ifelse( contents$Z==L,sample(1:4,length(contents$Z),replace=TRUE), ifelse(contents$Z==M,sample(5:8,length(contents$Z),replace=TRUE), ifelse(contents$Z==U,sample(9:10,length(contents$Z),replace=TRUE),))); return(something) }) someStructure[i,]-outputs } If you don't know the number of iterations or outputs beforehand, i'd have a look at while and use lists. Hope this helps. On 11.10.2012, at 20:09, KoopaTrooper wrote: I'm trying to figure out how to repeat a series of commands in R and have the outputs added to a dataframe after each iteration. My code starts this way... a-read.csv(File1.csv) b-read.csv(File2.csv) a$Z-ifelse(a$Z==L,sample(1:4,length(a$Z),replace=TRUE),ifelse(a$Z==M,sample(5:8,length(a$Z),replace=TRUE),ifelse(a$Z==U,sample(9:10,length(a$Z),replace=TRUE),))) a$Z-as.numeric(a$Z) b$Z-ifelse(b$Z==L,sample(1:4,length(b$Z),replace=TRUE),ifelse(b$Z==M,sample(5:8,length(b$Z),replace=TRUE),ifelse(b$Z==U,sample(9:10,length(b$Z),replace=TRUE),))) b$Z-as.numeric(b$Z) This is basically just starting off with a new and partially random data set every time that then goes through a bunch of other commands (not shown) and ends with the following outputs saved. Output1, Output2, Output3, Output4 where each of these is just a single number. My questions is: 1. How do I repeat the entire series of commands x number of times and save each of the outputs into a structure like this: Output1 Output2 Output3 Output4 Iteration 1 Iteration 2 Iteration 3 etc. Not even sure where to start. Are loops the answer? Thanks, -- View this message in context: http://r.789695.n4.nabble.com/Repeating-a-series-of-commands-tp4645881.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 file(file, rt) : cannot open the connection
I get this error : Error in file(file, rt) : cannot open the connection ... saspath=\C:/Program Files/SAS/SASFoundation/9.2, I don't know the package but your saspath only contains one quote mark, so you have given it C:/Program Files/SAS/SASFoundation/9.2 to open. Would it not need a closing quote or (noting that it's a simple enough path, no opening quote? 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] characters, mathematical expressions and computed values
[mailto:r-help-boun...@r-project.org] On Behalf Of William Dunlap Subject: Re: [R] characters, mathematical expressions and computed values I think that bquote, with its .() operator, suffices for [almost?] any single title; ... E.g., hist(new, main=bquote(Heart Attack ( * bar(X)==.(mean(new)) * ))) In this instance, using hist(new, main=bquote( Heart Attack * (bar(X) ==.( mean(new) )) ) ) improves the parentheses slightly, as it uses plotmath parentheses instead of forcing text parentheses. Otherwise I agree completely; bquote is a neat way of doing the job. S Ellison *** 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] Any better way of optimizing time for calculating distances in the mentioned scenario??
On 12 Oct 2012, at 09:46, Purna chander wrote: 4) scenario4: x-read.table(query.vec) v-read.table(query.vec2) v-as.matrix(v) d-dist(rbind(v,x),method=manhattan) m-as.matrix(d) m2-m[1:nrow(v),(nrow(v)+1):nrow(x)] print(m2[1,1:10]) time taken for running the code: real0m0.445s user0m0.401s sys 0m0.041s 1) Though scenario 4 is optimum, this scenario failed when matrix 'v' having more no. of rows. An error occurred while converting distance object 'd' to a matrix 'm'. For E.g: m-as.matrix(d) the above command resulted in error: Error: cannot allocate vector of size 922.7 MB. That's because you're calculating a full distance matrix with (1+100) * (1+100) points and then extract the much smaller number of distance values (1 * 100) that you actually need. I have a use case with similar requirements, so ... 3) Any other ideas to optimize the problem i'm facing with. ... my experimental wordspace package includes a function dist.matrix() for calculating such cross-distance matrices. The function is written in C code and doesn't handle NA's and NaN's properly, but it's considerably faster than the current implementation of dist(). I haven't uploaded the package to CRAN yet, but you should be able to install with install.packages(wordspace, repos=http://R-Forge.R-project.org;) Best, Stefan PS: Glad to see that daily builds on R-Forge work again -- that's an extremely useful feature to get beta testers for experimental package versions. :-) __ 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 on survival
It is easy to get a cumulative hazard curve. First, decide what values of age, a, and b you want curves for tdata- data.frame(age=55, a=2, b=6) Get the curves, there will be one for each strata in the output sfit- survfit(coxPhMod, newdata= tdata) Plot them plot(sfit, fun='cumhaz', col=1:4, xlab= etc etc) Hazard functions are something else again, estimating these rigorously is akin to density estimation. A quick and dirty method is to use smooth.spline. temp- sfit[1] #grab the first curve tfit- smooth.spline(temp$time, -log(temp$surv), df= 5) #smooth the cum haz plot(predict(tfit, deriv=1)) That value of df=5 is made up -- you need to decide for yourself how much smoothing to do. I make no claims that this is statistically well grounded, it's just a good way to get a quick idea. PS; There is no such thing as THE baseline hazard function; predictions are always for some particular value of the covariates. In a book it is sometimes useful to pick a particular set of x values as a default in order to simplify notation, often x=0, and label that as a baseline. But in actual computation all zeros is usually crazy (age=0, weight=0, blood pressure=0, etc). Terry Therneau Hi, I'm going crazy trying to plot a quite simple graph. i need to plot estimated hazard rate from a cox model. supposing the model i like this: coxPhMod=coxph(Surv(TIME, EV) ~ AGE+A+B+strata(C) data=data) with 4 level for C. how can i obtain a graph with 4 estimated (better smoothed) hazard curve (base-line hazard + 3 proportional) to highlight the effect of C. thanks!! laudan __ 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] Autofilling a large matrix in R
I wish to create a matrix of all possible percentages with two decimal place percision. I then want each row to sum to 100%. I started with the code below with the intent to then subset the data based on the row sum. This works great for 2 or 3 columns, but if I try 4 or more columns the number of rows become to large. I would like to find a way to break it down into some kind of for loop, so that I can remove the rows that don't sum to 100% inside the for loop rather than outside it. My first thought was to take list from 1:10, 11:20, etc. but that does not get all of the points. g-as.matrix(expand.grid(rep(list(1:100), times=3))) Any thoughts how to split this into pieces? -- View this message in context: http://r.789695.n4.nabble.com/Autofilling-a-large-matrix-in-R-tp4645991.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] struggling with R2wd or SWord? Try rtf!
I recently gave a talk to the Ottawa PC Users Group about Sweave, knitR and odfWeave. The last is sometimes cranky, but I've found I can use it for word-processing documents, and if these are saved in odt format (open office), then odfWeave can process them to finalized odt form. Recognize this isn't exactly the answer you sought, but possibly it is helpful. If there is interest, I can send the slides for the talk and some of the smaller examples (a couple are book length from knitR). JN On 10/12/2012 06:00 AM, r-help-requ...@r-project.org wrote: Message: 57 Date: Thu, 11 Oct 2012 14:26:15 -0500 From: Jean V Adams jvad...@usgs.gov To: r-help@r-project.org Subject: [R] struggling with R2wd or SWord? Try rtf! Message-ID: of44f33ef2.95339a09-on86257a94.00697515-86257a94.006ac...@usgs.gov Content-Type: text/plain I have been looking for a way to write R-generated reports to Microsoft Word documents. In the past, I used the package R2wd, but for some reason I haven't been able to get it to work on my current set up. R version 2.15.0 (64-bit) Windows 7 Enterprise - Service Pack 1 Microsoft Office Professional Plus 2010 - Word version 14.0.6123.5001 (32-bit) I gave the package SWord a try, too. Also, no luck. But, I just recently ran across the package rtf, and it serves my needs quite well. Since some of you may find yourself in a similar situation, I thought I'd spread the word (ha!) about rtf. Below is some introductory code based on examples in http://cran.r-project.org/web/packages/rtf/vignettes/rtf.pdf Give it a try. You may like it! Jean `·.,, (((º `·.,, (((º `·.,, (((º Jean V. Adams Statistician U.S. Geological Survey Great Lakes Science Center 223 East Steinfest Road Antigo, WI 54409 USA http://www.glsc.usgs.gov library(rtf) rtf - RTF(rtf_vignette.doc, width=8.5, height=11, font.size=10, omi=c(1, 1, 1, 1)) addHeader(rtf, title=This text was added with the addHeader() function., subtitle=So was this.) addParagraph(rtf, This text was added with the addParagraph() function. It is a new self-contained paragraph. When Alpha; is greater than beta;, then gamma; is equal to zero.\n) startParagraph(rtf) addText(rtf, This text was added with the startParagraph() and addText() functions. You can insert ) addText(rtf, styled , bold=TRUE, italic=TRUE) addText(rtf, text this way. But, you must end the paragraph manually with the endParagraph() function.\n) endParagraph(rtf) increaseIndent(rtf) addParagraph(rtf, paste(rep(You can indent text with the increaseIndent() function., 4), collapse= )) addNewLine(rtf) decreaseIndent(rtf) addParagraph(rtf, paste(rep(And remove the indent with the decreaseIndent() function., 4), collapse= )) addNewLine(rtf) addNewLine(rtf) addParagraph(rtf, Table 1. Table of the iris data using the addTable() function.\n) tab - table(iris$Species, floor(iris$Sepal.Length)) names(dimnames(tab)) - c(Species, Sepal Length) addTable(rtf, tab, font.size=10, row.names=TRUE, NA.string=-, col.widths=c(1, 0.5, 0.5, 0.5, 0.5) ) newPlot - function() { par(pty=s, cex=0.7) plot(iris[, 1], iris[, 2]) abline(h=2.5, v=6.0, lty=2) } addPageBreak(rtf) addPlot(rtf, plot.fun=newPlot, width=5, height=5, res=300) addNewLine(rtf) addParagraph(rtf, Figure 1. Plot of the iris data using the addPlot() function.\n) addNewLine(rtf) addNewLine(rtf) addSessionInfo(rtf) done(rtf) [[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] Autofilling a large matrix in R
If you are after all the possible percentages with two decimal places, why don't you use this: seq(from=0, to=100, by=.01)/100 I'm not really sure what you are trying to do in terms of rows and columns, however. Can you be a bit more specific on what each row/column is? Are you trying to group the numbers so that all the entries in a row add up to 100% and then, once it does, split the following entries onto the next row until they add up to 100%, etc.? Thanks. From: wwreith reith_will...@bah.com To: r-help@r-project.org Sent: Friday, October 12, 2012 10:30 AM Subject: [R] Autofilling a large matrix in R I wish to create a matrix of all possible percentages with two decimal place percision. I then want each row to sum to 100%. I started with the code below with the intent to then subset the data based on the row sum. This works great for 2 or 3 columns, but if I try 4 or more columns the number of rows become to large. I would like to find a way to break it down into some kind of for loop, so that I can remove the rows that don't sum to 100% inside the for loop rather than outside it. My first thought was to take list from 1:10, 11:20, etc. but that does not get all of the points. g-as.matrix(expand.grid(rep(list(1:100), times=3))) Any thoughts how to split this into pieces? -- View this message in context: http://r.789695.n4.nabble.com/Autofilling-a-large-matrix-in-R-tp4645991.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. [[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] Autofilling a large matrix in R
To avoid FAQ 7.31, you probably should use: seq(0, 1) / 1 On Fri, Oct 12, 2012 at 11:12 AM, Mark Lamias mlam...@yahoo.com wrote: If you are after all the possible percentages with two decimal places, why don't you use this: seq(from=0, to=100, by=.01)/100 I'm not really sure what you are trying to do in terms of rows and columns, however. Can you be a bit more specific on what each row/column is? Are you trying to group the numbers so that all the entries in a row add up to 100% and then, once it does, split the following entries onto the next row until they add up to 100%, etc.? Thanks. From: wwreith reith_will...@bah.com To: r-help@r-project.org Sent: Friday, October 12, 2012 10:30 AM Subject: [R] Autofilling a large matrix in R I wish to create a matrix of all possible percentages with two decimal place percision. I then want each row to sum to 100%. I started with the code below with the intent to then subset the data based on the row sum. This works great for 2 or 3 columns, but if I try 4 or more columns the number of rows become to large. I would like to find a way to break it down into some kind of for loop, so that I can remove the rows that don't sum to 100% inside the for loop rather than outside it. My first thought was to take list from 1:10, 11:20, etc. but that does not get all of the points. g-as.matrix(expand.grid(rep(list(1:100), times=3))) Any thoughts how to split this into pieces? -- View this message in context: http://r.789695.n4.nabble.com/Autofilling-a-large-matrix-in-R-tp4645991.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. [[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] struggling with R2wd or SWord? Try rtf!
Why does R2wd not work? I already got it working on a 64-bit PC, but I think you need a different statconn if I recall correctly. If you already have some scripts with R2wd, it's maybe easier to invest some time to get it working than switching to rtf. Anyway thanks for the tip, if I need it, I will digg into rtf. Bart -- View this message in context: http://r.789695.n4.nabble.com/struggling-with-R2wd-or-SWord-Try-rtf-tp4645899p4645978.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] problem in downloading RMySQL pkg
when i am installing Rmysql packages i get error like Warning in install.packages : package ‘RMySQL’ is not available (for R version 2.15.0) which is earliest version should i used ?how should i know the specific version -- View this message in context: http://r.789695.n4.nabble.com/problem-in-downloading-RMySQL-pkg-tp4645967.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 handle Chinese character in R plot?
But i need to read my data from XML. barplot cd name表/name value13/value1 value22.9/value2 /cd cd name笔/name value13.3/value1 value23/value2 /cd cd name铅笔/name value12.3/value1 value22.9/value2 /cd cd name书/name value13.4/value1 value22.6/value2 /cd cd name玻璃/name value13.1/value1 value22.4/value2 /cd /barplot Regards -- View this message in context: http://r.789695.n4.nabble.com/How-to-handle-Chinese-character-in-R-plot-tp4645950p4645962.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] installing RMySQL error due to cygwin
when i am installing package manually (using below command) i get error about cygwin as, install.packages(C:\\Users\\trendwise\\Downloads\\RMySQL_0.9-3.tar.gz,lib=getOption(lib), repos = NULL, type=source) error:-- Installing package(s) into ‘C:/Users/trendwise/Documents/R/win-library/2.15’ (as ‘lib’ is unspecified) * installing *source* package 'RMySQL' ... ** package 'RMySQL' successfully unpacked and MD5 sums checked tty option detected in CYGWIN environment variable. CYGWIN=tty is no longer supported. Please remove it from your CYGWIN environment variable and use a terminal emulator like mintty, xterm, or rxvt. checking for $MYSQL_HOME... not found... searching registry... Error in readRegistry(SOFTWARE\\MySQL AB, hive = HLM, maxdepth = 2) : Registry key 'SOFTWARE\MySQL AB' not found Execution halted ERROR: configuration failed for package 'RMySQL' * removing 'C:/Users/trendwise/Documents/R/win-library/2.15/RMySQL' Warning in install.packages : running command 'C:/PROGRA~1/R/R-215~1.0/bin/x64/R CMD INSTALL -l C:/Users/trendwise/Documents/R/win-library/2.15 C:/Users/trendwise/Downloads/RMySQL_0.9-3.tar.gz' had status 1 Warning in install.packages : installation of package ‘C:/Users/trendwise/Downloads/RMySQL_0.9-3.tar.gz’ had non-zero exit status i dont want to uninstall cygwin -- View this message in context: http://r.789695.n4.nabble.com/installing-RMySQL-error-due-to-cygwin-tp4645968.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] ifelse reformulation
Hi, i'm trying to simplify some R code but i got stucked in this: test-data.frame(cbind(id,x1,x2,x3,x4,x5,x6,x7)) test test id x1 x2 x3 x4 x5 x6 x7 1 1 36 26 21 32 31 27 31 2 2 45 21 46 50 22 36 29 3 3 49 47 35 44 33 31 46 4 4 42 32 38 28 39 45 32 5 5 29 42 39 48 25 35 34 6 6 39 31 30 37 46 43 44 7 7 41 40 25 23 42 40 24 8 8 27 29 47 34 26 38 28 9 9 25 35 29 36 43 34 23 10 10 24 44 37 26 27 46 22 11 11 38 50 32 49 37 24 40 12 12 20 34 48 25 30 41 36 13 13 26 46 20 40 29 20 43 14 14 33 37 49 31 47 30 30 15 15 43 39 27 35 48 47 27 count40-ifelse(test$x1==40|test$x2==40|test$x3==40|test$x4==40|test$x5==40|test$x6==40|test$x7==40,0,1) count40 I'm trying to remake that ifelse. If any variable from x1 to x7 equals to 40 -- 0, else -- 1 I was trying to do something like: count40aux-ifelse(test[,2:8]==40,0,1) count40aux It doesn't work as i expected... Can anyone help me please? Regards, Bruno -- View this message in context: http://r.789695.n4.nabble.com/ifelse-reformulation-tp4645981.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] party for prediction [REPOST]
Apologies for re-posting, my original message seems to have been overlooked by the moderators. -- Forwarded message -- From: Ed icelus...@gmail.com Date: 11 October 2012 19:03 Subject: party for prediction To: R-help@r-project.org Hi there I'm experiencing some problems using the party package (specifically mob) for prediction. I have a real scalar y I want to predict from a real valued vector x and an integral vector z. mob seemed the ideal choice from the documentation. The first problem I had was at some nodes in a partitioning tree, the components of x may be extremely highly correlated or effectively constant (that is x are not independent for all choices of components of z). When the resulting fit is fed into predict() the result is NA - this is not the same behaviour as models returned by say lm which ignore missing coefficients. I have fixed this by defining my own statsModel (myLinearModel - imaginative) which also ignores such coefficients when predicting. The second problem I have is that I get Cholesky not positive definite errors at some nodes. I guess this is because of numerical error and degeneracy in the covariance matrix? Any thoughts on how to avoid having this happen would be welcome; it is ignorable though for now. The third and really big problem I have is that when I apply mob to large datasets (say hundreds of thousands of elements) I get a logical subscript too long error inside mob_fit_fluctests. It's caught in a try(), and mob just gives up and treats the node as terminal. This is really hurting me though; with 1% of my data I can get a good fit and a worthwhile tree, but with the whole dataset I get a very stunted tree with a pretty useless prediction ability. I guess what I really want to know is: (a) has anyone else had this problem, and if so how did they overcome it? (b) is there any way to get a line or stack trace out of a try() without source modification? (c) failing all of that, does anyone know of an alternative to mob that does the same thing; for better or worse I'm now committed to recursive partitioning over linear models, as per mob? (d) failing all of this, does anyone have a link to a way to rebuild, or locally modify, an R package (preferably windows, but anything would do)? Sorry for the length of this post. If I should RTFM, please point me at any relevant manual by all means. I've spent a few days on this as you can maybe tell, but I'm far from being an R expert. Thanks for any help you can give. Best wishes, Ed __ 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] Loss of dimensions in subsetting arrays
Hi all, I've been wondering for a long time why R drops the dimensions of an array/matrix when you try to take a subset of one column. I mean this: dim(A) [1] 2 5 2 B=A[1,,] dim(B) 5 2 # so now dim(B)[3] doesn't work C=B[2,] dim(C) NULL # so now nrow(C) doesn't work Typically, you can get rid of this by writing as.matrix, as.array(...) but that generates extra lines of code. This is really annoying. Does anybody know how to turn this behaviour off? best, Markku Karhunen Uni. Helsinki __ 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] Creating a correlation matrix with significance levels
Hi there, I tried this code from homepage: http://myowelt.blogspot.de/2008/04/beautiful-correlation-tables-in-r.html http://myowelt.blogspot.de/2008/04/beautiful-correlation-tables-in-r.html corstarsl - function(x){ require(Hmisc) x - as.matrix(x) R - rcorr(x)$r p - rcorr(x)$P ## define notions for significance levels; spacing is important. mystars - ifelse(p .001, ***, ifelse(p .01, ** , ifelse(p .05, * , ))) ## trunctuate the matrix that holds the correlations to two decimal R - format(round(cbind(rep(-1.11, ncol(x)), R), 2))[,-1] ## build a new matrix that includes the correlations with their apropriate stars Rnew - matrix(paste(R, mystars, sep=), ncol=ncol(x)) diag(Rnew) - paste(diag(R), , sep=) rownames(Rnew) - colnames(x) colnames(Rnew) - paste(colnames(x), , sep=) ## remove upper triangle Rnew - as.matrix(Rnew) Rnew[upper.tri(Rnew, diag = TRUE)] - Rnew - as.data.frame(Rnew) ## remove last column and return the matrix (which is now a data frame) Rnew - cbind(Rnew[1:length(Rnew)-1]) return(Rnew) } Output_cor - xtable(corstarsl(swiss[,1:4])) setwd(paste(path,Output/Correlation/,sep=)) print.xtable(Output_cor, type=html, file=correlation.html) In this example it shows the output of package example Hmisc. I want to use this code for my own matrix called: Corr_Matrix - cbind(MA_data_raw$1, MA_data_raw$2, MA_data_raw$3, MA_data_raw$4, MA_data_raw$5, MA_data_raw$6, MA_data_raw$7, MA_data_raw$8, I(MA_data_raw$21/MA_data_raw$20), MA_data_raw$9) How can I do this? Thanks! I appreciate all helpful answers! ;-) -- View this message in context: http://r.789695.n4.nabble.com/Creating-a-correlation-matrix-with-significance-levels-tp4645984.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] How to get rid of page 1 and 4 i.e Only dots pages while generating the graphs?
Suppose I have Orange1 data like this. TIME1 RESPONSE RESPSTAT RESPUT REFID ARM SUBARM 0 299.5 Mean 8-item scale 68 0 0 0 287 Median 8-item scale 68 0 0 0 303.9 Mean 8-item scale 68 1 0 0 286 Median 8-item scale 68 1 0 0 295 Mean 8-item scale 85 0 0 12 254 Mean 8-item scale 85 0 0 0 287 Mean 8-item scale 85 1 0 12 216 Mean 8-item scale 85 1 0 0 306 Mean 8-item scale 85 2 0 12 218 Mean 8-item scale 85 2 0 0 273 Mean 8-item scale 18 0 0 1 258.003 Mean 8-item scale 18 0 0 2 261.392 Mean 8-item scale 18 0 0 4 250.812 Mean 8-item scale 18 0 0 0 258 Mean 8-item scale 18 1 0 1 226.153 Mean 8-item scale 18 1 0 2 213.41 Mean 8-item scale 18 1 0 4 206.781 Mean 8-item scale 18 1 0 While I am generating graphs for the above data I am getting four graphs in four pages in a pdf with the following programme. Page1: Only dots (No lines) Page2: Lines observed Page3: Lines observed Page4: Only dots (No lines) I want to get rid of page 1 and 4 i.e Only dots pages while generating the graphs. So that the pdf should contain only two pages(Page 2 3) Can anyone help? unique(Orange1$RESPSTAT) - change pdf(CDAI Response.pdf) for (j in 1:length(change)){ ((Orange1$RESPUT == 8-item scale)(Orange1$RESPSTAT == change[j])) - b FD - Orange1[b, ] unique(FD$REFID) - refid for (i in refid) { Orange2 - FD[i == FD$REFID, ] Orange2$ARM- factor(Orange2$ARM) unique(Orange2$RESPSTAT) - x y - paste(REFID=, i,; , RESPSTAT=, x, sep=) print(qplot(TIME1, RESPONSE, data=Orange2, geom= c(line, point), colour=ARM, main=y)) } } dev.off() 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:+91-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.
Re: [R] Question on survival
lau pel wrote Hi, I'm going crazy trying to plot a quite simple graph. i need to plot estimated hazard rate from a cox model. supposing the model i like this: coxPhMod=coxph(Surv(TIME, EV) ~ AGE+A+B+strata(C) data=data) with 4 level for C. how can i obtain a graph with 4 estimated (better smoothed) hazard curve (base-line hazard + 3 proportional) to highlight the effect of C. thanks!! laudan (1) The curves won't be proportional if you stratify on C. The curves are proportional for AGE, A, and B in your model. (2) If you want to deal with an individual stratum, you can extract them individually from survfit dataset - data.frame(Time = rexp(100, 1), A = rnorm(100), B = rnorm(100), C = factor(rep(letters[1:4],25))) mod - coxph(Surv(Time) ~ A + B + strata(C), data=dataset) # first stratum fit survfit(mod, newdata=data.frame(A=rep(0,4), B=rep(0,4), C=factor(letters[1:4])))[1] __ 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. -- View this message in context: http://r.789695.n4.nabble.com/Question-on-survival-tp4645926p4645986.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] Problem with which function
Hej, i need the which() funktion to find the positions of an entry in a matrix. the entries i'm looking for are : seq(begin,end,0.01) and there are no empty spaces i'm searching in the right range. so i was looking for the results R can find and i recieved this answer. for (l in 1:length(qr)){print(c(l,nstu[l,1],nsto[l,1],nsto[l,1]-nstu[l,1],(nsto[l,1]-nstu[l,1])*100,which(sp1[,1]==nstu[l,1]),(nsto[l,1]-nstu[l,1])*100+which(sp1[,1]==nstu[l,1]),which(r[,1]==nstu[l,1]),(nsto[l,1]-nstu[l,1])*100+which(r[,1]==nstu[l,1])))} [1] 1 0 0 0 0 [1] 2 0 0 0 0 [1] 3 0 0 0 0 [1]4.00 87.34 87.970.63 63.00 2491.00 2554.00 2491.00 2554.00 [1]5.00 86.73 88.461.73 173.00 2430.00 2603.00 [1]6.00 86.22 88.772.55 255.00 2379.00 2634.00 [1]7.00 85.77 89.013.24 324.00 2334.00 2658.00 [1]8.00 85.36 89.223.86 386.00 2293.00 2679.00 [1]9.0 85.0 89.44.4 440.0 2257.0 2697.0 [1] 10.00 84.68 89.574.89 489.00 2225.00 2714.00 2225.00 2714.00 [1] 11.00 84.38 89.735.35 535.00 2195.00 2730.00 [1] 12.00 84.11 89.885.77 577.00 2168.00 2745.00 [1] 13.00 83.86 90.026.16 616.00 2143.00 2759.00 [1] 14.00 83.64 90.156.51 651.00 2121.00 2772.00 [1] 15.00 83.43 90.286.85 685.00 2100.00 2785.00 2100.00 2785.00 [1] 16.00 83.24 90.407.16 716.00 2081.00 2797.00 [1] 17.00 83.07 90.52 7.45 745.00 [1] 18.00 82.91 90.637.72 772.00 2048.00 2820.00 [1] 19.00 82.76 90.757.99 799.00 2033.00 2832.00 [1] 20.00 82.62 90.868.24 824.00 2019.00 2843.00 2019.00 2843.00 [1] 21.00 82.49 90.978.48 848.00 2006.00 2854.00 [1] 22.00 82.37 91.088.71 871.00 1994.00 2865.00 1994.00 2865.00 [1] 23.00 82.26 91.198.93 893.00 1983.00 2876.00 [1] 24.00 82.16 91.319.15 915.00 1973.00 2888.00 [1] 25.00 82.07 91.429.35 935.00 1964.00 2899.00 [1] 26.00 81.98 91.539.55 955.00 1955.00 2910.00 [1] 27.00 81.90 91.649.74 974.00 1947.00 2921.00 1947.00 2921.00 [1] 28.00 81.83 91.759.92 992.00 1940.00 2932.00 [1] 29.00 81.76 91.87 10.11 1011.00 1933.00 2944.00 [1] 30.00 81.69 91.98 10.29 1029.00 1926.00 2955.00 [1] 31.00 81.63 92.09 10.46 1046.00 1920.00 2966.00 [1] 32.00 81.57 92.20 10.63 1063.00 [1] 33.00 81.50 92.31 10.81 1081.00 1907.00 2988.00 [1] 34.00 81.44 92.43 10.99 1099.00 1901.00 3000.00 [1] 35.00 81.38 92.54 11.16 1116.00 1895.00 3011.00 [1] 36.00 81.31 92.65 11.34 1134.00 1888.00 3022.00 [1] 37.00 81.25 92.76 11.51 1151.00 1882.00 3033.00 [1] 38.00 81.18 92.87 11.69 1169.00 1875.00 3044.00 1875.00 3044.00 [1] 39.00 81.12 92.98 11.86 1186.00 1869.00 3055.00 1869.00 3055.00 [1] 40.00 81.05 93.10 12.05 1205.00 1862.00 3067.00 [1] 41.00 80.99 93.21 12.22 1222.00 1856.00 3078.00 [1] 42.00 80.92 93.32 12.40 1240.00 1849.00 3089.00 [1] 43.00 80.86 93.43 12.57 1257.00 1843.00 3100.00 [1] 44.00 80.79 93.54 12.75 1275.00 [1] 45.00 80.73 93.66 12.93 1293.00 1830.00 3123.00 [1] 46.00 80.66 93.77 13.11 1311.00 1823.00 3134.00 [1] 47.00 80.60 93.88 13.28 1328.00 1817.00 3145.00 [1] 48.00 80.53 93.99 13.46 1346.00 1810.00 3156.00 [1] 49.00 80.47 94.10 13.63 1363.00 1804.00 3167.00 [1] 50.00 80.40 94.22 13.82 1382.00 1797.00 3179.00 1797.00 3179.00 [1] 51.00 80.34 94.33 13.99 1399.00 1791.00 3190.00 1791.00 3190.00 [1] 52.00 80.27 94.44 14.17 1417.00 1784.00 3201.00 [1] 53.00 80.20 94.55 14.35 1435.00 1777.00 3212.00 [1] 54.00 80.14 94.66 14.52 1452.00 1771.00 3223.00 [1] 55.00 80.07 94.77 14.70 1470.00 1764.00 3234.00 [1] 56.00 80.01 94.89 14.88 1488.00 1758.00 3246.00 [1] 57.00 79.94 95.00 15.06 1506.00 1751.00 3257.00 [1] 58.00 79.87 95.11 15.24 1524.00 1744.00 3268.00 1744.00 3268.00 [1] 59.00 79.81 95.22 15.41 1541.00 1738.00 3279.00 [1] 60.00 79.74 95.32 15.58 1558.00 1731.00 3289.00 [1] 61.00 79.67 95.43 15.76 1576.00 1724.00 3300.00 [1] 62.00 79.61 95.54 15.93 1593.00 1718.00 3311.00 [1] 63.00 79.54 95.65 16.11 1611.00 [1] 64.00 79.47 95.76 16.29 1629.00 1704.00 .00 [1] 65.00 79.41 95.87 16.46 1646.00 1698.00 3344.00 [1] 66.00 79.34 95.97 16.63 1663.00 1691.00 3354.00 1691.00 3354.00 [1] 67.00 79.27 96.08 16.81 1681.00 1684.00 3365.00 [1] 68.00 79.21 96.19 16.98 1698.00 1678.00 3376.00 1678.00 3376.00 [1] 69.00 79.14 96.30 17.16 1716.00 1671.00 3387.00 [1] 70.00 79.07 96.40 17.33 1733.00 1664.00 3397.00 [1] 71.00 79.01 96.51 17.50 1750.00 1658.00 3408.00 as it is obvious there are a lot of numbers for r, where R find nothing and some in sp1 where r find nothing. and here some more informations to my curiosity: nstu[10,1] [1] 84.68 r[2225,1] [1] 84.68 is(r) [1]
Re: [R] reading in a (very simple) list from a file
Hi again! Just in case someone ends up googling this for the same thing I did, here is a modification to get around a little problem: dat1-data.frame(keys=paste(key,5:1,sep=),value=1:5) splitlist - split(dat1,dat1$keys) list3-sapply(splitlist,`[`,2) names(list3)-names(splitlist) list3$key2 [1] 4 Because the list after split is stored in alphabetical order by name, it reorders things, so you need to use that order when you name it. Thanks again, Anne -- View this message in context: http://r.789695.n4.nabble.com/reading-in-a-very-simple-list-from-a-file-tp4645741p4645985.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] Autofilling a large matrix in R
Hello, Something like this? g[rowSums(g) == 100, ] Hope this helps, Rui Barradas Em 12-10-2012 15:30, wwreith escreveu: I wish to create a matrix of all possible percentages with two decimal place percision. I then want each row to sum to 100%. I started with the code below with the intent to then subset the data based on the row sum. This works great for 2 or 3 columns, but if I try 4 or more columns the number of rows become to large. I would like to find a way to break it down into some kind of for loop, so that I can remove the rows that don't sum to 100% inside the for loop rather than outside it. My first thought was to take list from 1:10, 11:20, etc. but that does not get all of the points. g-as.matrix(expand.grid(rep(list(1:100), times=3))) Any thoughts how to split this into pieces? -- View this message in context: http://r.789695.n4.nabble.com/Autofilling-a-large-matrix-in-R-tp4645991.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] average duplicated rows?
Dear useRs, I have a slightly complicated data structure and am stuck trying to extract what I need. I'm pasting an example of this data below. In some cases, there are duplicates in the gene_id column because there are two different sample 1 values for a given sample 2 value. Where these duplicates exist, I need to average the corresponding FL_EARLY values and retain the FL_LATE value and replace those two rows with a row containing the FL_EARLY average so that I no longer have any gene_id duplicates. Seems like this is a job for some version of the apply function, but searching and puzzling over this has not gotten me anywhere. Any help will be much appreciated! Example data: gene_id sample_1 sample_2 FL_EARLY FL_LATE 763938 Eucgr.A00054 fl_S1E fl_S1L 13.170800 22.2605 763979 Eucgr.A00101 fl_S1E fl_S1L 0.367960 14.1202 1273243 Eucgr.A00101fl_S2 fl_S1L 0.356625 14.1202 764169 Eucgr.A00350 fl_S1E fl_S1L 7.381070 43.9275 1273433 Eucgr.A00350fl_S2 fl_S1L 10.674500 43.9275 1273669 Eucgr.A00650fl_S2 fl_S1L 33.669100 50.0169 764480 Eucgr.A00744 fl_S1E fl_S1L 132.429000 747.2770 1273744 Eucgr.A00744fl_S2 fl_S1L 142.659000 747.2770 764595 Eucgr.A00890 fl_S1E fl_S1L 2.937760 14.9647 764683 Eucgr.A00990 fl_S1E fl_S1L 8.681250 48.5492 1273947 Eucgr.A00990fl_S2 fl_S1L 10.553300 48.5492 764710 Eucgr.A01020 fl_S1E fl_S1L 0.00 57.9273 1273974 Eucgr.A01020fl_S2 fl_S1L 0.00 57.9273 764756 Eucgr.A01073 fl_S1E fl_S1L 8.504710 101.1870 1274020 Eucgr.A01073fl_S2 fl_S1L 5.400010 101.1870 764773 Eucgr.A01091 fl_S1E fl_S1L 3.448910 15.7756 764826 Eucgr.A01152 fl_S1E fl_S1L 69.565700 198.2320 764831 Eucgr.A01158 fl_S1E fl_S1L 7.265640 30.9565 764845 Eucgr.A01172 fl_S1E fl_S1L 3.248020 16.9127 764927 Eucgr.A01269 fl_S1E fl_S1L 18.710200 76.6918 --Kelly V. [[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] ifelse reformulation
That was exacly what i was looking for! Thanks a lot! Cheers! -- View this message in context: http://r.789695.n4.nabble.com/ifelse-reformulation-tp4645981p4645990.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] Loss of dimensions in subsetting arrays
On Oct 12, 2012, at 4:52 AM, Markku Karhunen markku.karhu...@helsinki.fi wrote: Hi all, I've been wondering for a long time why R drops the dimensions of an array/matrix when you try to take a subset of one column. I mean this: dim(A) [1] 2 5 2 B=A[1,,] dim(B) 5 2 # so now dim(B)[3] doesn't work C=B[2,] dim(C) NULL # so now nrow(C) doesn't work Typically, you can get rid of this by writing as.matrix, as.array(...) but that generates extra lines of code. This is really annoying. Does anybody know how to turn this behaviour off? best, Markku Karhunen Uni. Helsinki You can save yourself a lot of time if you visit the R FAQ as your first action item when such questions come up. In this case: http://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-do-my-matrices-lose-dimensions_003f Regards, Marc Schwartz __ 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] Loss of dimensions in subsetting arrays
On 12-10-2012, at 11:52, Markku Karhunen markku.karhu...@helsinki.fi wrote: Hi all, I've been wondering for a long time why R drops the dimensions of an array/matrix when you try to take a subset of one column. I mean this: dim(A) [1] 2 5 2 B=A[1,,] Use B - A[1,,,drop=FALSE] Also read the help for [: ?[ Berend dim(B) 5 2 # so now dim(B)[3] doesn't work C=B[2,] dim(C) NULL # so now nrow(C) doesn't work Typically, you can get rid of this by writing as.matrix, as.array(...) but that generates extra lines of code. This is really annoying. Does anybody know how to turn this behaviour off? best, Markku Karhunen Uni. Helsinki __ 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] party for prediction [REPOST]
On Oct 12, 2012, at 1:37 AM, Ed wrote: Apologies for re-posting, my original message seems to have been overlooked by the moderators. No. Your original post _was_ forwarded to the list. On my machine it appeared at October 11, 2012 11:03:08 AM PDT. No one responded. It seems possible that its lack of data or code is the reason for that state of affairs. -- David. -- Forwarded message -- From: Ed icelus...@gmail.com Date: 11 October 2012 19:03 Subject: party for prediction To: R-help@r-project.org Hi there I'm experiencing some problems using the party package (specifically mob) for prediction. I have a real scalar y I want to predict from a real valued vector x and an integral vector z. mob seemed the ideal choice from the documentation. The first problem I had was at some nodes in a partitioning tree, the components of x may be extremely highly correlated or effectively constant (that is x are not independent for all choices of components of z). When the resulting fit is fed into predict() the result is NA - this is not the same behaviour as models returned by say lm which ignore missing coefficients. I have fixed this by defining my own statsModel (myLinearModel - imaginative) which also ignores such coefficients when predicting. The second problem I have is that I get Cholesky not positive definite errors at some nodes. I guess this is because of numerical error and degeneracy in the covariance matrix? Any thoughts on how to avoid having this happen would be welcome; it is ignorable though for now. The third and really big problem I have is that when I apply mob to large datasets (say hundreds of thousands of elements) I get a logical subscript too long error inside mob_fit_fluctests. It's caught in a try(), and mob just gives up and treats the node as terminal. This is really hurting me though; with 1% of my data I can get a good fit and a worthwhile tree, but with the whole dataset I get a very stunted tree with a pretty useless prediction ability. I guess what I really want to know is: (a) has anyone else had this problem, and if so how did they overcome it? (b) is there any way to get a line or stack trace out of a try() without source modification? (c) failing all of that, does anyone know of an alternative to mob that does the same thing; for better or worse I'm now committed to recursive partitioning over linear models, as per mob? (d) failing all of this, does anyone have a link to a way to rebuild, or locally modify, an R package (preferably windows, but anything would do)? Sorry for the length of this post. If I should RTFM, please point me at any relevant manual by all means. I've spent a few days on this as you can maybe tell, but I'm far from being an R expert. Thanks for any help you can give. Best wishes, Ed 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] rank() not doing really what I want
On Oct 12, 2012, at 1:07 AM, Henri-Paul Indiogine wrote: Hi Michael! 2012/10/12 R. Michael Weylandt michael.weyla...@gmail.com: If they are already in decreasing order, you might be able to work something out like (untested): cumsum(c(1, diff(x) 0)) Thanks seems to work. Thanks a bunch! Another strategy: cumsum(!duplicated(x)) -- 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] party for prediction [REPOST]
Sorry, my mistake, I didn't get a notification or see it send. Thanks for clearing that up. Best wishes Ed On 12 October 2012 16:58, David Winsemius dwinsem...@comcast.net wrote: On Oct 12, 2012, at 1:37 AM, Ed wrote: Apologies for re-posting, my original message seems to have been overlooked by the moderators. No. Your original post _was_ forwarded to the list. On my machine it appeared at October 11, 2012 11:03:08 AM PDT. No one responded. It seems possible that its lack of data or code is the reason for that state of affairs. -- David. -- Forwarded message -- From: Ed icelus...@gmail.com Date: 11 October 2012 19:03 Subject: party for prediction To: R-help@r-project.org Hi there I'm experiencing some problems using the party package (specifically mob) for prediction. I have a real scalar y I want to predict from a real valued vector x and an integral vector z. mob seemed the ideal choice from the documentation. The first problem I had was at some nodes in a partitioning tree, the components of x may be extremely highly correlated or effectively constant (that is x are not independent for all choices of components of z). When the resulting fit is fed into predict() the result is NA - this is not the same behaviour as models returned by say lm which ignore missing coefficients. I have fixed this by defining my own statsModel (myLinearModel - imaginative) which also ignores such coefficients when predicting. The second problem I have is that I get Cholesky not positive definite errors at some nodes. I guess this is because of numerical error and degeneracy in the covariance matrix? Any thoughts on how to avoid having this happen would be welcome; it is ignorable though for now. The third and really big problem I have is that when I apply mob to large datasets (say hundreds of thousands of elements) I get a logical subscript too long error inside mob_fit_fluctests. It's caught in a try(), and mob just gives up and treats the node as terminal. This is really hurting me though; with 1% of my data I can get a good fit and a worthwhile tree, but with the whole dataset I get a very stunted tree with a pretty useless prediction ability. I guess what I really want to know is: (a) has anyone else had this problem, and if so how did they overcome it? (b) is there any way to get a line or stack trace out of a try() without source modification? (c) failing all of that, does anyone know of an alternative to mob that does the same thing; for better or worse I'm now committed to recursive partitioning over linear models, as per mob? (d) failing all of this, does anyone have a link to a way to rebuild, or locally modify, an R package (preferably windows, but anything would do)? Sorry for the length of this post. If I should RTFM, please point me at any relevant manual by all means. I've spent a few days on this as you can maybe tell, but I'm far from being an R expert. Thanks for any help you can give. Best wishes, Ed 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] RWinEdt will not start properly
When trying to start RWinEdt on a new laptop I am getting the following sequence of error messages 540Errors have occured while loading *.png images: C:\Program Files (x86)\WinEdt Team\WinEdt 7\Bitmaps\Images\Abbreviation.png Can't Open Macro File ? Exe(?); Can't Open Macro File Readonly Exe(Readonly ); Can't Open Macro File Wrap Exe(Wrap); Can't Open Macro File Indent Exe(Indent); Error saving the project file: C:\Program Files (x86)\WinEdt Team\WinEdt 7\R.prj Can't Open Macro File Over Exe(Over); Error in saving the initialization file: C:\Users\mirwin\AppData\Roaming\WinEdt\R.ini It appears that RWinEdt was installed correctly. From what I can tell, the files look to be in the correct places This problem occurs with 2.15.0 and 2.15.1 and WinEdt 7 (Build 20120704) under Windows 7. version _ platform x86_64-pc-mingw32 arch x86_64 os mingw32 system x86_64, mingw32 status major 2 minor 15.1 year 2012 month 06 day22 svn rev59607 language R version.string R version 2.15.1 (2012-06-22) nickname Roasted Marshmallows Anybody have any suggestions? Mark -- Mark Irwin ir...@markirwin.net http://www.markirwin.net __ 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] Loss of dimensions in subsetting arrays
On Oct 12, 2012, at 2:52 AM, Markku Karhunen wrote: Hi all, I've been wondering for a long time why R drops the dimensions of an array/matrix when you try to take a subset of one column. I mean this: dim(A) [1] 2 5 2 B=A[1,,] dim(B) 5 2 # so now dim(B)[3] doesn't work C=B[2,] dim(C) NULL # so now nrow(C) doesn't work Typically, you can get rid of this by writing as.matrix, as.array(...) but that generates extra lines of code. This is really annoying. Does anybody know how to turn this behaviour off? Read the help page for: ?[ # especially regarding the drop parameter. -- 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] ifelse reformulation
HI, Try this: count40- ifelse(test1$x3==40|test1$x4==40|test1$x5==40,0,1) count40 # [1] 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 as.vector(apply(test1,1,function(x) ifelse(any(x[4:6]==40),0,1))) # [1] 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 A.K. - Original Message - From: brunosm brunos...@gmail.com To: r-help@r-project.org Cc: Sent: Friday, October 12, 2012 10:18 AM Subject: Re: [R] ifelse reformulation That was exacly what i was looking for! Thanks a lot! Cheers! -- View this message in context: http://r.789695.n4.nabble.com/ifelse-reformulation-tp4645981p4645990.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] Problem with which function
See R FAQ 7.31. --- 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. max u...@maxmetzger.de wrote: Hej, i need the which() funktion to find the positions of an entry in a matrix. the entries i'm looking for are : seq(begin,end,0.01) and there are no empty spaces i'm searching in the right range. so i was looking for the results R can find and i recieved this answer. for (l in 1:length(qr)){print(c(l,nstu[l,1],nsto[l,1],nsto[l,1]-nstu[l,1],(nsto[l,1]-nstu[l,1])*100,which(sp1[,1]==nstu[l,1]),(nsto[l,1]-nstu[l,1])*100+which(sp1[,1]==nstu[l,1]),which(r[,1]==nstu[l,1]),(nsto[l,1]-nstu[l,1])*100+which(r[,1]==nstu[l,1])))} [1] 1 0 0 0 0 [1] 2 0 0 0 0 [1] 3 0 0 0 0 [1]4.00 87.34 87.970.63 63.00 2491.00 2554.00 2491.00 2554.00 [1]5.00 86.73 88.461.73 173.00 2430.00 2603.00 [1]6.00 86.22 88.772.55 255.00 2379.00 2634.00 [1]7.00 85.77 89.013.24 324.00 2334.00 2658.00 [1]8.00 85.36 89.223.86 386.00 2293.00 2679.00 [1]9.0 85.0 89.44.4 440.0 2257.0 2697.0 [1] 10.00 84.68 89.574.89 489.00 2225.00 2714.00 2225.00 2714.00 [1] 11.00 84.38 89.735.35 535.00 2195.00 2730.00 [1] 12.00 84.11 89.885.77 577.00 2168.00 2745.00 [1] 13.00 83.86 90.026.16 616.00 2143.00 2759.00 [1] 14.00 83.64 90.156.51 651.00 2121.00 2772.00 [1] 15.00 83.43 90.286.85 685.00 2100.00 2785.00 2100.00 2785.00 [1] 16.00 83.24 90.407.16 716.00 2081.00 2797.00 [1] 17.00 83.07 90.52 7.45 745.00 [1] 18.00 82.91 90.637.72 772.00 2048.00 2820.00 [1] 19.00 82.76 90.757.99 799.00 2033.00 2832.00 [1] 20.00 82.62 90.868.24 824.00 2019.00 2843.00 2019.00 2843.00 [1] 21.00 82.49 90.978.48 848.00 2006.00 2854.00 [1] 22.00 82.37 91.088.71 871.00 1994.00 2865.00 1994.00 2865.00 [1] 23.00 82.26 91.198.93 893.00 1983.00 2876.00 [1] 24.00 82.16 91.319.15 915.00 1973.00 2888.00 [1] 25.00 82.07 91.429.35 935.00 1964.00 2899.00 [1] 26.00 81.98 91.539.55 955.00 1955.00 2910.00 [1] 27.00 81.90 91.649.74 974.00 1947.00 2921.00 1947.00 2921.00 [1] 28.00 81.83 91.759.92 992.00 1940.00 2932.00 [1] 29.00 81.76 91.87 10.11 1011.00 1933.00 2944.00 [1] 30.00 81.69 91.98 10.29 1029.00 1926.00 2955.00 [1] 31.00 81.63 92.09 10.46 1046.00 1920.00 2966.00 [1] 32.00 81.57 92.20 10.63 1063.00 [1] 33.00 81.50 92.31 10.81 1081.00 1907.00 2988.00 [1] 34.00 81.44 92.43 10.99 1099.00 1901.00 3000.00 [1] 35.00 81.38 92.54 11.16 1116.00 1895.00 3011.00 [1] 36.00 81.31 92.65 11.34 1134.00 1888.00 3022.00 [1] 37.00 81.25 92.76 11.51 1151.00 1882.00 3033.00 [1] 38.00 81.18 92.87 11.69 1169.00 1875.00 3044.00 1875.00 3044.00 [1] 39.00 81.12 92.98 11.86 1186.00 1869.00 3055.00 1869.00 3055.00 [1] 40.00 81.05 93.10 12.05 1205.00 1862.00 3067.00 [1] 41.00 80.99 93.21 12.22 1222.00 1856.00 3078.00 [1] 42.00 80.92 93.32 12.40 1240.00 1849.00 3089.00 [1] 43.00 80.86 93.43 12.57 1257.00 1843.00 3100.00 [1] 44.00 80.79 93.54 12.75 1275.00 [1] 45.00 80.73 93.66 12.93 1293.00 1830.00 3123.00 [1] 46.00 80.66 93.77 13.11 1311.00 1823.00 3134.00 [1] 47.00 80.60 93.88 13.28 1328.00 1817.00 3145.00 [1] 48.00 80.53 93.99 13.46 1346.00 1810.00 3156.00 [1] 49.00 80.47 94.10 13.63 1363.00 1804.00 3167.00 [1] 50.00 80.40 94.22 13.82 1382.00 1797.00 3179.00 1797.00 3179.00 [1] 51.00 80.34 94.33 13.99 1399.00 1791.00 3190.00 1791.00 3190.00 [1] 52.00 80.27 94.44 14.17 1417.00 1784.00 3201.00 [1] 53.00 80.20 94.55 14.35 1435.00 1777.00 3212.00 [1] 54.00 80.14 94.66 14.52 1452.00 1771.00 3223.00 [1] 55.00 80.07 94.77 14.70 1470.00 1764.00 3234.00 [1] 56.00 80.01 94.89 14.88 1488.00 1758.00 3246.00 [1] 57.00 79.94 95.00 15.06 1506.00 1751.00 3257.00 [1] 58.00 79.87 95.11 15.24 1524.00 1744.00 3268.00 1744.00 3268.00 [1] 59.00 79.81 95.22 15.41 1541.00 1738.00 3279.00 [1] 60.00 79.74 95.32 15.58 1558.00 1731.00 3289.00 [1] 61.00 79.67 95.43 15.76 1576.00 1724.00 3300.00 [1] 62.00 79.61 95.54 15.93 1593.00 1718.00 3311.00 [1] 63.00 79.54 95.65 16.11 1611.00 [1] 64.00 79.47 95.76 16.29 1629.00 1704.00 .00 [1] 65.00 79.41 95.87 16.46 1646.00 1698.00
Re: [R] problem in downloading RMySQL pkg
It will be helpful for us of you have some information about OS you are working. Anyways for windows , there is a similar post in nabble or r-help , so some googling will not hurt you. Best Regards, Bhupendrasinh Thakre Sent from my iPhone On Oct 12, 2012, at 12:52 AM, sagarnikam123 sagarnikam...@gmail.com wrote: when i am installing Rmysql packages i get error like Warning in install.packages : package ‘RMySQL’ is not available (for R version 2.15.0) which is earliest version should i used ?how should i know the specific version -- View this message in context: http://r.789695.n4.nabble.com/problem-in-downloading-RMySQL-pkg-tp4645967.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] average duplicated rows?
Hello, It could be a job for tapply, but I find it more suited for ?ave. dat - read.table(text = gene_id sample_1 sample_2 FL_EARLY FL_LATE 763938 Eucgr.A00054 fl_S1E fl_S1L 13.170800 22.2605 763979 Eucgr.A00101 fl_S1E fl_S1L 0.367960 14.1202 1273243 Eucgr.A00101fl_S2 fl_S1L 0.356625 14.1202 764169 Eucgr.A00350 fl_S1E fl_S1L 7.381070 43.9275 1273433 Eucgr.A00350fl_S2 fl_S1L 10.674500 43.9275 1273669 Eucgr.A00650fl_S2 fl_S1L 33.669100 50.0169 764480 Eucgr.A00744 fl_S1E fl_S1L 132.429000 747.2770 1273744 Eucgr.A00744fl_S2 fl_S1L 142.659000 747.2770 764595 Eucgr.A00890 fl_S1E fl_S1L 2.937760 14.9647 764683 Eucgr.A00990 fl_S1E fl_S1L 8.681250 48.5492 1273947 Eucgr.A00990fl_S2 fl_S1L 10.553300 48.5492 764710 Eucgr.A01020 fl_S1E fl_S1L 0.00 57.9273 1273974 Eucgr.A01020fl_S2 fl_S1L 0.00 57.9273 764756 Eucgr.A01073 fl_S1E fl_S1L 8.504710 101.1870 1274020 Eucgr.A01073fl_S2 fl_S1L 5.400010 101.1870 764773 Eucgr.A01091 fl_S1E fl_S1L 3.448910 15.7756 764826 Eucgr.A01152 fl_S1E fl_S1L 69.565700 198.2320 764831 Eucgr.A01158 fl_S1E fl_S1L 7.265640 30.9565 764845 Eucgr.A01172 fl_S1E fl_S1L 3.248020 16.9127 764927 Eucgr.A01269 fl_S1E fl_S1L 18.710200 76.6918 , header = TRUE) av - ave(dat$FL_EARLY, dat$gene_id) dat$FLY_EARLY - av Hope this helps, Rui Barradas Em 12-10-2012 16:41, Vining, Kelly escreveu: Dear useRs, I have a slightly complicated data structure and am stuck trying to extract what I need. I'm pasting an example of this data below. In some cases, there are duplicates in the gene_id column because there are two different sample 1 values for a given sample 2 value. Where these duplicates exist, I need to average the corresponding FL_EARLY values and retain the FL_LATE value and replace those two rows with a row containing the FL_EARLY average so that I no longer have any gene_id duplicates. Seems like this is a job for some version of the apply function, but searching and puzzling over this has not gotten me anywhere. Any help will be much appreciated! Example data: gene_id sample_1 sample_2 FL_EARLY FL_LATE 763938 Eucgr.A00054 fl_S1E fl_S1L 13.170800 22.2605 763979 Eucgr.A00101 fl_S1E fl_S1L 0.367960 14.1202 1273243 Eucgr.A00101fl_S2 fl_S1L 0.356625 14.1202 764169 Eucgr.A00350 fl_S1E fl_S1L 7.381070 43.9275 1273433 Eucgr.A00350fl_S2 fl_S1L 10.674500 43.9275 1273669 Eucgr.A00650fl_S2 fl_S1L 33.669100 50.0169 764480 Eucgr.A00744 fl_S1E fl_S1L 132.429000 747.2770 1273744 Eucgr.A00744fl_S2 fl_S1L 142.659000 747.2770 764595 Eucgr.A00890 fl_S1E fl_S1L 2.937760 14.9647 764683 Eucgr.A00990 fl_S1E fl_S1L 8.681250 48.5492 1273947 Eucgr.A00990fl_S2 fl_S1L 10.553300 48.5492 764710 Eucgr.A01020 fl_S1E fl_S1L 0.00 57.9273 1273974 Eucgr.A01020fl_S2 fl_S1L 0.00 57.9273 764756 Eucgr.A01073 fl_S1E fl_S1L 8.504710 101.1870 1274020 Eucgr.A01073fl_S2 fl_S1L 5.400010 101.1870 764773 Eucgr.A01091 fl_S1E fl_S1L 3.448910 15.7756 764826 Eucgr.A01152 fl_S1E fl_S1L 69.565700 198.2320 764831 Eucgr.A01158 fl_S1E fl_S1L 7.265640 30.9565 764845 Eucgr.A01172 fl_S1E fl_S1L 3.248020 16.9127 764927 Eucgr.A01269 fl_S1E fl_S1L 18.710200 76.6918 --Kelly V. [[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] Adding Time when Blanks
Greetings, My data set has dates and times that I am working with. Some of the times in Time_of_end are blank. This is supposed to dictate that the particular experiment lasted 48 hours. I would like to add 48 hours to the start Start_of_Experiment for another column as End_of_Experiment including both the ones with 48 added and those with early times. I was thinking something with a conditional statement but I can't seem to figure out what code to use. Any insight would be appreciated. Let me know if there is anything else you need. Thanks for your time. I have Start_of_Experiment in POSIX format for time calculations from the following: data$Start_of_Experiment=as.POSIXct(strptime(data$start_time, %m/%d/%Y %H:%M:%S)) Here is a subset of my data. IDgroup Start_date Time_of_experiment Time_of_end 120209 402/02/2009 12:38:00 26 30209 3 03/02/2009 12:40:00 13:32:00 27 31609 4 03/16/2009 11:28:00 12:26:00 28 40609 4 04/06/2009 11:17:00 53 42709 4 04/27/2009 11:15:00 9:30:00 76 51109 3 05/11/2009 11:51:00 101 51809 1 05/18/2009 12:28:00 126 62209 3 06/22/2009 11:31:00 150 71309 4 07/13/2009 12:12:00 13:37:00 173 81009 4 08/10/2009 11:32:00 20:52:00 Start_of_Experiment 1 2009-02-02 12:38:00 26 2009-03-02 12:40:00 27 2009-03-16 11:28:00 28 2009-04-06 11:17:00 53 2009-04-27 11:15:00 76 2009-05-11 11:51:00 101 2009-05-18 12:28:00 126 2009-06-22 11:31:00 150 2009-07-13 12:12:00 173 2009-08-10 11:32:00 [[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] average duplicated rows?
HI, You can also try this: dat1-read.table(text= gene_id sample_1 sample_2 FL_EARLY FL_LATE 763938 Eucgr.A00054 fl_S1E fl_S1L 13.170800 22.2605 763979 Eucgr.A00101 fl_S1E fl_S1L 0.367960 14.1202 1273243 Eucgr.A00101 fl_S2 fl_S1L 0.356625 14.1202 764169 Eucgr.A00350 fl_S1E fl_S1L 7.381070 43.9275 1273433 Eucgr.A00350 fl_S2 fl_S1L 10.674500 43.9275 1273669 Eucgr.A00650 fl_S2 fl_S1L 33.669100 50.0169 764480 Eucgr.A00744 fl_S1E fl_S1L 132.429000 747.2770 1273744 Eucgr.A00744 fl_S2 fl_S1L 142.659000 747.2770 764595 Eucgr.A00890 fl_S1E fl_S1L 2.937760 14.9647 764683 Eucgr.A00990 fl_S1E fl_S1L 8.681250 48.5492 1273947 Eucgr.A00990 fl_S2 fl_S1L 10.553300 48.5492 764710 Eucgr.A01020 fl_S1E fl_S1L 0.00 57.9273 1273974 Eucgr.A01020 fl_S2 fl_S1L 0.00 57.9273 764756 Eucgr.A01073 fl_S1E fl_S1L 8.504710 101.1870 1274020 Eucgr.A01073 fl_S2 fl_S1L 5.400010 101.1870 764773 Eucgr.A01091 fl_S1E fl_S1L 3.448910 15.7756 764826 Eucgr.A01152 fl_S1E fl_S1L 69.565700 198.2320 764831 Eucgr.A01158 fl_S1E fl_S1L 7.265640 30.9565 764845 Eucgr.A01172 fl_S1E fl_S1L 3.248020 16.9127 764927 Eucgr.A01269 fl_S1E fl_S1L 18.710200 76.6918 ,sep=,header=TRUE,stringsAsFactors=FALSE) do.call(rbind,lapply(lapply(split(dat1,dat1$gene_id),`[`,4:5),colMeans)) FL_EARLY FL_LATE #Eucgr.A00054 13.1708000 22.2605 #Eucgr.A00101 0.3622925 14.1202 #Eucgr.A00350 9.0277850 43.9275 #Eucgr.A00650 33.6691000 50.0169 #Eucgr.A00744 137.544 747.2770 #Eucgr.A00890 2.9377600 14.9647 #Eucgr.A00990 9.6172750 48.5492 #Eucgr.A01020 0.000 57.9273 #Eucgr.A01073 6.9523600 101.1870 #Eucgr.A01091 3.4489100 15.7756 #Eucgr.A01152 69.5657000 198.2320 #Eucgr.A01158 7.2656400 30.9565 #Eucgr.A01172 3.2480200 16.9127 #Eucgr.A01269 18.7102000 76.6918 In addition to aggregate(), ddply() etc. library(data.table) dat2-data.table(dat1) dat3-dat2[,list(FL_EARLY=mean(FL_EARLY),FL_LATE=mean(FL_LATE)),list(gene_id)] #aggregate() dat4-with(dat1,aggregate(cbind(FL_EARLY,FL_LATE),list(gene_id),FUN=mean)) colnames(dat4)-colnames(dat1)[c(1,4,5)] #ddply() library(plyr) dat5-ddply(dat1,.(gene_id),colwise(mean,c(FL_EARLY,FL_LATE))) A.K. - Original Message - From: Vining, Kelly kelly.vin...@oregonstate.edu To: r-help@r-project.org r-help@r-project.org Cc: Sent: Friday, October 12, 2012 11:41 AM Subject: [R] average duplicated rows? Dear useRs, I have a slightly complicated data structure and am stuck trying to extract what I need. I'm pasting an example of this data below. In some cases, there are duplicates in the gene_id column because there are two different sample 1 values for a given sample 2 value. Where these duplicates exist, I need to average the corresponding FL_EARLY values and retain the FL_LATE value and replace those two rows with a row containing the FL_EARLY average so that I no longer have any gene_id duplicates. Seems like this is a job for some version of the apply function, but searching and puzzling over this has not gotten me anywhere. Any help will be much appreciated! Example data: gene_id sample_1 sample_2 FL_EARLY FL_LATE 763938 Eucgr.A00054 fl_S1E fl_S1L 13.170800 22.2605 763979 Eucgr.A00101 fl_S1E fl_S1L 0.367960 14.1202 1273243 Eucgr.A00101 fl_S2 fl_S1L 0.356625 14.1202 764169 Eucgr.A00350 fl_S1E fl_S1L 7.381070 43.9275 1273433 Eucgr.A00350 fl_S2 fl_S1L 10.674500 43.9275 1273669 Eucgr.A00650 fl_S2 fl_S1L 33.669100 50.0169 764480 Eucgr.A00744 fl_S1E fl_S1L 132.429000 747.2770 1273744 Eucgr.A00744 fl_S2 fl_S1L 142.659000 747.2770 764595 Eucgr.A00890 fl_S1E fl_S1L 2.937760 14.9647 764683 Eucgr.A00990 fl_S1E fl_S1L 8.681250 48.5492 1273947 Eucgr.A00990 fl_S2 fl_S1L 10.553300 48.5492 764710 Eucgr.A01020 fl_S1E fl_S1L 0.00 57.9273 1273974 Eucgr.A01020 fl_S2 fl_S1L 0.00 57.9273 764756 Eucgr.A01073 fl_S1E fl_S1L 8.504710 101.1870 1274020 Eucgr.A01073 fl_S2 fl_S1L 5.400010 101.1870 764773 Eucgr.A01091 fl_S1E fl_S1L 3.448910 15.7756 764826 Eucgr.A01152 fl_S1E fl_S1L 69.565700 198.2320 764831 Eucgr.A01158 fl_S1E fl_S1L 7.265640 30.9565 764845 Eucgr.A01172 fl_S1E fl_S1L 3.248020 16.9127 764927 Eucgr.A01269 fl_S1E fl_S1L 18.710200 76.6918 --Kelly V. [[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
Re: [R] Adding Time when Blanks
Hello, Try the following. dat - read.table(text= IDgroup Start_date Time_of_experiment Time_of_end 120209 402/02/2009 12:38:00 26 30209 3 03/02/2009 12:40:00 13:32:00 27 31609 4 03/16/2009 11:28:00 12:26:00 28 40609 4 04/06/2009 11:17:00 53 42709 4 04/27/2009 11:15:00 9:30:00 76 51109 3 05/11/2009 11:51:00 101 51809 1 05/18/2009 12:28:00 126 62209 3 06/22/2009 11:31:00 150 71309 4 07/13/2009 12:12:00 13:37:00 173 81009 4 08/10/2009 11:32:00 20:52:00 , header=TRUE, fill=TRUE) str(dat) dat$start_time - with(dat, paste(Start_date, Time_of_experiment)) dat$Start_of_Experiment - as.POSIXct(strptime(dat$start_time, %m/%d/%Y %H:%M:%S)) #--- Create End_of_Experiment idx - dat$Time_of_end != '' dat$End_of_Experiment - dat$Start_of_Experiment + 48*60*60 dat$End_of_Experiment[idx] - as.POSIXct(strptime(paste(dat$Start_date, dat$Time_of_end)[idx], %m/%d/%Y %H:%M:%S)) dat Hope this helps, Rui Barradas Em 12-10-2012 18:59, Charles Determan Jr escreveu: Greetings, My data set has dates and times that I am working with. Some of the times in Time_of_end are blank. This is supposed to dictate that the particular experiment lasted 48 hours. I would like to add 48 hours to the start Start_of_Experiment for another column as End_of_Experiment including both the ones with 48 added and those with early times. I was thinking something with a conditional statement but I can't seem to figure out what code to use. Any insight would be appreciated. Let me know if there is anything else you need. Thanks for your time. I have Start_of_Experiment in POSIX format for time calculations from the following: data$Start_of_Experiment=as.POSIXct(strptime(data$start_time, %m/%d/%Y %H:%M:%S)) Here is a subset of my data. IDgroup Start_date Time_of_experiment Time_of_end 120209 402/02/2009 12:38:00 26 30209 3 03/02/2009 12:40:00 13:32:00 27 31609 4 03/16/2009 11:28:00 12:26:00 28 40609 4 04/06/2009 11:17:00 53 42709 4 04/27/2009 11:15:00 9:30:00 76 51109 3 05/11/2009 11:51:00 101 51809 1 05/18/2009 12:28:00 126 62209 3 06/22/2009 11:31:00 150 71309 4 07/13/2009 12:12:00 13:37:00 173 81009 4 08/10/2009 11:32:00 20:52:00 Start_of_Experiment 1 2009-02-02 12:38:00 26 2009-03-02 12:40:00 27 2009-03-16 11:28:00 28 2009-04-06 11:17:00 53 2009-04-27 11:15:00 76 2009-05-11 11:51:00 101 2009-05-18 12:28:00 126 2009-06-22 11:31:00 150 2009-07-13 12:12:00 173 2009-08-10 11:32:00 [[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] better example for multivariate data simulation question-please help if you can
Dear All, a few weeks ago I have posted a question on the R help listserv that some of you have responded to with a great solution, would like to thank you for that again. I thought I would reach out to you with the issue I am trying to solve now. I have posted the question a few days ago, but probably it was not clear enough, so I thought i try it again. At times I have a multivariate example on my hand with known information of means, SDs and medians for the variables, and the covariance matrix of those variables. Occasionally, these parameters have a strong enough relationship between them that a covariance matrix can be established. Please see attached document as an example. Usually when I (a medicine people) simulate (and it is not to say that this is the best approach), we use a lognormal distribution to avoid from negative values being generated because physiologic variables almost are never negative (we also really do not know better, unfortunatelly). For the most part I use another software that is capable of reproducing reasonable means and medians and SD if I enter the covariance matrix, but that is not a free resource (so I can not share the solutions with others), nor does it have the Sweave option for standard reports like R does that can be distributed for free. Unfortunately in R I am having a hard time figuring the solution out. I have tried to use the multivariate normal distribution function mvrnorm from the MASS package, or the Mvnorm from mvtnorm package, but will get negative values simulated, which I can not afford, also, at times the simulated means, medians and SDs are quiet different from what I started with (which may be due to the assumption I make with regards to the distribution of the data). I was wondering if anyone would be willing to provide some thoughts on how you think one should try to attempt to simulate in R a multivariate distribution with covariance matrix (using the attached data as an example) that would result in reasonable means, medians and SD as compared to the original values? While to have a better idea about the actual distribution of the data would probably be invaluable to accurately reproduce the data (and to choose a probability distribution to simulate with), often times in the medical literature we only have information available similar to what I have attached, (and we make the assumption of it being log normally distributed as I have mentioned it above). I would greatly appreciate your help, Sincerely, Andras__ 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] ifelse reformulation
Hi arun kirshna just let me ask you something else. Imagin that i only want to search in the variables x3,x4 and x5. How can i do this? Regards, Bruno -- View this message in context: http://r.789695.n4.nabble.com/ifelse-reformulation-tp4645981p4646013.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 rowMeans function
Hello, I am trying to create parcels for a CFA model. I am trying to average 6 sets of 3 variables each into parcels. I don't understand why I am getting an error message as follows: Thanks for your help, Catherine atds1par - rowMeans(semHW1dat1[, c(atds1, atds2, atds3)], na.rm=TRUE) atds2par - rowMeans(semHW1dat1[, c(atds4, atds5, atds6)], na.rm=TRUE) atds3par - rowMeans(semHW1dat1[, c(atds7, atds8, atds9)], na.rm=TRUE) sgs1par - rowMeans(semHW1dat1[, c(sgs1, sgs2, sgs3)], na.rm=TRUE) sgs2par - rowMeans(semHW1dat1[, c(sgs4, sgs5, sgs6)], na.rm=TRUE) sgs3par - rowMeans(semHW1dat1[, c(sgs7, sgs8, sgs9)], na.rm=TRUE) parmod1 - ProDragATT =~ atds1par + atds2par + atds3par + SucInSchl =~ sgs1par + sgs2par + sgs3par + ProDragAtt~~SucInSchl parout1 - cfa(parmod1, data=semHW1dat1, sample.nobs=500, std.lv=TRUE) Error in getDataFull(data = data, group = group, group.label = group.label, : lavaan ERROR: missing observed variables in dataset: atds1par atds2par atds3par sgs1par sgs2par sgs3par ProDragAtt summary(parout1) Error in summary(parout1) : error in evaluating the argument 'object' in selecting a method for function 'summary': Error: object 'parout1' not found fitMeasures(parout1) Error in fitMeasures(parout1) : object 'parout1' not found inspect(parout1, mi) Error in inspect(parout1, mi) : error in evaluating the argument 'object' in selecting a method for function 'inspect': Error: object 'parout1' not found [[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] Problems with getURL (RCurl) to obtain list files of an ftp directory
Hi Francisco The code gives me the correct results, and it works for you on a Windows machine. So while it could be different versions of software (e.g. libcurl, RCurl, etc.), the presence of the word squid in the HTML suggests to me that your machine/network is using the proxy/caching software Squid. This intercepts requests and caches the results locally and shares them across local users. So if squid has retrieved that page for an HTML target (e.g. a browser or with a Content-Type set to text/html), it may be using that cached copy for your FTP request. One thing I like to do when debugging RCurl calls is to add verbose = TRUE to the .opts argument and then see the information about the communication. D. On 10/11/12 11:37 AM, Francisco Zambrano wrote: Dear all, I have a problem with the command 'getURL' from the RCurl package, which I have been using to obtain a ftp directory list from the MOD16 (ET, DSI) products, and then to download them. (part of the script by Tomislav Hengl, spatial-analyst). Instead of the list of files (from ftp), I am getting the complete html code. Anyone knows why this might happen? This are the steps i have been doing: MOD16A2.doy- ' ftp://ftp.ntsg.umt.edu/pub/MODIS/Mirror/MOD16/MOD16A2.105_MERRAGMAO/' items - strsplit(getURL(MOD16A2.doy, .opts=curlOptions(ftplistonly=TRUE)), \n)[[1]] items #results [1] !DOCTYPE HTML PUBLIC \-//W3C//DTD HTML 4.01 Transitional//EN\ \ http://www.w3.org/TR/html4/loose.dtd\;\n!-- HTML listing generated by Squid 2.7.STABLE9 --\n!-- Wed, 10 Oct 2012 13:43:53 GMT --\nHTMLHEADTITLE\nFTP Directory: ftp://ftp.ntsg.umt.edu/pub/MODIS/Mirror/MOD16/MOD16A2.105_MERRAGMAO/\n/TITLE\nSTYLE type=\text/css\!--BODY{background-color:#ff;font-family:verdana,sans-serif}--/STYLE\n/HEADBODY\nH2\nFTP Directory: A HREF=\/\ftp://ftp.ntsg.umt.edu/A/A HREF=\/pub/\pub/A/A HREF=\/pub/MODIS/\MODIS/A/A HREF=\/pub/MODIS/Mirror/\Mirror/A/A HREF=\/pub/MODIS/Mirror/MOD16/\MOD16/A/A HREF=\/pub/MODIS/Mirror/MOD16/MOD16A2.105_MERRAGMAO/\MOD16A2.105_MERRAGMAO/A//H2\nPRE\nA HREF=\../\IMG border=\0\ SRC=\ http://localhost:3128/squid-internal-static/icons/anthony-dirup.gif\; ALT=\[DIRUP]\/A A HREF=\../\Parent Directory/A \nA HREF=\GEOTIFF_0.05degree/\IMG border=\0\ SRC=\ http://localhost:3128/squid-internal-static/icons/anthony-dir.gif\; ALT=\[DIR] \/A A HREF=\GEOTIFF_0.05degree/\GEOTIFF_0.05degree/A . . . . . . . Jun 3 18:00\nA HREF=\GEOTIFF_0.5degree/\IMG border=\0\ SRC=\ http://localhost:3128/squid-internal-static/icons/anthony-dir.gif\; ALT=\[DIR] \/A A HREF=\GEOTIFF_0.5degree/\GEOTIFF_0.5degree/A. . . . . . . . Jun 3 18:01\nA HREF=\Y2000/\IMG border=\0\ SRC=\http://localhost:3128/squid-internal-static/icons/anthony-dir.gif\; ALT=\[DIR] \/A A HREF=\Y2000/\Y2000/A. . . . . . . . . . . . . . Dec 23 2010\nA HREF=\Y2001/\IMG border=\0\ SRC=\ http://localhost:3128/squid-internal-static/icons/anthony-dir.gif\; ALT=\[DIR] \/A A HREF=\Y2001/\Y2001/A. . . . . . . . . . . . . . Dec 23 2010\nA HREF=\Y2002/\IMG border=\0\ SRC=\ http://localhost:3128/squid-internal-static/icons/anthony-dir.gif\; ALT=\[DIR] \/A A HREF=\Y2002/\Y2002/A. . . . . . . . . . . . . . Dec 23 2010\nA HREF=\Y2003/\IMG border=\0\ SRC=\ http://localhost:3128/squid-internal-static/icons/anthony-dir.gif\; ALT=\[DIR] \/A A HREF=\Y2003/\Y2003/A. . . . . . . . . . . . . . Dec 23 2010\nA HREF=\Y2004/\IMG border=\0\ SRC=\ http://localhost:3128/squid-internal-static/icons/anthony-dir.gif\; ALT=\[DIR] \/A A HREF=\Y2004/\Y2004/A. . . . . . . . . . . . . . Dec 23 2010\nA HREF=\Y2005/\IMG border=\0\ SRC=\ http://localhost:3128/squid-internal-static/icons/anthony-dir.gif\; ALT=\[DIR] \/A A HREF=\Y2005/\Y2005/A. . . . . . . . . . . . . . Dec 23 2010\nA HREF=\Y2006/\IMG border=\0\ SRC=\ http://localhost:3128/squid-internal-static/icons/anthony-dir.gif\; ALT=\[DIR] \/A A HREF=\Y2006/\Y2006/A. . . . . . . . . . . . . . Dec 23 2010\nA HREF=\Y2007/\IMG border=\0\ SRC=\ http://localhost:3128/squid-internal-static/icons/anthony-dir.gif\; ALT=\[DIR] \/A A HREF=\Y2007/\Y2007/A. . . . . . . . . . . . . . Dec 23 2010\nA HREF=\Y2008/\IMG border=\0\ SRC=\ http://localhost:3128/squid-internal-static/icons/anthony-dir.gif\; ALT=\[DIR] \/A A HREF=\Y2008/\Y2008/A. . . . . . . . . . . . . . Dec 23 2010\nA HREF=\Y2009/\IMG border=\0\ SRC=\ http://localhost:3128/squid-internal-static/icons/anthony-dir.gif\; ALT=\[DIR] \/A A HREF=\Y2009/\Y2009/A. . . . . . . . . . . . . . Dec 23 2010\nA HREF=\Y2010/\IMG border=\0\ SRC=\ http://localhost:3128/squid-internal-static/icons/anthony-dir.gif\; ALT=\[DIR] \/A A HREF=\Y2010/\Y2010/A. . . . . . . . . . . . . . Feb 20 2011\nA HREF=\Y2011/\IMG border=\0\ SRC=\ http://localhost:3128/squid-internal-static/icons/anthony-dir.gif\; ALT=\[DIR] \/A A HREF=\Y2011/\Y2011/A. . . . . . . . . . . . . . Mar 12 2012
[R] RTAQ - convert function: warning causes incorrect loading of data
Hello, I am closely following the RTAQ documentation in order to load my dataset into R, however I get this warning when running the convert function in the following way: convert(from=2010-11-01, to=2010-11-01,datasource=datasource, datadestination=datadestination,trades=T,quotes=T,ticker=BAC,dir=T, extention=csv, header=T, tradecolnames=c(SYMBOL, DATE, TIME, PRICE, SIZE, G127, CORR, COND, EX), quotecolnames=c(SYMBOL, DATE, TIME, BID, OFR, BIDSIZ, OFRSIZ, MODE, EX)) The only warning returned is: In `[-.factor`(`*tmp*`, is.na(tdata$G127), value = c(1L, 1L, 1L, : invalid factor level, NAs generated As it is a warning, the .RData files still get created and I can use TAQLoad to load them: x - TAQLoad(BAC,from=2010-11-01,to=2010-11-01,datasource=datadestination, trades=T,quotes=T) The PROBLEM: head(x) SYMBOL EX PRICE SIZECOND CORR G127 NA BAC B 11.4900 500 @ 0 0 ... This is the same for the quotes objects, but different headers obviously. I get a NA instead of the expected YYY-MM-DD HH:MM:SS format for each observation. I've spent a fair number of hours on trying to get this right, no success. Can you please provide me with some guidance? Thank you. A sample from the CSV files I use: SYMBOL,DATE,TIME,BID,OFR,BIDSIZ,OFRSIZ,MODE,EX BAC,20101101,9:30:00,11.5,11.51,5,116,12,P ... SYMBOL,DATE,TIME,PRICE,SIZE,G127,CORR,COND,EX BAC,20101101,10:30:00,11.49,500,0,0,@,B ... -- View this message in context: http://r.789695.n4.nabble.com/RTAQ-convert-function-warning-causes-incorrect-loading-of-data-tp4646025.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] extracting groups from hclust() for a very large matrix
Le vendredi 12 octobre 2012 à 11:33 -0700, Christopher R. Dolanc a écrit : That command gives me the same result. Do you see that R is not listing the plot numbers? Just all the numbers between 1 and 137, 138 and 310, etc. It's like it has reordered the dendrogram, so that everything occurs chronologically. Instead, I would expect something like this: [1] 3, 15, 48, 134, 136, 213, 299, . [2] 44, 67, 177, . Yeah, but that's a problem with your data or your dist function, not with hclust() and cutree(). As always, it's good to try to find the minimal example that reproduces the problem. Start from examples provided by ?cutree: hc - hclust(dist(USArrests)) cutree(hc, k=2) Alabama AlaskaArizona Arkansas California 1 1 1 2 1 ColoradoConnecticut DelawareFloridaGeorgia 2 2 1 1 2 etc. Here you see the cluster numbers are not in sequence, and my command shows groups correctly: split(rownames(USArrests), cutree(hc, 2)) $`1` [1] AlabamaAlaska ArizonaCalifornia etc. $`2` [1] Arkansas Colorado Connecticut Georgia [5] HawaiiIdaho Indiana Iowa etc. So either your data is already ordered, or you have a problem with your distance function. One guess: you have included the Plot column in the call to vegdist(). I don't know this function, but it seems to work like dist(), which means passing the plot id is plain wrong. Indeed, if I use VTM.Dist-vegdist(VTM.Matrix[,-1]) VTM.HClust- hclust(VTM.Dist, method=ward) VTM.8groups- cutree(VTM.HClust, 8) the result is not ordered as before. Lesson: try with simple, standard data when complex data sets don't work, and compare results. My two cents __ 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 to read non-standard csv file
Hi all, I have a problem to read csv file with comma as decimal. The numbers were readed as strings. I used the following string in R, but I do not understand why it does not work. tab - read.csv2(Specimen_RawData_1.csv, header = TRUE, sep = ;, dec = ,, nrows = -1) In addition, I copy/past into the post the link to the csv file generated by my instrument. https://dl.dropbox.com/u/95607996/Specimen_RawData_1.csv The file is encoded in ANSI, I tried also the following string, but the result was the same tab - read.csv2(Specimen_RawData_1.csv, header = TRUE, sep = ;, dec = ,, nrows = -1, encoding = ANSI) The possibility to open the file into a text editor and replace comma with point is a crazy way, because I have around 1000 files to elaborate. The only way for me is to use R. I hope that someone can help me to find the issue. Best, Roberto -- View this message in context: http://r.789695.n4.nabble.com/Problem-to-read-non-standard-csv-file-tp4646018.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] Selecting n observation
do.call(rbind, by(df, INDICES=df$ID, FUN=function(DF) tail(DF, 2) )) Another way to approach this sort of problem is to use ave() to assign a within-group sequence number to each row and then select the rows with the sequence numbers you want. You can also use ave() to make a column giving the size of the group that each item is in. Hence you can select things like the last 2 items in each category that had at least 3 items. E.g., here is a function to generate data on visits of patients to a clinic, where the visits are listed in time order. makeData - function(nVisits, Doctors=paste(Dr.,LETTERS[1:2]), Patients=101:104, seed = 1) { if (!is.null(seed)) set.seed(seed) data.frame(Doctor=sample(Doctors, replace=TRUE, nVisits), Patient=sample(Patients, replace=TRUE, nVisits), Date=as.Date(2004-01-01)+sort(sample(2000, replace=TRUE, nVisits))) } # Make a 12-row dataset d - makeData(12) # Add columns describing the visits between each doctor/patient pair d1 - within(d, { N=ave(integer(length(Date)), Doctor, Patient, FUN=length) Seq=ave(integer(length(Date)), Doctor, Patient, FUN=seq_along)}) d1 #Doctor Patient Date Seq N # 1 Dr. A 103 2004-01-28 1 3 # 2 Dr. A 102 2005-01-08 1 1 # 3 Dr. B 104 2005-06-19 1 4 # 4 Dr. B 102 2005-11-12 1 2 # 5 Dr. A 103 2006-02-04 2 3 # 6 Dr. B 104 2006-02-12 2 4 # 7 Dr. B 102 2006-08-23 2 2 # 8 Dr. B 104 2006-09-15 3 4 # 9 Dr. B 104 2007-04-15 4 4 # 10 Dr. A 101 2007-08-30 1 2 # 11 Dr. A 103 2008-07-13 3 3 # 12 Dr. A 101 2008-10-06 2 2 # Show the last visit in each doctor/patient group d[d1$Seq==d1$N, ] #Doctor Patient Date # 2 Dr. A 102 2005-01-08 # 7 Dr. B 102 2006-08-23 # 9 Dr. B 104 2007-04-15 # 11 Dr. A 103 2008-07-13 # 12 Dr. A 101 2008-10-06 # Show last 2 visits, but only if there were at least 2 visits d[d1$Seqd1$N-2 d1$N=2, ] #Doctor Patient Date # 4 Dr. B 102 2005-11-12 # 5 Dr. A 103 2006-02-04 # 7 Dr. B 102 2006-08-23 # 8 Dr. B 104 2006-09-15 # 9 Dr. B 104 2007-04-15 # 10 Dr. A 101 2007-08-30 # 11 Dr. A 103 2008-07-13 # 12 Dr. A 101 2008-10-06 # Show the amount of time beteen the last two visits in a group (if there were at least 2 visits) d[d1$Seq==d1$N d1$N=2, Date] - d[d1$Seq==d1$N-1 d1$N=2, Date] # Time differences in days # [1] 284 435 667 403 I find it easier to formulate the queries with this method. For large datasets, selecting rows according a criterion can be a lot faster than splitting a data.frame into many parts, processing them with tail, and combining them again. Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of David Winsemius Sent: Thursday, October 11, 2012 2:13 PM To: bibek sharma Cc: r-help@r-project.org Subject: Re: [R] Selecting n observation On Oct 11, 2012, at 12:48 PM, bibek sharma wrote: Hello R help, I have a question similar to what is posted by someone before. my problem is that Instead of last assessment, I want to choose last two. I have a data set with several time assessments for each participant. I want to select the last assessment for each participant. My dataset looks like this: ID week outcome 1 2 14 1 4 28 1 6 42 4 2 14 4 6 46 4 9 64 4 9 71 4 12 85 9 2 14 9 4 28 9 6 51 9 9 66 9 12 84 Here is one solution for choosing last assessment do.call(rbind, by(df, INDICES=df$ID, FUN=function(DF) DF[which.max(DF$week), ])) Why wouldn't the solution be something along the lines of: do.call(rbind, by(df, INDICES=df$ID, FUN=function(DF) tail(DF, 2) )) ID week outcome 1 16 42 4 4 12 85 9 9 12 84 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-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 file(file, rt) : cannot open the connection
I tried changing that to simplysaspath= C:/Program Files/SAS/SASFoundation/9.2 Still the same error :( Thanks for reply though Navin On Fri, Oct 12, 2012 at 8:24 AM, S Ellison s.elli...@lgcgroup.com wrote: I get this error : Error in file(file, rt) : cannot open the connection ... saspath=\C:/Program Files/SAS/SASFoundation/9.2, I don't know the package but your saspath only contains one quote mark, so you have given it C:/Program Files/SAS/SASFoundation/9.2 to open. Would it not need a closing quote or (noting that it's a simple enough path, no opening quote? S *** This email and any attachments are confidential. Any u...{{dropped:17}} __ 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] Adding Time when Blanks
This works perfect, thank you very much Rui! On Fri, Oct 12, 2012 at 1:35 PM, Rui Barradas ruipbarra...@sapo.pt wrote: Hello, Try the following. dat - read.table(text= IDgroup Start_date Time_of_experiment Time_of_end 120209 402/02/2009 12:38:00 26 30209 3 03/02/2009 12:40:00 13:32:00 27 31609 4 03/16/2009 11:28:00 12:26:00 28 40609 4 04/06/2009 11:17:00 53 42709 4 04/27/2009 11:15:00 9:30:00 76 51109 3 05/11/2009 11:51:00 101 51809 1 05/18/2009 12:28:00 126 62209 3 06/22/2009 11:31:00 150 71309 4 07/13/2009 12:12:00 13:37:00 173 81009 4 08/10/2009 11:32:00 20:52:00 , header=TRUE, fill=TRUE) str(dat) dat$start_time - with(dat, paste(Start_date, Time_of_experiment)) dat$Start_of_Experiment - as.POSIXct(strptime(dat$start_**time, %m/%d/%Y %H:%M:%S)) #--- Create End_of_Experiment idx - dat$Time_of_end != '' dat$End_of_Experiment - dat$Start_of_Experiment + 48*60*60 dat$End_of_Experiment[idx] - as.POSIXct(strptime(paste(dat$**Start_date, dat$Time_of_end)[idx], %m/%d/%Y %H:%M:%S)) dat Hope this helps, Rui Barradas Em 12-10-2012 18:59, Charles Determan Jr escreveu: Greetings, My data set has dates and times that I am working with. Some of the times in Time_of_end are blank. This is supposed to dictate that the particular experiment lasted 48 hours. I would like to add 48 hours to the start Start_of_Experiment for another column as End_of_Experiment including both the ones with 48 added and those with early times. I was thinking something with a conditional statement but I can't seem to figure out what code to use. Any insight would be appreciated. Let me know if there is anything else you need. Thanks for your time. I have Start_of_Experiment in POSIX format for time calculations from the following: data$Start_of_Experiment=as.**POSIXct(strptime(data$start_**time, %m/%d/%Y %H:%M:%S)) Here is a subset of my data. IDgroup Start_date Time_of_experiment Time_of_end 120209 402/02/2009 12:38:00 26 30209 3 03/02/2009 12:40:00 13:32:00 27 31609 4 03/16/2009 11:28:00 12:26:00 28 40609 4 04/06/2009 11:17:00 53 42709 4 04/27/2009 11:15:00 9:30:00 76 51109 3 05/11/2009 11:51:00 101 51809 1 05/18/2009 12:28:00 126 62209 3 06/22/2009 11:31:00 150 71309 4 07/13/2009 12:12:00 13:37:00 173 81009 4 08/10/2009 11:32:00 20:52:00 Start_of_Experiment 1 2009-02-02 12:38:00 26 2009-03-02 12:40:00 27 2009-03-16 11:28:00 28 2009-04-06 11:17:00 53 2009-04-27 11:15:00 76 2009-05-11 11:51:00 101 2009-05-18 12:28:00 126 2009-06-22 11:31:00 150 2009-07-13 12:12:00 173 2009-08-10 11:32:00 [[alternative HTML version deleted]] __** R-help@r-project.org mailing list https://stat.ethz.ch/mailman/**listinfo/r-helphttps://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/** posting-guide.html 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] plots for presentation
Duncan's answer is probably the easiest, but another alternative is to use the tikz device instead of .eps files, then you can find the code within the figure for the parts that you want to appear later and enclose them in the beamer commands that will make them appear later. Unfortunately this is not easy to automate, if you recreate the plot, then you need to completely redo the inserting of the beamer commands. On Thu, Oct 11, 2012 at 11:56 AM, Duncan Murdoch murdoch.dun...@gmail.com wrote: On 11/10/2012 1:08 PM, mamush bukana wrote: Dear users, I am preparing a presentation in latex(beamer) . I would like to show parts of my plots per click. Example, consider I have two time series x and y: x-ts(rnorm(100), start=1900,end=1999) y-ts(rnorm(100), start=1900,end=1999) plot(x) lines(y,col=2) Then I imported this plot into latex as .eps file. My question is, how can i show plot of each time series separately in sequence (one after the other). An also I want to show parts of the plots at different time segments in my presentation. To be honest, I don't know if these features are in R or in latex. Mostly Latex/Beamer. Draw the two versions of the plot, and tell beamer to show the first one only on overlay 1, the second only on overlay 2. This is particularly easy using Sweave, because you can save the code that drew the first plot and re-use it in the second. Duncan Murdoch __ 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] Problem to read non-standard csv file
On Oct 12, 2012, at 18:45 , Roberto wrote: Hi all, I have a problem to read csv file with comma as decimal. The numbers were readed as strings. I used the following string in R, but I do not understand why it does not work. tab - read.csv2(Specimen_RawData_1.csv, header = TRUE, sep = ;, dec = ,, nrows = -1) In addition, I copy/past into the post the link to the csv file generated by my instrument. https://dl.dropbox.com/u/95607996/Specimen_RawData_1.csv The file is encoded in ANSI, I tried also the following string, but the result was the same tab - read.csv2(Specimen_RawData_1.csv, header = TRUE, sep = ;, dec = ,, nrows = -1, encoding = ANSI) The possibility to open the file into a text editor and replace comma with point is a crazy way, because I have around 1000 files to elaborate. The only way for me is to use R. I hope that someone can help me to find the issue. Delete 2nd line and use plain read.csv2. -- 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] RTAQ - convert function: warning causes incorrect loading of data
I'm forwarding this to the R-SIG-Finance list, where ou'll have a more specialized audience. In the meanwhile, you may wish to look at http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example Finally, I note you're posting from Nabble. Please do include context in your reply -- I don't believe Nabble does this automatically, so you'll need to manually include it. Most of the regular respondents on these lists don't use Nabble -- it is a _mailing list_ after all -- so we don't get the forum view you do, only emails of the individual posts. Combine that with the high volume of posts, and it's quite difficult to trace a discussion if we all don't make sure to include context. Cheers, Michael On Fri, Oct 12, 2012 at 7:01 PM, caprarn9 capra...@cs.man.ac.uk wrote: Hello, I am closely following the RTAQ documentation in order to load my dataset into R, however I get this warning when running the convert function in the following way: convert(from=2010-11-01, to=2010-11-01,datasource=datasource, datadestination=datadestination,trades=T,quotes=T,ticker=BAC,dir=T, extention=csv, header=T, tradecolnames=c(SYMBOL, DATE, TIME, PRICE, SIZE, G127, CORR, COND, EX), quotecolnames=c(SYMBOL, DATE, TIME, BID, OFR, BIDSIZ, OFRSIZ, MODE, EX)) The only warning returned is: In `[-.factor`(`*tmp*`, is.na(tdata$G127), value = c(1L, 1L, 1L, : invalid factor level, NAs generated As it is a warning, the .RData files still get created and I can use TAQLoad to load them: x - TAQLoad(BAC,from=2010-11-01,to=2010-11-01,datasource=datadestination, trades=T,quotes=T) The PROBLEM: head(x) SYMBOL EX PRICE SIZECOND CORR G127 NA BAC B 11.4900 500 @ 0 0 ... This is the same for the quotes objects, but different headers obviously. I get a NA instead of the expected YYY-MM-DD HH:MM:SS format for each observation. I've spent a fair number of hours on trying to get this right, no success. Can you please provide me with some guidance? Thank you. A sample from the CSV files I use: SYMBOL,DATE,TIME,BID,OFR,BIDSIZ,OFRSIZ,MODE,EX BAC,20101101,9:30:00,11.5,11.51,5,116,12,P ... SYMBOL,DATE,TIME,PRICE,SIZE,G127,CORR,COND,EX BAC,20101101,10:30:00,11.49,500,0,0,@,B ... -- View this message in context: http://r.789695.n4.nabble.com/RTAQ-convert-function-warning-causes-incorrect-loading-of-data-tp4646025.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] ifelse reformulation
You can use subscripting on the matrix, e.g. ind - test == 40 and the test[ind] - 1. Just deal with the id column when you set the rest to 0. -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On Behalf Of brunosm Sent: Friday 12 October 2012 11:51 To: r-help@r-project.org Subject: [R] ifelse reformulation Hi, i'm trying to simplify some R code but i got stucked in this: test-data.frame(cbind(id,x1,x2,x3,x4,x5,x6,x7)) test test id x1 x2 x3 x4 x5 x6 x7 1 1 36 26 21 32 31 27 31 2 2 45 21 46 50 22 36 29 3 3 49 47 35 44 33 31 46 4 4 42 32 38 28 39 45 32 5 5 29 42 39 48 25 35 34 6 6 39 31 30 37 46 43 44 7 7 41 40 25 23 42 40 24 8 8 27 29 47 34 26 38 28 9 9 25 35 29 36 43 34 23 10 10 24 44 37 26 27 46 22 11 11 38 50 32 49 37 24 40 12 12 20 34 48 25 30 41 36 13 13 26 46 20 40 29 20 43 14 14 33 37 49 31 47 30 30 15 15 43 39 27 35 48 47 27 count40- ifelse(test$x1==40|test$x2==40|test$x3==40|test$x4==40|test$x5==40|test $x6==40|test$x7==40,0,1) count40 I'm trying to remake that ifelse. If any variable from x1 to x7 equals to 40 -- 0, else -- 1 I was trying to do something like: count40aux-ifelse(test[,2:8]==40,0,1) count40aux It doesn't work as i expected... Can anyone help me please? Regards, Bruno -- View this message in context: http://r.789695.n4.nabble.com/ifelse- reformulation-tp4645981.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] characters, mathematical expressions and computed values
Thanks for the example. On Thu, Oct 11, 2012 at 7:24 PM, William Dunlap [via R] ml-node+s789695n4645934...@n4.nabble.com wrote: I think that bquote, with its .() operator, suffices for [almost?] any single title; don't bother fiddling with expression(), substitute(), or parse(). (You can make those work in many situations, but if you stick with just bquote then you can spend your time on the title itself.) E.g., hist(new, main=bquote(Heart Attack ( * bar(X)==.(mean(new)) * ))) or, if you want to limit the number of digits after the decimal point, hist(new, main=bquote(Heart Attack ( * bar(X)==.(round(mean(new),1)) * ))) Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com -Original Message- From: [hidden email]http://user/SendEmail.jtp?type=nodenode=4645934i=0[mailto:[hidden email] http://user/SendEmail.jtp?type=nodenode=4645934i=1] On Behalf Of 1Rnwb Sent: Thursday, October 11, 2012 2:32 PM To: [hidden email]http://user/SendEmail.jtp?type=nodenode=4645934i=2 Subject: [R] characters, mathematical expressions and computed values Hello, I have to add Age (bar(x)=14.3) as a title on a chart. I am unable to get this to working. I have tried bquote, substitute and expression, but they are only doing a part of the job. new- c(14.3, 18.5, 18.1, 17.7, 18, 15.9, 19.6, 17.3, 17.8, 17.5, 15.4, 16.3, 15, 17.1, 17.1, 16.4, 15.2, 16.7, 16.7, 16.9, 14.5, 16.6, 15.8, 15.2, 16.2, 15.6, 15, 17.1, 16.7, 15.6, 15, 15.8, 16.8, 17, 15.2, 15.8, 15.7, 14.7, 17.3, 14.9, 16.8, 14.6, 19.3, 15.3, 14.7, 13.3, 16.5, 16, 14.2, 16.1, 15.2, 13.4, 17.7, 15.5, 14.5, 15.7, 13.6, 14.1, 20, 17.2, 16.5, 14.3, 13.7, 14.7, 15.4, 13.6, 17, 17.3, 15.4, 15.5, 16.6, 15.8, 15.7, 14.7, 14.2, 14.2, 14, 14.2, 19.1, 17.2, 18.3, 13.9, 16, 15.9, 14.9, 14.6, 15.9, 12.2, 14.1, 12, 12.8, 17.1, 17, 15, 15.8, 15.9, 16.1, 18, 14.7, 18.9 ) hist(new, xlab='30-day Death Rate',xlim=c(7,22),main=expression(Heart Attack( * bar(X) * )= * mean(new))) I would appreciate any pointers on getting this correct. Thanks -- View this message in context: http://r.789695.n4.nabble.com/characters-mathematical- expressions-and-computed-values-tp4645916.html Sent from the R help mailing list archive at Nabble.com. __ [hidden email] http://user/SendEmail.jtp?type=nodenode=4645934i=3mailing 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] http://user/SendEmail.jtp?type=nodenode=4645934i=4mailing 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/characters-mathematical-expressions-and-computed-values-tp4645916p4645934.html To unsubscribe from characters, mathematical expressions and computed values, click herehttp://r.789695.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_codenode=4645916code=c2JwdXJvaGl0QGdtYWlsLmNvbXw0NjQ1OTE2fDU4ODg0MTYwOQ== . NAMLhttp://r.789695.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewerid=instant_html%21nabble%3Aemail.namlbase=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespacebreadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml -- View this message in context: http://r.789695.n4.nabble.com/characters-mathematical-expressions-and-computed-values-tp4645916p4646003.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.
Re: [R] average duplicated rows?
You will have to split() the data and unsplit() it after making the alterations. Have a look at the plyr package for such functions. -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On Behalf Of Vining, Kelly Sent: Friday 12 October 2012 5:42 To: r-help@r-project.org Subject: [R] average duplicated rows? Dear useRs, I have a slightly complicated data structure and am stuck trying to extract what I need. I'm pasting an example of this data below. In some cases, there are duplicates in the gene_id column because there are two different sample 1 values for a given sample 2 value. Where these duplicates exist, I need to average the corresponding FL_EARLY values and retain the FL_LATE value and replace those two rows with a row containing the FL_EARLY average so that I no longer have any gene_id duplicates. Seems like this is a job for some version of the apply function, but searching and puzzling over this has not gotten me anywhere. Any help will be much appreciated! Example data: gene_id sample_1 sample_2 FL_EARLY FL_LATE 763938 Eucgr.A00054 fl_S1E fl_S1L 13.170800 22.2605 763979 Eucgr.A00101 fl_S1E fl_S1L 0.367960 14.1202 1273243 Eucgr.A00101fl_S2 fl_S1L 0.356625 14.1202 764169 Eucgr.A00350 fl_S1E fl_S1L 7.381070 43.9275 1273433 Eucgr.A00350fl_S2 fl_S1L 10.674500 43.9275 1273669 Eucgr.A00650fl_S2 fl_S1L 33.669100 50.0169 764480 Eucgr.A00744 fl_S1E fl_S1L 132.429000 747.2770 1273744 Eucgr.A00744fl_S2 fl_S1L 142.659000 747.2770 764595 Eucgr.A00890 fl_S1E fl_S1L 2.937760 14.9647 764683 Eucgr.A00990 fl_S1E fl_S1L 8.681250 48.5492 1273947 Eucgr.A00990fl_S2 fl_S1L 10.553300 48.5492 764710 Eucgr.A01020 fl_S1E fl_S1L 0.00 57.9273 1273974 Eucgr.A01020fl_S2 fl_S1L 0.00 57.9273 764756 Eucgr.A01073 fl_S1E fl_S1L 8.504710 101.1870 1274020 Eucgr.A01073fl_S2 fl_S1L 5.400010 101.1870 764773 Eucgr.A01091 fl_S1E fl_S1L 3.448910 15.7756 764826 Eucgr.A01152 fl_S1E fl_S1L 69.565700 198.2320 764831 Eucgr.A01158 fl_S1E fl_S1L 7.265640 30.9565 764845 Eucgr.A01172 fl_S1E fl_S1L 3.248020 16.9127 764927 Eucgr.A01269 fl_S1E fl_S1L 18.710200 76.6918 --Kelly V. [[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] Pkg rgl: installation fails because of x11
In my case R was not built with X support, and I was also missing some openGL libraries. The info I needed was in the README inside the unzipped tarball for rgl. But rgl cleaned up after failing the install, and deleted the README, so I never new the README was there until I manually untarr'ed the tarball and looked inside it. (Error msg from install.packages(rgl) showed where the tarball was.) I needed to do the following: 1. Rebuild R with X support. Add --with-X to the configure line when building See app.B.1 Configuration Options of R Installation Admin manual ./configure --with-tcltk --with-system-zlib --with-system-bzlib --enable-R-shlib --with-x (note: might need --x-includes=DIR --x-libraries=DIR . Seemed to work without these for me, presumably because they are in the default location) make make check make install 2. Install missing openGL libraries (I'm on RHEL...use apt get on other systems): yum install mesa-libGL-devel mesa-libGLU-devel libpng-devel 3. Install rgl install.packages(rgl) HTH -- View this message in context: http://r.789695.n4.nabble.com/Pkg-rgl-installation-fails-because-of-x11-tp871465p4646017.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] performance analytics- package
Hi sheenmaria, Please reread my first post and try to do well any of what I asked of you. Cheers, Michael On Fri, Oct 12, 2012 at 6:13 AM, sheenmaria sheenmar...@gmail.com wrote: Thanks for your reply . And i have a doubt why cant get the result of chart.performanceSummary() with more than 40 row values in their with the input data?? View this message in context: http://r.789695.n4.nabble.com/performance- analytics-package-tp4645834.html -- View this message in context: http://r.789695.n4.nabble.com/performance-analytics-package-tp4645834p4645965.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-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] missing gcc-42-5666.3-darwin11.pkg
Hi there, I just wanted to install gfortran via homebrew on mac os x mountain lion. It uses the package gcc-42-5666.3-darwin11.pkg for installation. Unfortunately I recognized that this package is not available anymore. But the google cache told me that it was available at http://r.research.att.com/tools/gcc-42-5666.3-darwin11.pkg some time ago (the site was cached at Sep 30th). Does anybody know, if the package was removed? I also read that ATT got some downtime a couple of hours ago. Could this be the actual problem? Is there any chance to be able to download the package again? Finally, I don't know, if this is the right place for this question. Honestly this is my first mailing list I'm posting to since ever :) So, if I'm at the wrong place, be patient with me ;) Thanks in advance Torben __ 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 to read non-standard csv file
arun kirshna wrote Hi, Try this: tab1-read.csv2(Specimen_RawData_1.csv,sep=\t,nrows=-1) tab2-as.data.frame(sapply(tab1,function(x) gsub([,],.,x)),stringsAsFactors=FALSE) tab3-tab2[-1,] tab3[]-sapply(tab3,as.numeric) row.names(tab3)-1:nrow(tab3) head(tab3) # Carico.compressione Corsa.compressione Tempo Deformazione.in.compressione #1 0.166480.0 0.000 0.0 #2 0.166220.0 0.002 0.0 #3 0.165850.0 0.004 0.0 #4 3.961320.14063 0.104 0.01078 #520.677220.31937 0.204 0.02449 #639.880200.49078 0.304 0.03763 str(tab3) #'data.frame':81 obs. of 4 variables: # $ Carico.compressione : num 0.166 0.166 0.166 3.961 20.677 ... # $ Corsa.compressione : num 0 0 0 0.141 0.319 ... # $ Tempo : num 0 0.002 0.004 0.104 0.204 0.304 0.404 0.504 0.604 0.704 ... # $ Deformazione.in.compressione: num 0 0 0 0.0108 0.0245 ... A.K. Thank you very much. It work very well! Best, Roberto -- View this message in context: http://r.789695.n4.nabble.com/Problem-to-read-non-standard-csv-file-tp4646018p4646036.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] dotchart ordering problem
I'm having an sorting problem in dotchart. I want to change the order of the BA in groups to AB, but I haven't found any solution yet. What should I do? And what if I want to change the groups order as well? At the bottom from Conrol up to 10 mg/L on the top. Thank you! x = c(39, 23, 23, 35, 30, 26, 30, 30, 29, 29, 26, 29, 34, 33) y = c(Control, DMSO, 0,1 mg/L, 0,3 mg/L, 1 mg/L, 3 mg/L, 10 mg/L) a = matrix(data= x, nrow=2) rownames(a) = c(A,B); colnames(a) = y a dotchart(a, main=Dotchart, xlim=c(0,50)) http://r.789695.n4.nabble.com/file/n4646038/dotchart.jpg -- View this message in context: http://r.789695.n4.nabble.com/dotchart-ordering-problem-tp4646038.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] missing gcc-42-5666.3-darwin11.pkg
On Fri, Oct 12, 2012 at 5:50 PM, Torben Griebe torbengri...@gmx.de wrote: Hi there, I just wanted to install gfortran via homebrew on mac os x mountain lion. It uses the package gcc-42-5666.3-darwin11.pkg for installation. Unfortunately I recognized that this package is not available anymore. But the google cache told me that it was available at http://r.research.att.com/tools/gcc-42-5666.3-darwin11.pkg some time ago (the site was cached at Sep 30th). Does anybody know, if the package was removed? I also read that ATT got some downtime a couple of hours ago. Could this be the actual problem? Is there any chance to be able to download the package again? Finally, I don't know, if this is the right place for this question. Honestly this is my first mailing list I'm posting to since ever :) So, if I'm at the wrong place, be patient with me ;) Fair question here, but in this case, I'll actually forward it along to the R-SIG-Mac list. There are R-SIG groups for Debian, Mac, and Fedora, though not Windows, just for future reference. You'd probably be able to get a good answer if we kept it here, but Simon Urbanek takes care of the R-SIG-Mac and he's the official Mac Guy for all things R and maintainer of the r.research.att.com site so he'll have the definitive word. Michael Thanks in advance Torben __ 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] dotchart ordering problem
Hi, You can reorder the matrix: dotchart(a[c(2,1), 7:1], main=Dotchart, xlim=c(0,50)) Sarah On Fri, Oct 12, 2012 at 4:38 PM, Zenonn87 zsolt.tar...@hotmail.com wrote: I'm having an sorting problem in dotchart. I want to change the order of the BA in groups to AB, but I haven't found any solution yet. What should I do? And what if I want to change the groups order as well? At the bottom from Conrol up to 10 mg/L on the top. Thank you! x = c(39, 23, 23, 35, 30, 26, 30, 30, 29, 29, 26, 29, 34, 33) y = c(Control, DMSO, 0,1 mg/L, 0,3 mg/L, 1 mg/L, 3 mg/L, 10 mg/L) a = matrix(data= x, nrow=2) rownames(a) = c(A,B); colnames(a) = y a dotchart(a, main=Dotchart, xlim=c(0,50)) http://r.789695.n4.nabble.com/file/n4646038/dotchart.jpg -- Sarah Goslee http://www.functionaldiversity.org __ 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] dotchart ordering problem
Reorder the rows and/or columns of your matrix: e.g. dotchart(a[2:1,7:1], main=Dotchart, xlim=c(0,50)) -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Zenonn87 Sent: Friday, October 12, 2012 23:39 To: r-help@r-project.org Subject: [R] dotchart ordering problem I'm having an sorting problem in dotchart. I want to change the order of the BA in groups to AB, but I haven't found any solution yet. What should I do? And what if I want to change the groups order as well? At the bottom from Conrol up to 10 mg/L on the top. Thank you! x = c(39, 23, 23, 35, 30, 26, 30, 30, 29, 29, 26, 29, 34, 33) y = c(Control, DMSO, 0,1 mg/L, 0,3 mg/L, 1 mg/L, 3 mg/L, 10 mg/L) a = matrix(data= x, nrow=2) rownames(a) = c(A,B); colnames(a) = y a dotchart(a, main=Dotchart, xlim=c(0,50)) http://r.789695.n4.nabble.com/file/n4646038/dotchart.jpg -- View this message in context: http://r.789695.n4.nabble.com/dotchart- ordering-problem-tp4646038.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] Columns and rows
This should also work: Using the dat1 data frame that arun created: #1 dat2 - t(dat1[,2:4]) dim(dat2) - prod(dim(dat2)) dat2 - data.frame(Col1=dat2, stringsAsFactors=FALSE) dat2 Col1 1 A 2 E 3 H 4 B 5 F 6 I 7 C 8 G 9 J 10D 11K 12 #2 dat3 - as.matrix(dat1[, 2:4]) dim(dat3) - prod(dim(dat3)) dat3 - data.frame(Col1=dat3, stringsAsFactors=FALSE) dat3 Col1 1 A 2 B 3 C 4 D 5 E 6 F 7 G 8 K 9 H 10I 11J 12 #3 d4 - data.frame(t(dat2), stringsAsFactors=FALSE) d4 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 Col1 A E H B F I C G J D K -- 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 arun Sent: Thursday, October 11, 2012 11:26 PM To: Santana Sarma Cc: R help Subject: Re: [R] Columns and rows HI, Try this: dat1-read.table(text= Names Colx Coly Colz rowName1 A E H rowName2 B F I rowName3 C G J rowName4 D K ,sep=,header=TRUE,stringsAsFactors=FALSE,fill=TRUE) dat2-t(dat1) dat3-dat2[2:4,] dat4-do.call(rbind,sapply(dat3,list))) row.names(dat4)-1:nrow(dat4) dat4 dat4 # [,1] #1 A #2 E #3 H #4 B #5 F #6 I #7 C #8 G #9 J #10 D #11 K #12 data.frame(col1=stack(dat1[,2:4])[,1]) # col1 #1 A #2 B #3 C #4 D #5 E #6 F #7 G #8 K #9 H #10 I #11 J #12 dat5-do.call(data.frame,sapply(dat3,list)) dat5 # A E H B F I C G J D K X.. #1 A E H B F I C G J D K A.K. - Original Message - From: Santana Sarma aimanusa...@gmail.com To: David Winsemius dwinsem...@comcast.net Cc: r-help@r-project.org Sent: Thursday, October 11, 2012 11:07 PM Subject: Re: [R] Columns and rows Hi, Trying to give an example here. Say, I have read in a .csv file using read.csv (), and the file contains the following info. Names Col x Col y Col z rowName1 A E H rowName2 B F I rowName3 C G J rowName4 D K Now, this is what is required: 1. Combine/stack/join contents from - a) multiple rows into one column. That is: A E H B F I C G J D K b) multiple columns into one row. A B C D E F G H I J K 2. Stack contents from A) multiple columns into one column. A B C D E F G H I J K B) Multiple rows into one row. A E H B F I C G J D Thank you. Cheers, Santana On Fri, Oct 12, 2012 at 1:32 PM, David Winsemius dwinsem...@comcast.netwrote: On Oct 11, 2012, at 5:55 PM, Santana Sarma wrote: Hi, Could you please advice some easy way to do the following for a dataframe (header=F) having unequal column- row- length. 1. Combine/stack/join contents from - a) multiple rows into one column. b) multiple columns into one row. 2. Stack contents from multiple columns (or, rows) into one column (or, row). Could _you_ please produce an example. Dataframes do not have headers. They do have column names and column names are required. -- David Winsemius, MD Alameda, CA, USA [[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.
Re: [R] dotchart ordering problem
HI, Try this: Hi, Try this: #For your first question: dotchart(a[rev(order(rownames(a))),],main=Dotchart,xlim=c(0,50)) #For your second question: dotchart(a[rev(order(rownames(a))),rev(1:ncol(a))],main=Dotchart,xlim=c(0,50)) A.K. - Original Message - From: Zenonn87 zsolt.tar...@hotmail.com To: r-help@r-project.org Cc: Sent: Friday, October 12, 2012 4:38 PM Subject: [R] dotchart ordering problem I'm having an sorting problem in dotchart. I want to change the order of the BA in groups to AB, but I haven't found any solution yet. What should I do? And what if I want to change the groups order as well? At the bottom from Conrol up to 10 mg/L on the top. Thank you! x = c(39, 23, 23, 35, 30, 26, 30, 30, 29, 29, 26, 29, 34, 33) y = c(Control, DMSO, 0,1 mg/L, 0,3 mg/L, 1 mg/L, 3 mg/L, 10 mg/L) a = matrix(data= x, nrow=2) rownames(a) = c(A,B); colnames(a) = y a dotchart(a, main=Dotchart, xlim=c(0,50)) http://r.789695.n4.nabble.com/file/n4646038/dotchart.jpg -- View this message in context: http://r.789695.n4.nabble.com/dotchart-ordering-problem-tp4646038.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] goodness of fit for logistic regression with survey package
I am making exploratory analyses on a complex survey data by using survey package. Could you help me how to see the goodness of fit for the model below? Should I use AIC, BIC, ROC, or what? What code would let me run a goodness of fit test for the model? Here are my codes: #incorporating design effects# mydesign - svydesign(id=~clust, strata=~strat, weights=~sweight, data=mydata) #logistic regression model# model1 - svyglm(y ~ x1 + x2+ x3 + x4 + x5, design = mydesign, data=(mydata),family=quasibinomial()) #I tried loglik function, but didn't work# logLik(model1) [1] 8753.057 Warning message: In logLik.svyglm(model1) : svyglm not fitted by maximum likelihood. #I did the following which didn't work either# with(model1, null.deviance - deviance) [1] 1039.695 with(model2, df.null - df.residual) [1] 6565 with(model2, pchisq(null.deviance - deviance, df.null - df.residual, + lower.tail = FALSE)) [1] 1 -- View this message in context: http://r.789695.n4.nabble.com/goodness-of-fit-for-logistic-regression-with-survey-package-tp4646044.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] R not finding function in installed pscl package
Hi, This may be such a general question that my searches are just failing. I installed the pscl lib, all appears fine, installed it several different ways to be sure, but I am getting: Error: could not find function zeroinfl I double checked my spelling of the function and that it had not been evolved out of the package. It is in the same location as the other libraries that are located and running just fine. I have successfully added and used many libs, any ideas (1) how this might be happening and, if it's not apparent from the answer to #1 (2) a solution to point to it? Thanks! -- View this message in context: http://r.789695.n4.nabble.com/R-not-finding-function-in-installed-pscl-package-tp4646053.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] RMySQL install on windows
On 10/10/2012 12:58 PM, Greg Snow wrote: I finally was able to compile/load it under windows 7. I had similar problems to what you show below. I set the MYSQL_HOME environmental variable through windows (start button control panel System and Security system Advanced System Settings Environmental variables). I had to set it to the version of the path without spaces, in my case it was: c:\PROGRA~1\MySQL\MYSQLS~1.5 Then I opened a command prompt window, changed to the directory where I had downloaded the tar.gz file from cran and entered the command: c:\Program Files\R\R-2.15.1\bin\x64\R CMD INSTALL RMySQL_0.9-3.tar.gz and everything worked (it did not work if I used i386 or just the regular bin folder, possibly due to the version of MySQL I downloaded). Then I started a new instance of R and did library(MySQL) and everything loaded and I was able to connect to a local MySQL database. Hope this helps you as well. Thanks, Greg. I got a couple of warnings during the build, but I can at least load the library. Now, I'll to to learn to use itG I had downloaded the 64-bit MySQL engine. The seemingly successful install was on R (64-bit). I guess not unexpectedly I get the from R (i386) library(RMySQL) Error: package ‘RMySQL’ is not installed for 'arch=i386' Appreciate the guidance. Rob __ 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] Autofilling a large matrix in R
I think the issue is that the with expand.grid and times = 4 you are likely to run out of memory before subscripting (at least on my machine). A simplification is to realize that you are looking for points in a lattice in the interior of a (p - 1)-dimensional simplex for p columns/factors/groups. As a start the xsimplex() function in the combinat package generates all the points in such a simplex which sums to a specific value (and nsimplex() calculates the number). If you then still want to remove the instances on the edges of the simplex (where one of the percentages is 0), at least you have a more memory efficient base within which to search. For p = 4 then you will start with require(combinat) nsimplex(4,100) [1] 176851 candidate points instead of 100^4 [1] 1e+08 points. As an example, to generate all combinations for 4 factors excluding any 0's, you could do mat - xsimplex(4,100) ncol(mat) [1] 176851 print(object.size(mat),unit=Mb) 5.4 Mb mat - mat[,apply(mat,2,function(x)!any(x==0))] ncol(mat) [1] 156849 Of course the curse of dimensionality will still get you as the number of factors increases. E.g. mat - xsimplex(5,100) ncol(mat) [1] 4598125 print(object.size(mat),unit=Mb) 175.4 Mb which is still manageable (but for p = 6 your lattice has nearly 100 million points). Perhaps you can modify the code of xsimplex to automatically discard zeros. -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Rui Barradas Sent: Friday, October 12, 2012 18:04 To: wwreith Cc: r-help@r-project.org Subject: Re: [R] Autofilling a large matrix in R Hello, Something like this? g[rowSums(g) == 100, ] Hope this helps, Rui Barradas Em 12-10-2012 15:30, wwreith escreveu: I wish to create a matrix of all possible percentages with two decimal place percision. I then want each row to sum to 100%. I started with the code below with the intent to then subset the data based on the row sum. This works great for 2 or 3 columns, but if I try 4 or more columns the number of rows become to large. I would like to find a way to break it down into some kind of for loop, so that I can remove the rows that don't sum to 100% inside the for loop rather than outside it. My first thought was to take list from 1:10, 11:20, etc. but that does not get all of the points. g-as.matrix(expand.grid(rep(list(1:100), times=3))) Any thoughts how to split this into pieces? -- View this message in context: http://r.789695.n4.nabble.com/Autofilling-a-large-matrix-in-R-tp464599 1.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-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 not finding function in installed pscl package
nprause Nicole.Prause at gmail.com writes: This may be such a general question that my searches are just failing. I installed the pscl lib, all appears fine, installed it several different ways to be sure, but I am getting: Error: could not find function zeroinfl I double checked my spelling of the function and that it had not been evolved out of the package. It is in the same location as the other libraries that are located and running just fine. I believe this is R FAQ 7.30: 7.30 I installed a package but the functions are not there To actually use the package, it needs to be loaded using library(). __ 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] average duplicated rows?
HI, My earlier solutions averaged FL_EARLY values for duplicated gene_ids so that the resultant dataframe had unique rows. But, if you want to keep the duplicated rows with average values, you can also try this: dat$FL_EARLY-unlist(lapply(lapply(split(dat,dat$gene_id),`[`,4),function(x) rep(colMeans(x),each=nrow(x))),use.names=F) head(dat) # gene_id sample_1 sample_2 FL_EARLY FL_LATE #763938 Eucgr.A00054 fl_S1E fl_S1L 13.1708000 22.2605 #763979 Eucgr.A00101 fl_S1E fl_S1L 0.3622925 14.1202 #1273243 Eucgr.A00101 fl_S2 fl_S1L 0.3622925 14.1202 #764169 Eucgr.A00350 fl_S1E fl_S1L 9.0277850 43.9275 #1273433 Eucgr.A00350 fl_S2 fl_S1L 9.0277850 43.9275 #1273669 Eucgr.A00650 fl_S2 fl_S1L 33.6691000 50.0169 A.K. - Original Message - From: Rui Barradas ruipbarra...@sapo.pt To: Vining, Kelly kelly.vin...@oregonstate.edu Cc: r-help@r-project.org r-help@r-project.org Sent: Friday, October 12, 2012 1:10 PM Subject: Re: [R] average duplicated rows? Hello, It could be a job for tapply, but I find it more suited for ?ave. dat - read.table(text = gene_id sample_1 sample_2 FL_EARLY FL_LATE 763938 Eucgr.A00054 fl_S1E fl_S1L 13.170800 22.2605 763979 Eucgr.A00101 fl_S1E fl_S1L 0.367960 14.1202 1273243 Eucgr.A00101 fl_S2 fl_S1L 0.356625 14.1202 764169 Eucgr.A00350 fl_S1E fl_S1L 7.381070 43.9275 1273433 Eucgr.A00350 fl_S2 fl_S1L 10.674500 43.9275 1273669 Eucgr.A00650 fl_S2 fl_S1L 33.669100 50.0169 764480 Eucgr.A00744 fl_S1E fl_S1L 132.429000 747.2770 1273744 Eucgr.A00744 fl_S2 fl_S1L 142.659000 747.2770 764595 Eucgr.A00890 fl_S1E fl_S1L 2.937760 14.9647 764683 Eucgr.A00990 fl_S1E fl_S1L 8.681250 48.5492 1273947 Eucgr.A00990 fl_S2 fl_S1L 10.553300 48.5492 764710 Eucgr.A01020 fl_S1E fl_S1L 0.00 57.9273 1273974 Eucgr.A01020 fl_S2 fl_S1L 0.00 57.9273 764756 Eucgr.A01073 fl_S1E fl_S1L 8.504710 101.1870 1274020 Eucgr.A01073 fl_S2 fl_S1L 5.400010 101.1870 764773 Eucgr.A01091 fl_S1E fl_S1L 3.448910 15.7756 764826 Eucgr.A01152 fl_S1E fl_S1L 69.565700 198.2320 764831 Eucgr.A01158 fl_S1E fl_S1L 7.265640 30.9565 764845 Eucgr.A01172 fl_S1E fl_S1L 3.248020 16.9127 764927 Eucgr.A01269 fl_S1E fl_S1L 18.710200 76.6918 , header = TRUE) av - ave(dat$FL_EARLY, dat$gene_id) dat$FLY_EARLY - av Hope this helps, Rui Barradas Em 12-10-2012 16:41, Vining, Kelly escreveu: Dear useRs, I have a slightly complicated data structure and am stuck trying to extract what I need. I'm pasting an example of this data below. In some cases, there are duplicates in the gene_id column because there are two different sample 1 values for a given sample 2 value. Where these duplicates exist, I need to average the corresponding FL_EARLY values and retain the FL_LATE value and replace those two rows with a row containing the FL_EARLY average so that I no longer have any gene_id duplicates. Seems like this is a job for some version of the apply function, but searching and puzzling over this has not gotten me anywhere. Any help will be much appreciated! Example data: gene_id sample_1 sample_2 FL_EARLY FL_LATE 763938 Eucgr.A00054 fl_S1E fl_S1L 13.170800 22.2605 763979 Eucgr.A00101 fl_S1E fl_S1L 0.367960 14.1202 1273243 Eucgr.A00101 fl_S2 fl_S1L 0.356625 14.1202 764169 Eucgr.A00350 fl_S1E fl_S1L 7.381070 43.9275 1273433 Eucgr.A00350 fl_S2 fl_S1L 10.674500 43.9275 1273669 Eucgr.A00650 fl_S2 fl_S1L 33.669100 50.0169 764480 Eucgr.A00744 fl_S1E fl_S1L 132.429000 747.2770 1273744 Eucgr.A00744 fl_S2 fl_S1L 142.659000 747.2770 764595 Eucgr.A00890 fl_S1E fl_S1L 2.937760 14.9647 764683 Eucgr.A00990 fl_S1E fl_S1L 8.681250 48.5492 1273947 Eucgr.A00990 fl_S2 fl_S1L 10.553300 48.5492 764710 Eucgr.A01020 fl_S1E fl_S1L 0.00 57.9273 1273974 Eucgr.A01020 fl_S2 fl_S1L 0.00 57.9273 764756 Eucgr.A01073 fl_S1E fl_S1L 8.504710 101.1870 1274020 Eucgr.A01073 fl_S2 fl_S1L 5.400010 101.1870 764773 Eucgr.A01091 fl_S1E fl_S1L 3.448910 15.7756 764826 Eucgr.A01152 fl_S1E fl_S1L 69.565700 198.2320 764831 Eucgr.A01158 fl_S1E fl_S1L 7.265640 30.9565 764845 Eucgr.A01172 fl_S1E fl_S1L 3.248020 16.9127 764927 Eucgr.A01269 fl_S1E fl_S1L 18.710200 76.6918 --Kelly V. [[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
[R] RS-MySQL.h:32:19: fatal error: mysql.h: No such file or directory
i m installing RMySQL under windows -7 64bit, i have wamp server(which has mysql5.5.16) i have given MYSQL_HOME path in environment variable as MYSQL_HOME=C:\wamp\bin\mysql\mysql5.5.16\bin , also create Renviron.site file in C:\Program Files\R\R-2.15.0\etc giving MYSQL_HOME=C:/wamp/bin/mysql/mysql5.5.16/bin as path i install c connector MySQL Connector C 6.0.2 version also, which has mysql.h file Question:- In which folder should I include mysql.h file ? i dont know how to put mysql.h in RMySQL_0.9-3.tar.gz f, if yes how can i do it ? install.packages(RMySQL,type=source) Installing package(s) into ‘C:/Users/trendwise/Documents/R/win-library/2.15’ (as ‘lib’ is unspecified) trying URL 'http://ftp.iitm.ac.in/cran/src/contrib/RMySQL_0.9-3.tar.gz' Content type 'application/x-gzip' length 165363 bytes (161 Kb) opened URL downloaded 161 Kb * installing *source* package 'RMySQL' ... ** package 'RMySQL' successfully unpacked and MD5 sums checked checking for $MYSQL_HOME... C:\wamp\bin\mysql\mysql5.5.16\bin cygwin warning: MS-DOS style path detected: C:\wamp\bin\mysql\mysql5.5.16\bin Preferred POSIX equivalent is: /cygdrive/c/wamp/bin/mysql/mysql5.5.16/bin CYGWIN environment variable option nodosfilewarning turns off this warning. Consult the user's guide for more details about POSIX paths: http://cygwin.com/cygwin-ug-net/using.html#using-pathnames ** libs Warning: this package has a non-empty 'configure.win' file, so building only the main architecture cygwin warning: MS-DOS style path detected: C:/PROGRA~1/R/R-215~1.0/etc/x64/Makeconf Preferred POSIX equivalent is: /cygdrive/c/PROGRA~1/R/R-215~1.0/etc/x64/Makeconf CYGWIN environment variable option nodosfilewarning turns off this warning. Consult the user's guide for more details about POSIX paths: http://cygwin.com/cygwin-ug-net/using.html#using-pathnames gcc -m64 -IC:/PROGRA~1/R/R-215~1.0/include -DNDEBUG -IC:\wamp\bin\mysql\mysql5.5.16\bin/include -Id:/RCompile/CRANpkg/extralibs64/local/include -O2 -Wall -std=gnu99 -mtune=core2 -c RS-DBI.c -o RS-DBI.o RS-DBI.c: In function 'RS_na_set': RS-DBI.c:1219:11: warning: variable 'c' set but not used [-Wunused-but-set-variable] gcc -m64 -IC:/PROGRA~1/R/R-215~1.0/include -DNDEBUG -IC:\wamp\bin\mysql\mysql5.5.16\bin/include -Id:/RCompile/CRANpkg/extralibs64/local/include -O2 -Wall -std=gnu99 -mtune=core2 -c RS-MySQL.c -o RS-MySQL.o In file included from RS-MySQL.c:22:0: RS-MySQL.h:32:19: fatal error: mysql.h: No such file or directory compilation terminated. make: *** [RS-MySQL.o] Error 1 ERROR: compilation failed for package 'RMySQL' * removing 'C:/Users/trendwise/Documents/R/win-library/2.15/RMySQL' * restoring previous 'C:/Users/trendwise/Documents/R/win-library/2.15/RMySQL' Warning in install.packages : running command 'C:/PROGRA~1/R/R-215~1.0/bin/x64/R CMD INSTALL -l C:/Users/trendwise/Documents/R/win-library/2.15 C:\Users\TRENDW~1\AppData\Local\Temp\RtmpshWgve/downloaded_packages/RMySQL_0.9-3.tar.gz' had status 1 Warning in install.packages : installation of package ‘RMySQL’ had non-zero exit status - Sagar Nikam B.Pharm, M.Sc(Bioinformatics) Software Engineer (Data Research Analyst ) Trendwise Analytics,Bangalore India -- View this message in context: http://r.789695.n4.nabble.com/RS-MySQL-h-32-19-fatal-error-mysql-h-No-such-file-or-directory-tp4646060.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] DCC help
hi all, i am using a dcc model for my senior thesis, it looks at stock returns during times of market uncertainty. my current rfile is below. library(SparseM) library(quantreg) library(zoo) library(nortest) library(MASS) library(fEcofin) library(mvtnorm) library(ccgarch) library(stats) library(foreign) #dataset-read.csv(file=,header=FALSE) attach(dataset); vardata=data.frame(dataset[,2],dataset[,4]) ### DCC ### #initial values a1 - c(0.003, 0.001, 0.001) A1 - diag(c(0.1,0.1,0.1)) B1 - diag(c(0.1, 0.1, 0.1)) dcc.para - c(0.01,0.98) # Estimating a DCC-GARCH(1,1) model dcc.results - dcc.estimation(inia=a, iniA=A, iniB=B, ini.dcc=dcc.para, dvar=vardata, model=diagonal) # Parameter estimates and their robust standard errors dcc.results$out DCC_corr-dcc.results$DCC[,2] plot(DCC_corr) this gives me the output results and a plot. the questions i have are 1. how do i get a plot with lines instead of dots 2. in my file i have two types of dummy variables - the first are quantiles where it is 1 if stock returns are in the lowest 5% quantile and the second dummy variable are specific events in the world economy where it is 1 if the stock return for that day happens to lie within the date range i specified for each event. i have fun the dcc without my dummy variables, but how can i incorporate my dummies into my results as i cannot find a user guide to help me any help would be greatly appreciated! thank you all! -- View this message in context: http://r.789695.n4.nabble.com/DCC-help-tp4646061.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.