Re: [R] Confidence intervals for Sen slope in zyp-package
On 11/07/2012 12:31 AM, kun...@gfz-potsdam.de wrote: Hi, I have a question about the computation of confidence intervals in the zyp package, in particular using the functions zyp.sen and confint.zyp, or zyp.yuepilon. (1) I'm a bit confused about the confidence intervals given by zyp.sen and confint.zyp. When I request a certain confidence interval in the function, the R output seems to deliver another confidence interval, e.g. when I set level=0.95 in the function, then the output is for 0.025 and 0.975 (instead of the expected 0.05 and 0.95). See example below. Which confint statement is the right one? (2) I checked the documentation but did not find a specification about which confidence interval is used in the zyp.yuepilon function. It seems to be the same as level=0.95 in confint.zyp (I'm not sure if this is 0.95 or 0.975 - see above). Maybe, I'm just not seeing the obvious explanation... Could anybody advise me? Thanks in advance, Katy --- My example: x- c(0, 1, 2, 3, 4, 5) y- c(6, 4, 1, 8, 7, 8) # zyp.sen and confint.zyp function slope- zyp.sen(y~x) slope$coef Intercept x 4.500 0.667 ci_99- confint.zyp(slope, level=0.99) ci_99 0.0050.995 Intercept -2.071288 10.07129 x -3.00 3.0 ci_95- confint.zyp(slope, level=0.95) ci_95 0.0250.975 Intercept -0.6196794 8.619679 x -2.500 2.33 ci_90- confint.zyp(slope, level=0.90) ci_90 0.05 0.95 Intercept 0.1230428 7.876957 x -2.000 2.00 # zyp.yuepilon # confidence interval corresponds to nominal 0.95 interval in confint.zyp (output 0.025 0.975) xy_senslope- zyp.yuepilon (y, conf.intervals=TRUE) xy_senslope lbound trend trendp ubound tau sig nruns autocor valid_frac -2.5000 0.6667 4. 2. 0.8001 0.08641075 1. -0.2240 1. linear intercept 0.74285714 3.8333 Hi Katy, I didn't see an answer to this, so I'll attempt one. A 95% confidence interval is defined as an interval within which 95% of replicated values will fall. In most cases, the preferred confidence interval among the many which could be calculated is symmetric about the observed value in the sense that half of the replicated values are expected to fall above the observed value and half below. This means that 2.5% of replications would be expected to produce values below the lower confidence limit and 2.5% above the upper one. If these proportions were 5% below and 5% above, you would get a 90% confidence interval. Jim __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] change colour of geom_step by scale_colour_manual
Hi, Color of my step plot is now by default. Now I'd like to change the color as the grey scale I specified. I don't know why I got three black plot. Here I attach two version of codes. The first one produces a step plot with color by default. The second one, modified from the first one, is not producing the grey scale I want. Any help would be highly appreciated. [version 1- working] library(ggplot2) ggplot(qry_r3_AFF0_CumRate_pooled[qry_r3_AFF0_CumRate_pooled$trt_label %in% c('ace','ctrlAM','met'),] , aes(x=AFF0, y=cum_rate_AFF0_pooled, group=trt_label))+ geom_step(aes(color=trt_label), direction=hv, size=5.0)+ scale_y_continuous(Rates of initiating first orientation flight, limits=c(0,0.6), expand=c(0,0), breaks=c(0,0.2,0.4,0.6)) + scale_x_continuous(Age of adults (days), limits=c(0,16), expand=c(0,0), breaks=c(5, 10, 15)) + scale_colour_discrete(name =Group, breaks=c(ace, ctrlAM,met), labels=c(acetone, untreated,methoprene))+ theme_bw() + # maek background theme black and white opts(legend.justification=c(1,0),# legend justification needs to be in the (options) legend.position=c(1,0), panel.grid.major = theme_line(size = 0.5, colour = '#FF'), panel.grid.minor = theme_line(colour = NA) # colour = NA to suppress gridlines, reappear if colour='black' ) http://r.789695.n4.nabble.com/file/n4648669/step_plot_in_default_color.png [version 2- producing wrong colour] #try greyScale, didn't work all -qry_r3_AFF0_CumRate_pooled all - subset(all, trt_label %in% c('ace','ctrlAM','met')) greyScale -c(grey15,grey30,grey45) ggplot(all, aes(x=AFF0, y=cum_rate_AFF0_pooled, group=trt_label))+ geom_step(direction=hv, size=3.0)+ scale_y_continuous(Rates of initiating first orientation flight, limits=c(0,0.6), expand=c(0,0), breaks=c(0,0.2,0.4,0.6)) + scale_x_continuous(Age of adults (days), limits=c(0,16), expand=c(0,0), breaks=c(5, 10, 15)) + scale_colour_manual(name=Group, breaks=c('ace', 'ctrlAM','met'), labels=c(acetone, untreated,methoprene), values=c(black,grey,red)) theme_bw() + # maek background theme black and white theme(legend.justification=c(1,0),# legend justification needs to be in the (options) legend.position=c(1,0), panel.grid.major = theme_line(size = 0.5, colour = '#FF'), panel.grid.minor = theme_line(colour = NA) # colour = NA to suppress gridlines, reappear if colour='black' ) http://r.789695.n4.nabble.com/file/n4648669/step_plot_not_showing_grey_scale_colour.png -- View this message in context: http://r.789695.n4.nabble.com/change-colour-of-geom-step-by-scale-colour-manual-tp4648669.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] LMER vs PROC MIXED estimates
Hi David, Thanks for the reply. sorry for typo in the R script ...what I meant to write was testdata - read.csv(adstest.csv,header=TRUE,sep=,) attach(testdata) library(lme4) options(contrasts = c(factor = contr.SAS,ordered = contr.poly)) lmm.2=lmer(y~X1+X2+X3 + (X2|Geography),REML=TRUE,data=testdata) not sure if attaching the dataset causes any problem. Also, I would take your suggestion and post this in Mixed Models SIG. Regards, Sandip -- View this message in context: http://r.789695.n4.nabble.com/LMER-vs-PROC-MIXED-estimates-tp4648653p4648671.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] a simple list question
On Nov 7, 2012, at 6:07 AM, Rolf Turner rolf.tur...@xtra.co.nz wrote: On 07/11/12 18:35, Erin Hodgess wrote: Dear R People I have a simple list question, please: I have vectors x.1, x.2,...x.n (each of different lengths) and I would like to combine them into a list. However, I'm sure that there is a better way to do this than to type in x - list(x.1,x.2,x.3,...) Is there a better way to do this, please? I was thinking about possibly using grep? If I understand your question correctly --- always a dubious assumption --- you could do: n - however many vectors you have xlist - lapply(1:n,function(n){get(paste(x,n,sep=.))}) Does that accomplish your goal? cheers, Rolf Perhaps an hair shorter with mget() Michael __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] LMER vs PROC MIXED estimates
On Nov 6, 2012, at 11:38 PM, sandip1006 wrote: Hi David, Thanks for the reply. sorry for typo in the R script ...what I meant to write was testdata - read.csv(adstest.csv,header=TRUE,sep=,) attach(testdata) library(lme4) options(contrasts = c(factor = contr.SAS,ordered = contr.poly)) lmm.2=lmer(y~X1+X2+X3 + (X2|Geography),REML=TRUE,data=testdata) not sure if attaching the dataset causes any problem. I'm not _sure_ either, but I would definitely advise detach()-ing it. You should not need to attach when you are also passing testdata to the data argument. Also, I would take your suggestion and post this in Mixed Models SIG. Regards, Sandip -- View this message in context: http://r.789695.n4.nabble.com/LMER-vs-PROC-MIXED-estimates-tp4648653p4648671.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. 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] matrix.csr %*% matrix -- matrix
Sam == Sam Steingold s...@gnu.org on Tue, 6 Nov 2012 13:08:30 -0500 writes: Sam The question is even more pressing for me now given that I no longer can Sam convert some csr matrices to the regular ones for scaling. Sam (http://article.gmane.org/gmane.comp.lang.r.general:279305) Sam Any suggestions? (the original csr matrix is too large to be converted Sam to a regular one, but the product is small enough). * Sam Steingold f...@tah.bet [2012-08-27 14:58:47 -0400]: When a sparse matrix is multiplied by a regular one, the result is usually not sparse. However, when matrix.csr is multiplied by a regular matrix in R, a matrix.csr is produced. Is there a way to avoid this? Thanks! Why don't you use the sparse matrix classes from the Matrix package .. which is part of every R distribution ? SparseM has been written as very first package to support sparse matrices, and is to be applauded for that, but it does lack many features nowadays (and also uses less modern algorithm for e.g. the sparse Cholesky decomposition). Martin Maechler the (biased!) Co-author of the Matrix package. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Plot in function
On 11/07/2012 03:44 AM, Pauli wrote: Hello, I am a R beginner and I have a question about a litte function I found. Here is the code: # Gambler's Ruin Problem. # seed capital:k # rounds: n # probability of success: p # number of trials: N # graphical output (yes/no): draw # Wait for new graphic (yes/no): ask ruin- function( N = 1, n = 10, k = 1, p = 1 / 2, draw = FALSE, ask = FALSE ){ if(draw) par( ask = ask ) r- 0 for( i in 1:N ){ x- k + cumsum (sample( c(-1, 1),replace = TRUE, n,prob = c(1-p, p))) if( min(x)= 0 ){ r- r + 1 if(draw) ruin.plot( k, x, col = red,main = paste(i, th trial: ruin! ) ) } else if(draw) ruin.plot( k, x, main = paste( i, th trial: no ruin ),ylim = c( 0, max(x) ) ) } return(r / N) } Now I want to start it with for example ruin(N=100,n=1000,k=50,draw=TRUE,ask=TRUE) but i received the message, that there is an unused argument: (col = red,main = paste(i, th trial: ruin! ) ). What is wrong with the code? Hi Pauli, Since you received the unused argument error message, you may have defined the ruin.plot function somewhere without the col= argument. I tried changing the call to ruin.plot to simply plot, but your k and x values are of different lengths, so they won't plot anyway. I think what you may be trying to achieve is more like this: ruin-function( N = 1, n = 10, k = 1, p = 1 / 2, draw = FALSE, ask = FALSE ){ if(draw) par( ask = ask ) r - 0 plot(0,xlim=c(0,N),ylim=c(-20,k),type=n,main=Gambler's Ruin plot) for( i in 1:N ){ x - k + cumsum (sample( c(-1, 1),replace = TRUE, n,prob = c(1-p, p))) if( min(x) = 0 ) { r - r + 1 if(draw) { points(i, x[which.min(x)], col = red ) text(i,x[which.min(x)]-2,ruin!) } } else if(draw) points(i, x[which.min(x)], col=green) } return(r / N) } ruin(N=100,n=1000,k=50,draw=TRUE,ask=TRUE) Jim __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 + Hadoop on Amazon
Hello All, Having some issue with local machine, I need to locate myself on Amazon for running R and Hadoop with Amazon instance. After searching a lot, I can't able to take a decision for choosing Image for Amazon instance. Can any one using R + Hadoop on Amazon. Thanks [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] a simple list question
Hello, Try the following. x.1 - 1:3 y.1 - 1:4 x.2 - 5:10 vecs - ls()[grep(^x\\.[[:digit:]]+$, ls())] lapply(vecs, function(.x) assign(.x, get(.x))) Then you can use vecs to attribute names() to the result. Hope this helps, Rui Barradas Em 07-11-2012 05:35, Erin Hodgess escreveu: Dear R People I have a simple list question, please: I have vectors x.1, x.2,...x.n (each of different lengths) and I would like to combine them into a list. However, I'm sure that there is a better way to do this than to type in x - list(x.1,x.2,x.3,...) Is there a better way to do this, please? I was thinking about possibly using grep? Thanks, Sincerely, Erin __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] simple coversion of matrix rows to matrix columns
Dear All I would like to convert matrix rows to columns. I am thinking the t() function should help, but am having a hard time converting the matrix into the dimensions I would like them to. Example: a -matrix(c(1:30),ncol=3) gives me:[,1] [,2] [,3] [1,]1 11 21 [2,]2 12 22 [3,]3 13 23 [4,]4 14 24 [5,]5 15 25 [6,]6 16 26 [7,]7 17 27 [8,]8 18 28 [9,]9 19 29 [10,] 10 20 30 I would like to convert the above into a matrix that looks like this with 3 rows and 10 columns: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 I have tried : b -t(matrix(a)) but I am getting a 1X30 double matrix. I also Tried to specify b -t(matrix(a),byrow=TRUE,ncol=10) but that does not help either... apreciate your help, Andras [[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] simple coversion of matrix rows to matrix columns
try this: a - matrix(1:30, ncol= 3 ) t(a) I hope it helps. Best, Dimitris On 11/7/2012 12:50 PM, Andras Farkas wrote: Dear All I would like to convert matrix rows to columns. I am thinking the t() function should help, but am having a hard time converting the matrix into the dimensions I would like them to. Example: a -matrix(c(1:30),ncol=3) gives me:[,1] [,2] [,3] [1,]1 11 21 [2,]2 12 22 [3,]3 13 23 [4,]4 14 24 [5,]5 15 25 [6,]6 16 26 [7,]7 17 27 [8,]8 18 28 [9,]9 19 29 [10,] 10 20 30 I would like to convert the above into a matrix that looks like this with 3 rows and 10 columns: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 I have tried : b -t(matrix(a)) but I am getting a 1X30 double matrix. I also Tried to specify b -t(matrix(a),byrow=TRUE,ncol=10) but that does not help either... apreciate your help, Andras [[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. -- Dimitris Rizopoulos Assistant Professor Department of Biostatistics Erasmus University Medical Center Address: PO Box 2040, 3000 CA Rotterdam, the Netherlands Tel: +31/(0)10/7043478 Fax: +31/(0)10/7043014 Web: http://www.erasmusmc.nl/biostatistiek/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] HELP! Excel and R give me totally different regression results using the exact same data
Hello, You are using an Excel feature documented as bug by Microsoft. See http://support.microsoft.com/kb/214230 It warns that both function LINEST() and the regression tool in Analysis ToolPack may give incorrect results. Search the help pages to get long discussions on this. Among others you'll find the link above in https://stat.ethz.ch/pipermail/r-help/2012-July/318348.html Looking at your results, don't you find a negative R^2 suspect? Hope this helps, Rui Barradas Em 07-11-2012 00:20, frauke escreveu: Hallo, I am totally confused why Excel and R give me totally different regression results for the data below. If you know the solution, please enlighten me. In Excel I used LINEST() and DataData AnalysisRegression and both (fortunately) gave the same result. The coefficients were: /b0=1.16, b1=0.957, b2=0.024, R2=0.0027, adjusted R2=-0.017/ In R I used model-lm(as.numeric(test[,1]) /(wave sign here)/ as.numeric(test[,2]) + as.numeric(test[,3])) The result is: /Coefficients: Estimate Std. Error t value Pr(|t|) (Intercept) 3.514 28.913 0.1220.904 as.numeric(test[, 2])0.423 1.027 0.4120.681 as.numeric(test[, 3])6.629 4.194 1.5810.117 Residual standard error: 29.19 on 98 degrees of freedom Multiple R-squared: 0.02706, Adjusted R-squared: 0.007204 F-statistic: 1.363 on 2 and 98 DF, p-value: 0.2607 / Does anybody know what is going on? Thank you for your time! Frauke test- obs fcst48 rate24.last [1,] 1.93 6.9 -0.13 [2,] 5.23 6.6 6.52 [3,] 5.25 6.8 5.85 [4,] 5.26 6.6 1.27 [5,] 5.26 6.8 -0.0703 [6,] 5.34 6.6 -0.95 [7,] 5.37 6.9 0.78 [8,] 5.56 6.7 3.05 [9,] 5.60 71.64 [10,] 5.61 6.9 2.6 [11,] 5.74 6.7 4.09 [12,] 5.92 6.8 1.95 [13,] 5.95 6.8 -5.87 [14,] 6.08 6.6 0.1 [15,] 6.13 6.6 2.6 [16,] 6.16 6.6 -6.15 [17,] 6.26 6.5 1.4 [18,] 6.32 79.78 [19,] 6.33 6.5 0.28 [20,] 6.35 6.6 -0.0899 [21,] 6.36 6.6 -0.13 [22,] 6.37 6.9 -0.04 [23,] 6.39 6.5 -2.14 [24,] 6.39 6.6 0.15 [25,] 6.39 6.7 2.29 [26,] 6.40 6.6 -1.84 [27,] 6.42 6.7 -2.25 [28,] 6.43 6.6 -0.0302 [29,] 6.45 6.8 0.221 [30,] 6.47 6.5 -0.18 [31,] 6.51 6.9 -1.8 [32,] 6.55 6.7 -1.38 [33,] 6.56 6.6 1.33 [34,] 6.58 6.7 7.86 [35,] 6.58 6.8 -0.221 [36,] 6.61 6.8 -0.59 [37,] 6.62 6.7 -0.24 [38,] 6.62 6.7 -0.0996 [39,] 6.64 6.6 -0.221 [40,] 6.65 6.7 -9.63 [41,] 6.69 6.8 -0.18 [42,] 6.72 6.9 -0.739 [43,] 6.73 6.8 0.83 [44,] 6.76 6.6 -1.56 [45,] 6.76 6.7 -1.64 [46,] 6.79 6.8 -0.141 [47,] 6.80 6.9 0.38 [48,] 6.81 6.8 6.46 [49,] 6.81 6.9 -0.0196 [50,] 6.82 6.9 0.54 [51,] 6.84 6.9 -0.19 [52,] 6.84 7-2.11 [53,] 6.85 6.7 -0.171 [54,] 6.88 6.9 0.0605 [55,] 6.90 6.7 -0.0801 [56,] 6.90 7-0.18 [57,] 6.91 6.6 -4.65 [58,] 6.91 6.6 3 [59,] 6.92 6.6 -0.219 [60,] 6.94 6.8 1.4 [61,] 6.99 6.7 -0.44 [62,] 6.99 6.9 1.16 [63,] 7.02 6.8 -1.72 [64,] 7.03 6.8 -0.46 [65,] 7.03 6.9 -0.24 [66,] 7.04 7-0.11 [67,] 7.06 6.9 -0.13 [68,] 7.07 6.7 -0.0196 [69,] 7.08 6.8 0.23 [70,] 7.09 6.7 0.66 [71,] 7.09 7-0.55 [72,] 7.12 7-0.17 [73,] 7.15 6.7 -3.05 [74,] 7.17 6.7 -0.141 [75,] 7.26 6.9 -0.171 [76,] 7.31 7-1.57 [77,] 7.36 6.8 -0.2 [78,] 7.41 6.6 -0.29 [79,] 7.42 6.6 -3.39 [80,] 7.42 6.8 2.11 [81,] 7.53 6.9 0.18 [82,] 7.66 6.6 0 [83,] 7.74 6.7 10.31 [84,] 7.87 6.9 -0.0703 [85,] 7.89 6.6 0.24 [86,] 8.07 6.8 -0.25 [87,] 8.17 6.6 0.97 [88,] 8.38 6.8 -0.15 [89,] 8.38 6.9 0.7 [90,] 8.43 6.8 0.0979 [91,] 8.92 6.8 0 [92,] 9.20 70.18 [93,] 9.79 6.6 0.33 [94,] 9.87 6.8 0 [95,] 10.72 6.8 0.13 [96,] 11.61 6.8 1.88 [97,] 16.44 6.8 -0.00801 [98,] 16.55 6.6 2.96 [99,] 16.88 6.7 1.16 [100,] 17.72 6.7 -0.0694 [101,] 17.91 6.7 -0.24 [102,] 19.03 6.8 -0.431 -- View this message in context: http://r.789695.n4.nabble.com/HELP-Excel-and-R-give-me-totally-different-regression-results-using-the-exact-same-data-tp4648648.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] GMM Gaussian Mixture Model in R
Hello, I'm using and testing different possibility to use GMM. And I would like to test it in R. Anyone know how to use GMM in R ? Maybe with the package BGMM ? Thank's in advance for your answer ! Regards Jerome [[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] New Learner
Hi Experts, As i am a new in this forum, let me introduce myself:- i am Debaranjan, from India, Assam. I have heard many things about R and its statistical Magic feature. i am really have nothing knowledge about R language nor have ever used before. i am only a nursery in R. please help me in learning R. I have gone through many study material for R but have gain nothing about. i understand that i need some guidance and training as a beginners. Please suggest or advice me how to start learning. Regards, Debaranjan __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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: Genotype-quantitativa phenotype linear regression
Hi everyone. what´s the basic package to perform association (linear regression) between 1 marker and quantitatve pohenotypes? Thanks luca __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 + Hadoop on Amazon
Dear All, As i am a new in this forum, let me introduce myself:- i am Debaranjan, from India, Assam. I have heard many things about R and its statistical Magic feature. i am really have nothing knowledge about R language nor have ever used before. i am only a nursery in R. please help me in learning R. I have gone through many study material for R but have gain nothing about. i understand that i need some guidance and training as a beginners. Please suggest or advice me how to start learning. Regards, Debaranjan On Nov 7, 3:35 pm, Vignesh Prajapati vign...@tatvic.com wrote: Hello All, Having some issue with local machine, I need to locate myself on Amazon for running R and Hadoop with Amazon instance. After searching a lot, I can't able to take a decision for choosing Image for Amazon instance. Can any one using R + Hadoop on Amazon. Thanks [[alternative HTML version deleted]] __ r-h...@r-project.org mailing listhttps://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guidehttp://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] Problem with CANDPARA
Hi, I am using the package PTAK and in particular the command Candpara to perform the Parafac factorizationor of a tensor. The results are not encouraging as I expected, I'm starting a phase of analysis to see if there are errors. I pose a question and I hope you can help me. The command to run the factorization is: ## CANDECOMP/PARAFAC results- CANDPARA(data_matrix, dim=3) summary(results) U-results[[1]]$v V-results[[2]]$v W-results[[3]]$v data_matrix is a tensor of 943x1682x4. what I want understand is: U, V, W, are really the three factors that I should get from factorization? I hope someone can help me. Thank you. giuseppe -- View this message in context: http://r.789695.n4.nabble.com/Problem-with-CANDPARA-tp4648682.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] maptree package
Hello, I was using the functino kgs of maptree and I've realized maptree has been removed from CRAN repository. Anybody knows why has it been removed? or where can I find the function kgs that computes the Kelley-Gardner-Sutcliffe penalty function for a hierarchical cluster tree Thank you. [[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] simple coversion of matrix rows to matrix columns
Hi, is.matrix(a) #[1] TRUE #You don't need t(matrix(a)) t(a) # [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] #[1,] 1 2 3 4 5 6 7 8 9 10 #[2,] 11 12 13 14 15 16 17 18 19 20 #[3,] 21 22 23 24 25 26 27 28 29 30 is.matrix(t(a)) #[1] TRUE str(t(a)) # int [1:3, 1:10] 1 11 21 2 12 22 3 13 23 4 ... str(t(matrix(a)) ) # int [1, 1:30] 1 2 3 4 5 6 7 8 9 10 ... A.K. - Original Message - From: Andras Farkas motyoc...@yahoo.com To: r-help@r-project.org r-help@r-project.org Cc: Sent: Wednesday, November 7, 2012 6:50 AM Subject: [R] simple coversion of matrix rows to matrix columns Dear All I would like to convert matrix rows to columns. I am thinking the t() function should help, but am having a hard time converting the matrix into the dimensions I would like them to. Example: a -matrix(c(1:30),ncol=3) gives me:[,1] [,2] [,3] [1,] 1 11 21 [2,] 2 12 22 [3,] 3 13 23 [4,] 4 14 24 [5,] 5 15 25 [6,] 6 16 26 [7,] 7 17 27 [8,] 8 18 28 [9,] 9 19 29 [10,] 10 20 30 I would like to convert the above into a matrix that looks like this with 3 rows and 10 columns: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 I have tried : b -t(matrix(a)) but I am getting a 1X30 double matrix. I also Tried to specify b -t(matrix(a),byrow=TRUE,ncol=10) but that does not help either... apreciate your help, Andras [[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] Survplot, Y-axis in percent
It doesn't look like 'survplot' allows you to control the yaxis formatting in that way. You can edit the function survplot.survfit directly if you really need to: fix(survplot.survfit). The relevant line to change is (I believe) mgp.axis(2, at = pretty(ylim)) to mgp.axis(2, at = pretty(ylim), labels= 100*pretty(ylim)). However, if you are new to R this could cause you more trouble than you want. Alternatively, you can use 'plot' with the yaxt=n option. e.g., mod - survfit(Surv(time,status)~ph.ecog, data=lung) plot(mod, yaxt=n, col=1:4, ylab=Survival Percent, xlab=Days, main=Lung Cancer Data\nEffect of ph.ecog on Survival) axis(2, at=seq(0,1,0.2), labels=paste(seq(0,100,20), %, sep=), las=1) But that doesn't have all the other stuff you appear to want (e.g., shaded confidence bands). Good luck, Chris -Original Message- From: maziar.mohaddes [mailto:maziar.mohad...@gmail.com] Sent: Tuesday, November 06, 2012 11:11 AM To: r-help@r-project.org Subject: [R] Survplot, Y-axis in percent Hi I am a new fan of R after getting mad with the graphical functional in SPSS. I have been able to create a nice looking Kaplan Meyer graph using Survplot function. However I have difficulties in turning the y axis to percent instead of the default 0-1 scale. Further I have tried the function yaxt=n without any results. Any help in this matter will be appreciated. The code is posted below: par(mfrow=c(1,1)) fit - survfit(Surv(revreg$Tcuprev , revreg$Rcup_n_j_n)~revreg$RAceGrp_1Maz) fit survplot (fit, col=c(gray1,gray40), lty=1, lwd = 1, col.fill=c(gray50,gray80), mark.time= T, conf=bands , conf.int=.95, add=F , xlim=c(0, 20) , time.inc = 4, ylim=c(0.5, 1), xlab=Years Postoperative , ylab=Cumulative Survival Probability , label.curves=F , abbrev.label=F , yaxt=n ) -- View this message in context: http://r.789695.n4.nabble.com/Survplot-Y-axis-in-percent-tp4648572.html Sent from the R help mailing list archive at Nabble.com. ** Electronic Mail is not secure, may not be read every day, and should not be used for urgent or sensitive issues __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Survplot, Y-axis in percent
Don't change the code. Just use survplot(..., fun=function(y)100*y, ylim=c(0,100)). But note that percent is not recommended as it is more confusing than proportions, especially when talking about differences in percents. Frank Andrews, Chris wrote It doesn't look like 'survplot' allows you to control the yaxis formatting in that way. You can edit the function survplot.survfit directly if you really need to: fix(survplot.survfit). The relevant line to change is (I believe) mgp.axis(2, at = pretty(ylim)) to mgp.axis(2, at = pretty(ylim), labels= 100*pretty(ylim)). However, if you are new to R this could cause you more trouble than you want. Alternatively, you can use 'plot' with the yaxt=n option. e.g., mod - survfit(Surv(time,status)~ph.ecog, data=lung) plot(mod, yaxt=n, col=1:4, ylab=Survival Percent, xlab=Days, main=Lung Cancer Data\nEffect of ph.ecog on Survival) axis(2, at=seq(0,1,0.2), labels=paste(seq(0,100,20), %, sep=), las=1) But that doesn't have all the other stuff you appear to want (e.g., shaded confidence bands). Good luck, Chris -Original Message- From: maziar.mohaddes [mailto: maziar.mohaddes@ ] Sent: Tuesday, November 06, 2012 11:11 AM To: r-help@ Subject: [R] Survplot, Y-axis in percent Hi I am a new fan of R after getting mad with the graphical functional in SPSS. I have been able to create a nice looking Kaplan Meyer graph using Survplot function. However I have difficulties in turning the y axis to percent instead of the default 0-1 scale. Further I have tried the function yaxt=n without any results. Any help in this matter will be appreciated. The code is posted below: par(mfrow=c(1,1)) fit - survfit(Surv(revreg$Tcuprev , revreg$Rcup_n_j_n)~revreg$RAceGrp_1Maz) fit survplot (fit, col=c(gray1,gray40), lty=1, lwd = 1, col.fill=c(gray50,gray80), mark.time= T, conf=bands , conf.int=.95, add=F , xlim=c(0, 20) , time.inc = 4, ylim=c(0.5, 1), xlab=Years Postoperative , ylab=Cumulative Survival Probability , label.curves=F , abbrev.label=F , yaxt=n ) -- View this message in context: http://r.789695.n4.nabble.com/Survplot-Y-axis-in-percent-tp4648572.html Sent from the R help mailing list archive at Nabble.com. ** Electronic Mail is not secure, may not be read every day, and should not be used for urgent or sensitive issues __ R-help@ mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. - Frank Harrell Department of Biostatistics, Vanderbilt University -- View this message in context: http://r.789695.n4.nabble.com/Survplot-Y-axis-in-percent-tp4648572p4648697.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] New Learner
Dear Debaranjan, What's your field of specialisation or study? Regards, José José Iparraguirre Chief Economist Age UK T 020 303 31482 E jose.iparragui...@ageuk.org.uk Twitter @jose.iparraguirre@ageuk Tavis House, 1- 6 Tavistock Square London, WC1H 9NB www.ageuk.org.uk | ageukblog.org.uk | @ageukcampaigns For a copy of our new Economic Monitor and the full Chief Economist's report, visit the Age UK Knowledge Hub http://www.ageuk.org.uk/professional-resources-home/knowledge-hub-evidence-statistics/ For evidence and statistics on the older population, visit the Age UK Knowledge Hub http://www.ageuk.org.uk/professional-resources-home/knowledge-hub-evidence-statistics/ -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Debaranjan Sent: 07 November 2012 10:34 To: r-help@r-project.org Subject: [R] New Learner Hi Experts, As i am a new in this forum, let me introduce myself:- i am Debaranjan, from India, Assam. I have heard many things about R and its statistical Magic feature. i am really have nothing knowledge about R language nor have ever used before. i am only a nursery in R. please help me in learning R. I have gone through many study material for R but have gain nothing about. i understand that i need some guidance and training as a beginners. Please suggest or advice me how to start learning. Regards, Debaranjan __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Wrap Up Run 10k next March to raise vital funds for Age UK Six exciting new 10k races are taking place throughout the country and we want you to join in the fun! Whether you're a runner or not, these are events are for everyone ~ from walking groups to serious athletes. The Age UK Events Team will provide you with a training plan to suit your level and lots of tips to make this your first successful challenge of 2012. Beat the January blues and raise some vital funds to help us prevent avoidable deaths amongst older people this winter. Sign up now! www.ageuk.org.uk/10k Coming to; London Crystal Palace, Southport, Tatton Park, Cheshire Harewood House, Leeds,Coventry, Exeter Age UK Improving later life www.ageuk.org.uk --- Age UK is a registered charity and company limited by guarantee, (registered charity number 1128267, registered company number 6825798). Registered office: Tavis House, 1-6 Tavistock Square, London WC1H 9NA. For the purposes of promoting Age UK Insurance, Age UK is an Appointed Representative of Age UK Enterprises Limited, Age UK is an Introducer Appointed Representative of JLT Benefit Solutions Limited and Simplyhealth Access for the purposes of introducing potential annuity and health cash plans customers respectively. Age UK Enterprises Limited, JLT Benefit Solutions Limited and Simplyhealth Access are all authorised and regulated by the Financial Services Authority. -- This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you receive a message in error, please advise the sender and delete immediately. Except where this email is sent in the usual course of our business, any opinions expressed in this email are those of the author and do not necessarily reflect the opinions of Age UK or its subsidiaries and associated companies. Age UK monitors all e-mail transmissions passing through its network and may block or modify mails which are deemed to be unsuitable. Age Concern England (charity number 261794) and Help the Aged (charity number 272786) and their trading and other associated companies merged on 1st April 2009. Together they have formed the Age UK Group, dedicated to improving the lives of people in later life. The three national Age Concerns in Scotland, Northern Ireland and Wales have also merged with Help the Aged in these nations to form three registered charities: Age Scotland, Age NI, Age Cymru. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] a simple list question
HI, If you want to combine vectors x and y into a list, may be this also helps: x.1-1:3 x.2-1:4 x.3-5:10 y.1-5:6 y.2-8:10 ls() # [1] a a1 L mat1 n vecs x.1 x.2 x.3 y.1 #[11] y.2 lapply(strsplit(ls()[grep(x|y,ls())],),function(x) get(paste(x,collapse=))) #[[1]] #[1] 1 2 3 # #[[2]] #[1] 1 2 3 4 # #[[3]] #[1] 5 6 7 8 9 10 # #[[4]] #[1] 5 6 # #[[5]] #[1] 8 9 10 A.K. - Original Message - From: Rui Barradas ruipbarra...@sapo.pt To: Erin Hodgess erinm.hodg...@gmail.com Cc: R help r-h...@stat.math.ethz.ch Sent: Wednesday, November 7, 2012 6:44 AM Subject: Re: [R] a simple list question Hello, Try the following. x.1 - 1:3 y.1 - 1:4 x.2 - 5:10 vecs - ls()[grep(^x\\.[[:digit:]]+$, ls())] lapply(vecs, function(.x) assign(.x, get(.x))) Then you can use vecs to attribute names() to the result. Hope this helps, Rui Barradas Em 07-11-2012 05:35, Erin Hodgess escreveu: Dear R People I have a simple list question, please: I have vectors x.1, x.2,...x.n (each of different lengths) and I would like to combine them into a list. However, I'm sure that there is a better way to do this than to type in x - list(x.1,x.2,x.3,...) Is there a better way to do this, please? I was thinking about possibly using grep? Thanks, Sincerely, Erin __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 + Hadoop on Amazon
Hi Debaranjan, I'm not really sure what you mean by statistical magic feature -- R is good, but not quite magic. (Though occasional sarcastic references are made to its capabilities by members of this list when questions push things beyond the realm of responsible statistics) The canonical first place to start is by reading the 'An Introduction to R' manual provided with every distribution of R. You can find it online, or access it locally by typing help.start() at the command prompt. Cheers, Michael On Wed, Nov 7, 2012 at 10:54 AM, Debaranjan drdeva...@gmail.com wrote: Dear All, As i am a new in this forum, let me introduce myself:- i am Debaranjan, from India, Assam. I have heard many things about R and its statistical Magic feature. i am really have nothing knowledge about R language nor have ever used before. i am only a nursery in R. please help me in learning R. I have gone through many study material for R but have gain nothing about. i understand that i need some guidance and training as a beginners. Please suggest or advice me how to start learning. Regards, Debaranjan __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] maptree package
On 07/11/2012 11:27, xavier maresma wrote: Hello, I was using the functino kgs of maptree and I've realized maptree has been removed from CRAN repository. Anybody knows why has it been removed? or where can I find the function kgs That's not true: see http://cran.r-project.org/web/packages/maptree/index.html and follow the link. that computes the Kelley-Gardner-Sutcliffe penalty function for a hierarchical cluster tree Thank you. [[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. -- Brian D. Ripley, rip...@stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] export home range image to google earth (alternatively a shapefile)
I calculated a homerange using the adehabitatHR-packaged, plotted it and now I want to export the image (image with the contourlines) to google maps. I just don't get how to do that. Here is something like my image: library(adehabitatHR) kudl - kernelUD(puechabonsp$relocs[, 1], h = LSCV) vud - getvolumeUD(kudl) image(vud[[1]]) xyzv - as.image.SpatialGridDataFrame(vud[[1]]) contour(xyzv, add=TRUE) To create a KML I thought I'd use 'plotKML'. But I don't get it. Does anyone have any idea? -- View this message in context: http://r.789695.n4.nabble.com/export-home-range-image-to-google-earth-alternatively-a-shapefile-tp4648705.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] RODBC to MS SQL Server update error
Is this a bug: Trying to update when the where condition gives zero rows throws an error on MS SQL server sqlQuery(pipe,select * from ComDetailCurrent where RateTypeId is null;) [1] ProcessDate SourceSystemIdAccountNumber Xref1 0 rows (or 0-length row.names) sqlQuery(pipe,update ComDetailCurrent set RateTypeId=1 where RateTypeId is null;) [1] [RODBC] ERROR: Could not SQLExecDirect 'update ComDetailCurrent set RateTypeId=1 where RateTypeId is null;' On the other hand with MySQL sqlQuery(mys,update rate_hist set val=5.0 where dtend'1986-05-01') [1] No Data Please, try to update a table on SQL server and give it a where condition such that zero rows will be updated. And post the result on this forum :-) Thanks everybody and have a great day. Stephen B __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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: net reclassification index after Cox survival analysis
Dear all, I am interested to evaluate reclassification using net reclassification improvement and Integrated Discrimination Index IDI after survival analysis (Cox proportional hazards using stcox). I search a R package or a R code that specifically addresses the categorical NRI for time-to-event data in the presence of censored observation and, if possible, at different follow-up time points. I know that the PredictABEL Package contains functions for NRI and IDI calculation but it is unclear for me if it allows censored observation. Package survIDINRI calculates only continuous NRI and the function of Package Hmisc[#rcorrp.cens(x1, x2, y) ##] is only for no censored observations. Many thanks. Sincerely, Mario Petretta Dpt. Internal Medicine, Cardiology and Heart Surgery Naples University Federico II - Italy __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] matrix.csr %*% matrix -- matrix
* Martin Maechler znrpu...@fgng.zngu.rgum.pu [2012-11-07 10:10:51 +0100]: Sam == Sam Steingold s...@gnu.org on Tue, 6 Nov 2012 13:08:30 -0500 writes: Sam The question is even more pressing for me now given that I no longer can Sam convert some csr matrices to the regular ones for scaling. Sam (http://article.gmane.org/gmane.comp.lang.r.general:279305) Sam Any suggestions? (the original csr matrix is too large to be converted Sam to a regular one, but the product is small enough). * Sam Steingold f...@tah.bet [2012-08-27 14:58:47 -0400]: When a sparse matrix is multiplied by a regular one, the result is usually not sparse. However, when matrix.csr is multiplied by a regular matrix in R, a matrix.csr is produced. Is there a way to avoid this? Thanks! Why don't you use the sparse matrix classes from the Matrix package .. which is part of every R distribution ? SparseM has been written as very first package to support sparse matrices, and is to be applauded for that, but it does lack many features nowadays (and also uses less modern algorithm for e.g. the sparse Cholesky decomposition). Thank you very much for your advice. I do not think I use SparseM directly. I use e1071::read.matrix.csr and e1071::write.matrix.csr which use SparseM. I.e., I need to be able to do i/o on files which are palatable to libsvm/liblinear, specifically, read/write files like --8---cut here---start-8--- 1.2 2:3.5 6:5.1 2 4:6.7 8 7:6.6 --8---cut here---end---8--- As you can see from my other messages (e.g., http://article.gmane.org/gmane.comp.lang.r.general:279387), I am not happy with my current setup. I would be delighted to learn that there is an alternative, but so far the only matrix i/o I could find is Matrix::readHB and it does not handle the libsvm/liblinear format. -- Sam Steingold (http://sds.podval.org/) on Ubuntu 12.04 (precise) X 11.0.11103000 http://www.childpsy.net/ http://openvotingconsortium.org http://truepeace.org http://palestinefacts.org http://camera.org http://www.memritv.org Heck is a place for people who don't believe in gosh. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] total number of citations for R project
Dear Member list, is there a weblink or a paper where the total number of citations for R project is report? Thanks in advance Gianni [[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] a simple list question
Hello, My solution is too complicated, the assign() is not needed. lapply( ls()[grep(^x\\.[[:digit:]]+$, ls())], get) Hope this helps, Rui Barradas Em 07-11-2012 11:44, Rui Barradas escreveu: Hello, Try the following. x.1 - 1:3 y.1 - 1:4 x.2 - 5:10 vecs - ls()[grep(^x\\.[[:digit:]]+$, ls())] lapply(vecs, function(.x) assign(.x, get(.x))) Then you can use vecs to attribute names() to the result. Hope this helps, Rui Barradas Em 07-11-2012 05:35, Erin Hodgess escreveu: Dear R People I have a simple list question, please: I have vectors x.1, x.2,...x.n (each of different lengths) and I would like to combine them into a list. However, I'm sure that there is a better way to do this than to type in x - list(x.1,x.2,x.3,...) Is there a better way to do this, please? I was thinking about possibly using grep? Thanks, Sincerely, Erin __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] total number of citations for R project
http://scholar.google.be/scholar?q=www.R-project.orgbtnG=hl=nlas_sdt=0 http://scholar.google.be/scholar?q=%22R+Core+Team%22btnG=hl=nlas_sdt=0 http://scholar.google.be/scholar?q=%22R+Foundation+for+Statistical+Computing%22btnG=hl=nlas_sdt=0 ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest team Biometrie Kwaliteitszorg / team Biometrics Quality Assurance Kliniekstraat 25 1070 Anderlecht Belgium + 32 2 525 02 51 + 32 54 43 61 85 thierry.onkel...@inbo.be www.inbo.be To call in the statistician after the experiment is done may be no more than asking him to perform a post-mortem examination: he may be able to say what the experiment died of. ~ Sir Ronald Aylmer Fisher The plural of anecdote is not data. ~ Roger Brinner The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data. ~ John Tukey -Oorspronkelijk bericht- Van: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] Namens gianni lavaredo Verzonden: woensdag 7 november 2012 16:40 Aan: r-help@r-project.org Onderwerp: [R] total number of citations for R project Dear Member list, is there a weblink or a paper where the total number of citations for R project is report? Thanks in advance Gianni [[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. * * * * * * * * * * * * * D I S C L A I M E R * * * * * * * * * * * * * Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is door een geldig ondertekend document. The views expressed in this message and any annex are purely those of the writer and may not be regarded as stating an official position of INBO, as long as the message is not confirmed by a duly signed document. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] a simple list question
Combining your, Rolf, and Michael's suggestions makes it possible to eliminate the lappy(): mget(ls()[grep(^x\\.[[:digit:]]+$, ls())], .GlobalEnv) -- 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 Rui Barradas Sent: Wednesday, November 07, 2012 9:49 AM To: Erin Hodgess Cc: R help Subject: Re: [R] a simple list question Hello, My solution is too complicated, the assign() is not needed. lapply( ls()[grep(^x\\.[[:digit:]]+$, ls())], get) Hope this helps, Rui Barradas Em 07-11-2012 11:44, Rui Barradas escreveu: Hello, Try the following. x.1 - 1:3 y.1 - 1:4 x.2 - 5:10 vecs - ls()[grep(^x\\.[[:digit:]]+$, ls())] lapply(vecs, function(.x) assign(.x, get(.x))) Then you can use vecs to attribute names() to the result. Hope this helps, Rui Barradas Em 07-11-2012 05:35, Erin Hodgess escreveu: Dear R People I have a simple list question, please: I have vectors x.1, x.2,...x.n (each of different lengths) and I would like to combine them into a list. However, I'm sure that there is a better way to do this than to type in x - list(x.1,x.2,x.3,...) Is there a better way to do this, please? I was thinking about possibly using grep? Thanks, Sincerely, Erin __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] a simple list question
And the ls()[grep(^x\\.[[:digit:]]+$, ls())] can be simplified to grep(^x\\.[[:digit:]]+$, ls(), value=TRUE) 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 L Carlson Sent: Wednesday, November 07, 2012 8:25 AM To: 'Rui Barradas'; 'Erin Hodgess' Cc: 'R help' Subject: Re: [R] a simple list question Combining your, Rolf, and Michael's suggestions makes it possible to eliminate the lappy(): mget(ls()[grep(^x\\.[[:digit:]]+$, ls())], .GlobalEnv) -- 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 Rui Barradas Sent: Wednesday, November 07, 2012 9:49 AM To: Erin Hodgess Cc: R help Subject: Re: [R] a simple list question Hello, My solution is too complicated, the assign() is not needed. lapply( ls()[grep(^x\\.[[:digit:]]+$, ls())], get) Hope this helps, Rui Barradas Em 07-11-2012 11:44, Rui Barradas escreveu: Hello, Try the following. x.1 - 1:3 y.1 - 1:4 x.2 - 5:10 vecs - ls()[grep(^x\\.[[:digit:]]+$, ls())] lapply(vecs, function(.x) assign(.x, get(.x))) Then you can use vecs to attribute names() to the result. Hope this helps, Rui Barradas Em 07-11-2012 05:35, Erin Hodgess escreveu: Dear R People I have a simple list question, please: I have vectors x.1, x.2,...x.n (each of different lengths) and I would like to combine them into a list. However, I'm sure that there is a better way to do this than to type in x - list(x.1,x.2,x.3,...) Is there a better way to do this, please? I was thinking about possibly using grep? Thanks, Sincerely, Erin __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting- guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] HELP! Excel and R give me totally different regression results using the exact same data
Hi David, hi Rui, thanks for your quick replies. I have replicated David's R results and confirmed them with Minitab. Though I'm not sure what you are trying to tell me with the code you wrote, David. Do you mean, I should use a dataframe rather than a matrix, or use the data= part of the lm() function? Rui seems to be right, too. Excel's regression function doesn't work; I cannot replicate the Minitab and R results with it. According to the Microsoft website this is probably because the x- and y-values overlap. I am truly astonished that such a major bug doesn't at least have a major red flag to it. Thank you! Frauke -- View this message in context: http://r.789695.n4.nabble.com/HELP-Excel-and-R-give-me-totally-different-regression-results-using-the-exact-same-data-tp4648648p4648723.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] generic question about differences between PCA and DMFA
Dear list I'd like to have your opinion about my case study. I'm analizing a dataset of 9 experiments and 15 variables with the aim to highlight the variables that can majorly explain the variance between the experiments. This is an example with only 3 rows and 5 variables var1 var2 var3 var4 var5 sample5 0,067 0,005 0,008 0,100 0,005 sample6 0,069 0,001 0,011 0,084 0,005 sample7 -7 -5 -1 34 4 My problem is that in some experiments (like in sample7) the measures related to my variables are measured as delta values (initial condition - final condition). In the other cases the variables are measured considering only the absolute values at my final condition. After PCA the model looks like strongly influenced by this difference (even if my data are centered to 0 and scaled to 1) because in the score plot I see with the first PC mainly the separation between experiments with positive and negative values and the second PC is not able to give to me further informations . In your opinion is there a way to compare these experiments measured in this different way? Alternatively do you think that the Dual Multiple Factor Analysis available with the package FactorMineR could be a better way to analyze these data? Thank you for any suggestion Guido -- Guido Leoni National Research Institute on Food and Nutrition (I.N.R.A.N.) via Ardeatina 546 00178 Rome Italy tel + 39 06 51 49 41 (operator) + 39 06 51 49 4498 (direct) [[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] pseudo R-squared with likfit (geoR)
We want to compute a pseudo R-squared for a model whose parameter estimation was based on maximum likelihood (function likfit, package geoR). I tried to compute the R2 proposed by Maddala (1983) which compare the maximized likelihood for the model without any predictor and the maximized likelihood for the model with all predictors. I got a really low value (0,01%). Did I miss something? Are there other R-squared which are more appropriate than the R2 of Maddala? : sp05_l01 - likfit(cnm05g, *ini.cov.pars=vm05*, lik.method = REML, trend = trend.spatial(~ logIKA04 + nbLitre0 + nbLitre1, cnm05g))#complete model sp05_nt - update(sp05_01, trend = trend.spatial(cte, cnm05g)) #null model 1-(sp07_nt$loglik/sp07_l0$loglik)^(2/590)#Maddala (1983) [1] 0.0001510074 Thanks, Regards, Marion -- Marion Jacquot Laboratoire de Chrono-environnement UMR UFC/CNRS 6249 USC INRA Université de Franche-Comté Place Leclerc F-25030 Besançon cedex FRANCE Tel. : +33 (0)381 665 829 Fax : +33 (0)381 665 797 http://chrono-environnement.univ-fcomte.fr/ [[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] pseudo R-squared with likfit (geoR)
This is basically a statistics question, despite the fact that you refer to an R implementation. You should therefore probably post on a statistics list, like stats.stackexchange.com, especially the part about asking for alternative R^2. -- Bert On Wed, Nov 7, 2012 at 9:01 AM, Marion Jacquot marion.jacq...@univ-fcomte.fr wrote: We want to compute a pseudo R-squared for a model whose parameter estimation was based on maximum likelihood (function likfit, package geoR). I tried to compute the R2 proposed by Maddala (1983) which compare the maximized likelihood for the model without any predictor and the maximized likelihood for the model with all predictors. I got a really low value (0,01%). Did I miss something? Are there other R-squared which are more appropriate than the R2 of Maddala? : sp05_l01 - likfit(cnm05g, *ini.cov.pars=vm05*, lik.method = REML, trend = trend.spatial(~ logIKA04 + nbLitre0 + nbLitre1, cnm05g))#complete model sp05_nt - update(sp05_01, trend = trend.spatial(cte, cnm05g)) #null model 1-(sp07_nt$loglik/sp07_l0$loglik)^(2/590)#Maddala (1983) [1] 0.0001510074 Thanks, Regards, Marion -- Marion Jacquot Laboratoire de Chrono-environnement UMR UFC/CNRS 6249 USC INRA Université de Franche-Comté Place Leclerc F-25030 Besançon cedex FRANCE Tel. : +33 (0)381 665 829 Fax : +33 (0)381 665 797 http://chrono-environnement.univ-fcomte.fr/ [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Bert Gunter Genentech Nonclinical Biostatistics Internal Contact Info: Phone: 467-7374 Website: http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] pseudo R-squared with likfit (geoR)
... and you might also wish to try the R-sig-geo list, for obvious reasons. -- Bert On Wed, Nov 7, 2012 at 9:01 AM, Marion Jacquot marion.jacq...@univ-fcomte.fr wrote: We want to compute a pseudo R-squared for a model whose parameter estimation was based on maximum likelihood (function likfit, package geoR). I tried to compute the R2 proposed by Maddala (1983) which compare the maximized likelihood for the model without any predictor and the maximized likelihood for the model with all predictors. I got a really low value (0,01%). Did I miss something? Are there other R-squared which are more appropriate than the R2 of Maddala? : sp05_l01 - likfit(cnm05g, *ini.cov.pars=vm05*, lik.method = REML, trend = trend.spatial(~ logIKA04 + nbLitre0 + nbLitre1, cnm05g))#complete model sp05_nt - update(sp05_01, trend = trend.spatial(cte, cnm05g)) #null model 1-(sp07_nt$loglik/sp07_l0$loglik)^(2/590)#Maddala (1983) [1] 0.0001510074 Thanks, Regards, Marion -- Marion Jacquot Laboratoire de Chrono-environnement UMR UFC/CNRS 6249 USC INRA Université de Franche-Comté Place Leclerc F-25030 Besançon cedex FRANCE Tel. : +33 (0)381 665 829 Fax : +33 (0)381 665 797 http://chrono-environnement.univ-fcomte.fr/ [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Bert Gunter Genentech Nonclinical Biostatistics Internal Contact Info: Phone: 467-7374 Website: http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R: net reclassification index after Cox survival analysis
On Nov 7, 2012, at 6:54 AM, petre...@unina.it wrote: Dear all, I am interested to evaluate reclassification using net reclassification improvement and Integrated Discrimination Index IDI after survival analysis (Cox proportional hazards using stcox). I search a R package or a R code that specifically addresses the categorical NRI for time-to-event data in the presence of censored observation and, if possible, at different follow-up time points. I know that the ‘PredictABEL’ Package contains functions for NRI and IDI calculation but it is unclear for me if it allows censored observation. Package ‘survIDINRI’ calculates only continuous NRI and the function of Package ‘Hmisc’[#rcorrp.cens(x1, x2, y) ##] is only for no censored observations. ???. Doesn't its name , 'rcorrp.cens' suggest otherwise? Not to mention its description int the Hmisc Index: Rank Correlation for Paired Predictors with a Possibly Censored Response, and Integrated Discrimination Index. rcoop.cens is a fairly recent addition to Hmisc and I am looking at Hmisc version 3.10-1. If you are looking at a version that is a couple of years old, you may be seeing something different. The argument list you list looks like the one for improveProb(), which does not appear to handle censoring. The rcorrp.cens argument list is: rcorrp.cens(x1, x2, S, outx=FALSE, method=1) And the S object is a Surv-object. Many thanks. Sincerely, Mario Petretta Dpt. Internal Medicine, Cardiology and Heart Surgery Naples University Federico II - Italy __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. 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] Aggregate data frame across columns
Folks, I have a data frame with columns 200401, 200402, ..., 201207, 201208. These represent years/months. What would be the best way to sum these columns by year? What about by quarter? Thanks for your time, KW -- [[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] Aggregate data frame across columns
Have you read the Introduction to R tutorial? This is discussed there, I believe. If you have not, please do so before posting here further. But ... ?tapply ?aggregate ?ave Also the plyr package for user-friendlier approaches. -- Bert On Wed, Nov 7, 2012 at 9:32 AM, Keith Weintraub kw1...@gmail.com wrote: Folks, I have a data frame with columns 200401, 200402, ..., 201207, 201208. These represent years/months. What would be the best way to sum these columns by year? What about by quarter? Thanks for your time, KW -- [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Bert Gunter Genentech Nonclinical Biostatistics Internal Contact Info: Phone: 467-7374 Website: http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] how to generate a set of random numbers that sum to 1 with uniform distribution of elements
Hi, I am looking for a way to generate a matrix of random numbers in a way that each row of the matrix would sum to 1 and that the numbers in the columns of the matrix would have a uniform distribution. So far I have found several ways to create random numbers that would sum to 1, but then the distribution of the individual elements is more or less skewed - there are much more small numbers than larger ones. Any help and suggestions? - Bärbel -- View this message in context: http://r.789695.n4.nabble.com/how-to-generate-a-set-of-random-numbers-that-sum-to-1-with-uniform-distribution-of-elements-tp4648695.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] connecting R eclipse problem
i am connecting R 2.15 with Eclipse IDE 3.7,using [StatET] -: http://www.walware.de/ i have installed rjava,rj-1.1,rj.gd-1.1,installed new software StatET 3.0-3.1 in eclipse ,etc as prerequisite, i done all procedure as per eclipse says(Configure Launch R console panel),but at end,when configuring with R,gives error in Eclipse console * using log directory ‘/home/trendwise/lib.Rcheck’ * using R version 2.15.1 (2012-06-22) * using platform: x86_64-pc-linux-gnu (64-bit) * using session charset: UTF-8 * checking for file ‘lib/DESCRIPTION’ ... NO i have installed R in /usr/lib/R (R_HOME),why R checking for DESCRIPTION file ? - 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/connecting-R-eclipse-problem-tp4648700.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] Survplot, Y-axis in percent
Dear Prof Harell, great thanks for your solution to this. I have been trying to figure this out last four weeks by reading loads of manuals and forums around the net without success. Once again thank you for the solution and the great option of shadowed Conf int in the survplot Best Regards - Maziar Mohaddes, MD Gothenburg, Sweden -- View this message in context: http://r.789695.n4.nabble.com/Survplot-Y-axis-in-percent-tp4648572p4648703.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 message no lines available in input
Dear all, a program that worked well for weeks today gave me consistently the error message no lines available in input referring to the lines for (i in (0:(timeintervals-1))) { j=subjectquantity+6+i*(subjectquantity+7) print (j) results-read.table(file, header=F, skip=j, nrows=subjectquantity) timeintervals have been specified as argument as 12 subjectquantity as 9 the file it should be reading starts like: davide.jtfbase elena.jtfbase fabio.jtfbase francesco.jtfbase giulia.jtfbase kerstin.jtfbase Lucia.jtfbase maria.jtfbase Stephanomer.jtfbase Power Mean amplitude averaged over channel group left_central: 30, 36, 41, 31, 37, 42, 54, 53 right_central: 104, 103, 105, 87, 93, 86, 80, 79 Baseline1 Baseline2 _left_central _right_central _left_central _right_central davide.jtfbase 0.94036 1.03227 1.02403 0.75338 elena.jtfbase 1.05467 0.52269 0.85483 0.75881 fabio.jtfbase 1.02207 1.14401 1.15726 0.98496 francesco.jtfbase 1.39298 0.97169 1.15515 1.23719 giulia.jtfbase 1.28790 1.54337 1.37583 2.0 kerstin.jtfbase 1.78279 1.70336 1.38145 1.06702 Lucia.jtfbase 1.14633 1.53128 1.19042 1.56369 maria.jtfbase 1.23954 1.11156 0.60587 0.84131 Stephanomer.jtfbase 1.09375 1.01436 1.13088 1.17659 I really have no idea what is going on, if you could help me that would be awesome! Best Katrin -- View this message in context: http://r.789695.n4.nabble.com/error-message-no-lines-available-in-input-tp4648709.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] Annotation using org.At.tair.db package in R
Iam using R version 2.15 in a linux operating system. I have a matrix consisting of the gene ids and their specific signal intensity values as follows( a subset of the whole matrix) : probes GSM362180GSM362181 GSM362188GSM362189 GSM362192 244901 5.094871713 4.626623079 4.554272515 4.748604391 4.759221647 244902 5.194528083 4.985930299 4.817426064 5.151654407 4.838741605 244903 5.412329253 5.352970877 5.06250609 5.305709079 8.365082403 244904 5.529220594 5.28134657 5.467445095 5.62968933 5.458388909 244905 5.024052699 4.714631878 4.792865831 4.843975286 4.657188246 244906 5.786557533 5.242403911 5.060605782 5.458148567 5.890061836 I would like to extract only the first column as follows : ids - scr[,2] and then I got a factor[2368] And then I proceeded to the annotation as follows: biocLite(GO.db) library(AnnotationDbi) biocLite(org.At.tair.db) biocLite(ath1121501.db). genenames - org.At.tairGENENAME[ids] #map the probe ids to the gene names in TAIR The output of which is AnnDbBiMap[1] number-org.At.tairENTREZID[ids] #map the probe ids to the gene ids in TAIR The output of which is AnnDbBiMap[1] And then I try to merge both the lists as : xx-toTable(entrez) yy-toTable(number) complete-merge(xx,yy) I get an error in this step and unable to proceed further.The error reads: Error in fix.by(by.y.y): 'by' must specify uniquely valid column(s) Is it because ids - scr[,1] is a factor ? How would it be possible to extract it as : ids- c(244901, 244902, 244903,..) I cannot do the above manually because its a large matrix. -- output of sessionInfo(): R version 2.15 Linux. -- View this message in context: http://r.789695.n4.nabble.com/Annotation-using-org-At-tair-db-package-in-R-tp4648711.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] Welch Two Sample T-Test
I know when I enter this into R: x = c(15, 10, 13, 7, 9, 8, 21, 9, 14, 8) y = c(15, 14, 12, 8, 14, 7, 16, 10, 15, 12) t.test(x,y,alt=less,var.equal=TRUE) it shows: Two Sample t-test data: x and y t = -0.5331, df = 18, p-value = 0.3002 alternative hypothesis: true difference in means is less than 0 95 percent confidence interval: -Inf 2.027436 sample estimates: mean of x mean of y 11.4 12.3 I need to write out the entire function and give this same result but without t.test(x,y,alt=less,var.equal=TRUE). I need to print out the value for t, df, pvalue as well as the confidence, etc. How exactly do I go about doing that? -- View this message in context: http://r.789695.n4.nabble.com/Welch-Two-Sample-T-Test-tp4648713.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] Calling R object from R function
Hi, Can you please help me with this please? What I am trying to do is call a vector from R function and used in the new function So I create 4 functions with these arguments M11 - function(TrainData,TestData,mdat,nsam) { ls - list() I have few statments one of them is vectx - c(,1,2,3,4,5,6,6) vectz - c(12,34,5,6,78,9,90) and then ls(vectx=vtecx,vectz=vectz) return(ls) } Then I great an new function has the following arguments get.m - function(dat,asim,ModelFun,M){ Sim - list() modInd - ModelFun(TrainData=dat,TestData=dat,mdat=dat,nsam=0.1) *# HERE IS MY PROBLEM HOW CAN I JUST CALL vectx without fitting the ModelFun becasue as you see in the bottom TrainData and Test are arguments used after resampling. I dont want to use the main dat argument?* if(M==11){ vecx - modInd$vectx px - length(vecx) # ncol for X nam -colnames(dat[,vecx]) Asse - matrix(NA,nrow=asim,ncol=px) colnames(Asse) - nam } for(i in 1:asim){ set.seed(i) Samdat - dat[sample(1:nrow(dat), nrow(dat), replace = TRUE), ] TrSet - Samdat[1:50,] TeSet - Samdat[51:75,] } Model- ModelFun(TrainData=TrSet ,TestData=TeSet ,mdat=dat,nsam=i) Y - Model$Y X - Model$X fit - lm(Y~X) return(fit) } -- View this message in context: http://r.789695.n4.nabble.com/Calling-R-object-from-R-function-tp4648714.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] R: net reclassification index after Cox survival analysis
Thanks to David Winsemius for the replay. i use the latest update of Hmisc package and I try as reported in the example: set.seed(1) library(survival) x1 - rnorm(400) x2 - x1 + rnorm(400) d.time - rexp(400) + (x1 - min(x1)) cens - runif(400,.5,2) death - d.time = cens d.time - pmin(d.time, cens) rcorrp.cens(x1, x2, Surv(d.time, death)) but to me it appears that NRI and IDi are not reported in the results: Dxy S.D. x1 more concordant x2 more concordant -8.212107e-02 1.370738e-01 4.589395e-01 5.410605e-01 nmissing uncensored Relevant Pairs 4.00e+02 0.00e+00 1.10e+01 4.262000e+03 Uncertain C X1 C X2 Dxy X1 1.553380e+05 9.920225e-01 9.258564e-01 9.840450e-01 Dxy X2 8.517128e-01 but only after: #rcorrp.cens(x1, x2, y) ## no censoring set.seed(1) x1 - runif(1000) x2 - runif(1000) y - sample(0:1, 1000, TRUE) rcorrp.cens(x1, x2, y) improveProb(x1, x2, y) thus censoring not allowed. Or I'm in error? Many thanks David Winsemius dwinsem...@comcast.net ha scritto: On Nov 7, 2012, at 6:54 AM, petre...@unina.it wrote: Dear all, I am interested to evaluate reclassification using net reclassification improvement and Integrated Discrimination Index IDI after survival analysis (Cox proportional hazards using stcox). I search a R package or a R code that specifically addresses the categorical NRI for time-to-event data in the presence of censored observation and, if possible, at different follow-up time points. I know that the ‘PredictABEL’ Package contains functions for NRI and IDI calculation but it is unclear for me if it allows censored observation. Package ‘survIDINRI’ calculates only continuous NRI and the function of Package ‘Hmisc’[#rcorrp.cens(x1, x2, y) ##] is only for no censored observations. ???. Doesn't its name , 'rcorrp.cens' suggest otherwise? Not to mention its description int the Hmisc Index: Rank Correlation for Paired Predictors with a Possibly Censored Response, and Integrated Discrimination Index. rcoop.cens is a fairly recent addition to Hmisc and I am looking at Hmisc version 3.10-1. If you are looking at a version that is a couple of years old, you may be seeing something different. The argument list you list looks like the one for improveProb(), which does not appear to handle censoring. The rcorrp.cens argument list is: rcorrp.cens(x1, x2, S, outx=FALSE, method=1) And the S object is a Surv-object. Many thanks. Sincerely, Mario Petretta Dpt. Internal Medicine, Cardiology and Heart Surgery Naples University Federico II - Italy __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. David Winsemius, MD Alameda, CA, USA Mario Petretta Dipartimento di Medicina Clinica Scienze Cardiovascolari e Immunologiche Facolt� di Medicina e Chirurgia Universit� di Napoli Federico II 081 - 7462233 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] save/load and package namespaces
Could someone explain to me what namespaces are loaded/saved when objects are saved? Specifically, I'm using this: save(list = ls(all.names = TRUE, envir = envir), file = name, envir = envir) to save out everything from an environment. Later, loading it on another machine, I'm surprised to see the load failing for being unable to load certain packages. Could anyone help me understand why this happens? Jamie Olson [[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] Aggregate data frame across columns
HI, Without data, it is a bit hard to know how your data looks like. Anyway, try this: set.seed(1) dat2-data.frame(matrix(sample(10:150,50,replace=TRUE),ncol=10)) names(dat2)-c(paste0(20040,1:4),paste0(20050,1:3),paste0(20080,1:3)) library(reshape) dat3-melt(dat2) dat3$variable-gsub((\\d{4}).*,\\1,dat3$variable) tapply(dat3$value,dat3$variable,FUN=sum) #2004 2005 2008 #1756 1094 1377 #or with(dat3,aggregate(value,by=list(variable),sum)) # Group.1 x #1 2004 1756 #2 2005 1094 #3 2008 1377 A.K. - Original Message - From: Keith Weintraub kw1...@gmail.com To: r-help@r-project.org Cc: Sent: Wednesday, November 7, 2012 12:32 PM Subject: [R] Aggregate data frame across columns Folks, I have a data frame with columns 200401, 200402, ..., 201207, 201208. These represent years/months. What would be the best way to sum these columns by year? What about by quarter? Thanks for your time, KW -- [[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] Aggregate data frame across columns
The best way to get an answer is to provide sample data and desired results (computed by hand or by any other available means). See http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example. In the vague question begets a vague answer department, I would use melt from the reshape package, and make some columns that contain unique key values for each time interval, and then use aggregate or ddply from the plyr package. --- 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. Keith Weintraub kw1...@gmail.com wrote: Folks, I have a data frame with columns 200401, 200402, ..., 201207, 201208. These represent years/months. What would be the best way to sum these columns by year? What about by quarter? Thanks for your time, KW -- [[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] HELP! Excel and R give me totally different regression results using the exact same data
On Nov 7, 2012, at 8:53 AM, frauke wrote: Hi David, hi Rui, thanks for your quick replies. I have replicated David's R results and confirmed them with Minitab. Though I'm not sure what you are trying to tell me with the code you wrote, David. Do you mean, I should use a dataframe rather than a matrix, or use the data= part of the lm() function? What I thought I was demonstrating was: a) we had different degrees of freedom suggesting that you made a major error in data preparation. I offered my hypothesis for how this happened, but since you failed to provide the requested code showing your data input steps, it was only a guess. b) I used a dataframe because that is the simplest way of preparing data for presentation to lm(). You can use a matrix to store data and present to lm(), but storing character representations of numeric data in a matrix ( as you appeared to be attempting) seems just plain ... wrong. Rui seems to be right, too. Excel's regression function doesn't work; I cannot replicate the Minitab and R results with it. According to the Microsoft website this is probably because the x- and y-values overlap. I am truly astonished that such a major bug doesn't at least have a major red flag to it. Many people are astonished, incredulous, aghast, astounded, (what is the right adjective?) that MS has allowed many errors to persist despite negative reviews by statisticians and mathematicians for decades. On the other hand my reading of the commentary suggest a different interpretation of the error conditions. MS says: Case 1: The x-value and y-value ranges overlap If the x-value and y-value ranges overlap, the LINEST worksheet function produces incorrect values in all result cells. Normal statistical probability disallows the values in the x and y ranges to overlap (duplicate each other). Do not overlap the x- and y-value ranges when referencing cells in the formula. I think that mean not that the mathematical ranges overlap but rather that the error occurs when the spreadsheet ranges overlap. -- 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] Excel Regression Function
Dear Frauke, good afternoon, Could you tell me which excel function didnt work for regression analysis and what excel version where you using? Best regards, Paul El 07/11/2012 11:55, frauke fh...@andrew.cmu.edu escribió: Hi David, hi Rui, thanks for your quick replies. I have replicated David's R results and confirmed them with Minitab. Though I'm not sure what you are trying to tell me with the code you wrote, David. Do you mean, I should use a dataframe rather than a matrix, or use the data= part of the lm() function? Rui seems to be right, too. Excel's regression function doesn't work; I cannot replicate the Minitab and R results with it. According to the Microsoft website this is probably because the x- and y-values overlap. I am truly astonished that such a major bug doesn't at least have a major red flag to it. Thank you! Frauke -- View this message in context: http://r.789695.n4.nabble.com/HELP-Excel-and-R-give-me-totally-different-regression-results-using-the-exact-same-data-tp4648648p4648723.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] Executing SAS Codes in R
Is there a way of executing SAS codes in R environment? Peter Maclean Department of Economics UDSM [[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] Calling R object from R function
On Wed, Nov 7, 2012 at 3:31 PM, frespider frespi...@hotmail.com wrote: Hi, Can you please help me with this please? What I am trying to do is call a vector from R function and used in the new function So I create 4 functions with these arguments M11 - function(TrainData,TestData,mdat,nsam) { ls - list() I have few statments one of them is vectx - c(,1,2,3,4,5,6,6) vectz - c(12,34,5,6,78,9,90) and then ls(vectx=vtecx,vectz=vectz) return(ls) } This is not valid assignment to a list. In fact, I'm rather surprised it doesn't throw an error... Michael __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R: net reclassification index after Cox survival analysis
On Nov 7, 2012, at 9:59 AM, petre...@unina.it wrote: Thanks to David Winsemius for the replay. i use the latest update of Hmisc package and I try as reported in the example: set.seed(1) library(survival) x1 - rnorm(400) x2 - x1 + rnorm(400) d.time - rexp(400) + (x1 - min(x1)) cens - runif(400,.5,2) death - d.time = cens d.time - pmin(d.time, cens) rcorrp.cens(x1, x2, Surv(d.time, death)) but to me it appears that NRI and IDi are not reported in the results: Dxy S.D. x1 more concordant x2 more concordant -8.212107e-02 1.370738e-01 4.589395e-01 5.410605e-01 nmissing uncensored Relevant Pairs 4.00e+02 0.00e+00 1.10e+01 4.262000e+03 Uncertain C X1 C X2 Dxy X1 1.553380e+05 9.920225e-01 9.258564e-01 9.840450e-01 Dxy X2 8.517128e-01 The NRI is not reported but an equivalent measure is. As far as getting output that is labeled the way you expect it, I also looked at the PredictABEL::reclassification function help page: The function also computes continuous NRI, which does not require any discrete risk categories and relies on the proportions of individuals with outcome correctly assigned a higher probability and individuals without outcome correctly assigned a lower probability by an updated model compared with the initial model. I think that is essentiality what rcorrp.cens is providing, just not with the labels you expected. The function requires predicted risks estimated by using two separate risk models. Predicted risks can be obtained using the functionsfitLogRegModel and predRisk or be imported from other methods or packages. So it would seem that you could use results from any censored survival models that had a predict method. -- David. but only after: #rcorrp.cens(x1, x2, y) ## no censoring set.seed(1) x1 - runif(1000) x2 - runif(1000) y - sample(0:1, 1000, TRUE) rcorrp.cens(x1, x2, y) improveProb(x1, x2, y) thus censoring not allowed. Or I'm in error? Many thanks David Winsemius dwinsem...@comcast.net ha scritto: On Nov 7, 2012, at 6:54 AM, petre...@unina.it wrote: Dear all, I am interested to evaluate reclassification using net reclassification improvement and Integrated Discrimination Index IDI after survival analysis (Cox proportional hazards using stcox). I search a R package or a R code that specifically addresses the categorical NRI for time-to-event data in the presence of censored observation and, if possible, at different follow-up time points. I know that the ‘PredictABEL’ Package contains functions for NRI and IDI calculation but it is unclear for me if it allows censored observation. Package ‘survIDINRI’ calculates only continuous NRI and the function of Package ‘Hmisc’[#rcorrp.cens(x1, x2, y) ##] is only for no censored observations. ???. Doesn't its name , 'rcorrp.cens' suggest otherwise? Not to mention its description int the Hmisc Index: Rank Correlation for Paired Predictors with a Possibly Censored Response, and Integrated Discrimination Index. rcoop.cens is a fairly recent addition to Hmisc and I am looking at Hmisc version 3.10-1. If you are looking at a version that is a couple of years old, you may be seeing something different. The argument list you list looks like the one for improveProb(), which does not appear to handle censoring. The rcorrp.cens argument list is: rcorrp.cens(x1, x2, S, outx=FALSE, method=1) And the S object is a Surv-object. Many thanks. Sincerely, Mario Petretta Dpt. Internal Medicine, Cardiology and Heart Surgery Naples University Federico II - Italy __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. David Winsemius, MD Alameda, CA, USA Mario Petretta Dipartimento di Medicina Clinica Scienze Cardiovascolari e Immunologiche Facolt� di Medicina e Chirurgia Universit� di Napoli Federico II 081 - 7462233 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. 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] Excel Regression Function
-Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On Behalf Of Paul Bernal Sent: Wednesday, November 07, 2012 10:17 AM To: frauke; r-help@r-project.org Subject: [R] Excel Regression Function Dear Frauke, good afternoon, Could you tell me which excel function didnt work for regression analysis and what excel version where you using? Best regards, Paul El 07/11/2012 11:55, frauke fh...@andrew.cmu.edu escribió: Hi David, hi Rui, thanks for your quick replies. I have replicated David's R results and confirmed them with Minitab. Though I'm not sure what you are trying to tell me with the code you wrote, David. Do you mean, I should use a dataframe rather than a matrix, or use the data= part of the lm() function? Rui seems to be right, too. Excel's regression function doesn't work; I cannot replicate the Minitab and R results with it. According to the Microsoft website this is probably because the x- and y-values overlap. I am truly astonished that such a major bug doesn't at least have a major red flag to it. Thank you! Frauke Part of the problem is that Frauke is apparently posting from Nabble and is not providing context. In the original post, the problem was reconciling output from linest in Excel with output from lm in R. The problem appears to have been incorrect preparation of data and/or misspecification of the call to lm in R, and a misspecification of the linest formula in Excel. I read the presented data into R and had no problem with the lm function (David Winsemius reported the same results). I also loaded the data into Excel and got the same results using linest function as I got in R. So, absent a reproducible example of the problem, I can only conclude operator error on the part of the OP in both cases. Dan Daniel Nordlund Olympia, WA 98504-5204 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] row index for max values of row groups
Dear list members! I am looking for ''nice solution'' for (maybe) simple problem. I need a code (small program) to calculate row index for max value (example below: df1$values) by groups (example below: df1$groups). df1 - data.frame( groups = c(1,1,1,1,1,2,2,2,3,3,3,3), values = c(1,1,1,2,1,1,2,3,2,1,4,3) ) df1 expected results 4 8 11 # row index of max values by group Thansk to all for help, OV [[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] Aggregate data frame across columns
HI, Forgot about the 2nd part (by quarter): set.seed(1) dat2-data.frame(matrix(sample(10:250,96,replace=TRUE),ncol=24)) names(dat2)-c(paste0(2004,paste0(0,1:9),sep=),paste0(2004,10:12),paste0(2005,paste0(0,1:9),sep=),paste0(2005,10:12)) library(reshape) dat3-melt(dat2) dat4-within(dat3,{variable-as.character(variable)}) library(xts) dat5-xts(dat4[,2],order.by=as.yearqtr(dat4[,1],%Y%m)) aggregate(dat5[,1],by=list(index(dat5)), sum) #2004 Q1 1534 #2004 Q2 1833 #2004 Q3 1445 #2004 Q4 1720 #2005 Q1 1444 #2005 Q2 1630 #2005 Q3 1780 #2005 Q4 1458 A.K. - Original Message - From: Keith Weintraub kw1...@gmail.com To: r-help@r-project.org Cc: Sent: Wednesday, November 7, 2012 12:32 PM Subject: [R] Aggregate data frame across columns Folks, I have a data frame with columns 200401, 200402, ..., 201207, 201208. These represent years/months. What would be the best way to sum these columns by year? What about by quarter? Thanks for your time, KW -- [[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] pivot table
HI, Could you tell me which version of R you are using? I guess paste0() works from R.2.14. YOu can use instead: colnames(res1)[-1]-gsub([\\_],.,paste(Lab,colnames(res1)[-1],sep=)) res1 # ID Lab1.A Lab1.N Lab2.N Lab3.N #1 a 1 1 1 0 #2 b 1 0 0 1 A.K. From: farnoosh sheikhi farnoosh...@yahoo.com To: arun smartpink...@yahoo.com Cc: R help r-help@r-project.org Sent: Wednesday, November 7, 2012 1:40 PM Subject: Re: [R] pivot table Hi there, Thanks forhelping. I really appreciate it. The only thing is I get this error: Error in gsub([\\_], ., paste0(Lab, colnames(res2)[-1])) : could not find function paste0 Thanks. Best,Farnoosh Sheikhi From: arun smartpink...@yahoo.com To: farnoosh sheikhi farnoosh...@yahoo.com Cc: R help r-help@r-project.org Sent: Tuesday, November 6, 2012 5:50 PM Subject: Re: [R] pivot table Hi, May be this helps: dat1-read.table(text= ID Lab Status a 1 N a 1 A a 2 N b 3 N b 1 A ,sep=,header=TRUE,stringsAsFactors=FALSE) library(reshape2) res1-dcast(dat1,ID~Lab+Status,value.var=Lab) res1[,-1]-ifelse(is.na(res1[,-1]),0,1) colnames(res1)[-1]-gsub([\\_],.,paste0(Lab,colnames(res1)[-1])) res1 # ID Lab1.A Lab1.N Lab2.N Lab3.N #1 a 1 1 1 0 #2 b 1 0 0 1 A.K. From: farnoosh sheikhi farnoosh...@yahoo.com To: arun smartpink...@yahoo.com Cc: R help r-help@r-project.org Sent: Tuesday, November 6, 2012 7:31 PM Subject: Re: [R] pivot table Hi again, I have another question for different data. Here is how my data looks like: ID Lab Status a 1 N a 1 A a 2 N b 3 N b 1 A I need to reformat this data as following. ID Lab1.N Lab1.A Lab2.N Lab2.A Lab3.N Lab3.A a 11 1000 b 0 1001 0 Thanks a lot:) Best,Farnoosh Sheikhi From: arun smartpink...@yahoo.com To: farnoosh sheikhi farnoosh...@yahoo.com Cc: R help r-help@r-project.org Sent: Tuesday, November 6, 2012 2:44 PM Subject: Re: [R] pivot table Hi, Is this okay? library(reshape2) dat1-read.table(text= ID Diag Proc DOB Gender a diag1 proc1 10/15/1969 M b diag2 proc2 8/25/1978 F c diag1 proc1 1/10/1985 M a diag3 proc3 10/15/1969 M b diag4 proc4 8/25/1978 F b diag6 proc5 8/25/1978 F ,sep=,header=TRUE,stringsAsFactors=FALSE) res-dcast(melt(dat1,id.var=c(ID,DOB,Gender)),ID+Gender+DOB~value) res[,4:13]-ifelse(is.na(res[,4:13]),0,1) res # ID Gender DOB diag1 diag2 diag3 diag4 diag6 proc1 proc2 proc3 proc4 #1 a M 10/15/1969 1 0 1 0 0 1 0 1 0 #2 b F 8/25/1978 0 1 0 1 1 0 1 0 1 #3 c M 1/10/1985 1 0 0 0 0 1 0 0 0 # proc5 #1 0 #2 1 #3 0 A.K. From: farnoosh sheikhi farnoosh...@yahoo.com To: arun smartpink...@yahoo.com Cc: R help r-help@r-project.org Sent: Tuesday, November 6, 2012 5:12 PM Subject: Re: [R] pivot table Hi there, Thanks a lot for your help, but Proc doesn't show in the result. I also want to assign 1 and 0 instead of the name of variables. Thanks a lot. Best,Farnoosh Sheikhi From: arun smartpink...@yahoo.com To: farnoosh sheikhi farnoosh...@yahoo.com Cc: R help r-help@r-project.org Sent: Tuesday, November 6, 2012 1:42 PM Subject: Re: [R] pivot table HI, It is better to dput() an example dataset to work with. May be this helps: dat1-read.table(text= ID Diag Proc DOB Gender a diag1 1 10/15/1969 M b diag2 2 8/25/1978 F c diag1 1 1/10/1985 M a diag3 3 10/15/1969 M b diag4 4 8/25/1978 F b diag4 5 8/25/1978 F ,sep=,header=TRUE,stringsAsFactors=FALSE) library(reshape) res-reshape(dat1,idvar=c(ID,DOB,Gender),v.names=Diag,timevar=Proc,direction=wide) res # ID DOB Gender Diag.1 Diag.2 Diag.3 Diag.4 Diag.5 #1 a 10/15/1969 M diag1 NA diag3 NA NA #2 b 8/25/1978 F NA diag2 NA diag4 diag4 #3 c 1/10/1985 M diag1 NA NA NA NA A.K. - Original Message - From: farnoosh sheikhi farnoosh...@yahoo.com To: r-help@R-project.org r-help@r-project.org Cc: Sent: Tuesday, November 6, 2012 3:37 PM Subject: [R] pivot table Hello, I have a data which looks like below: Some of the patients have multiple diagnosis. ID(200 patients) Diag (100 unique Diag-200 in general) Proc (50 uniqe Proc) DOB (200) Gender (200) a daig1 b diag2 c diag1 I want to reformat this data to : ID diag1 diag 2 diag 3.. diagx proc1 proc2
Re: [R] Executing SAS Codes in R
-Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On Behalf Of Peter Maclean Sent: Wednesday, November 07, 2012 10:25 AM To: R mailing list Subject: Re: [R] Executing SAS Codes in R Is there a way of executing SAS codes in R environment? Peter Maclean Department of Economics UDSM [[alternative HTML version deleted]] Peter, I think you will need to clarify what you are trying to do before you will get much useable help. Obviously, R will not run SAS programs/scripts. If you are asking if R can call SAS and have SAS run SAS code, then the answer is yes. There are other options for different levels of integration in between. So, what is it that you wish to accomplish? Dan Daniel Nordlund Olympia, WA 98504-5204 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 generate a set of random numbers that sum to 1 with uniform distribution of elements
What uniform distribution do you want for the columns? The average value of X_k given \sum X_i = 1 must be 1/n. If you start with X_i ~ U(0,1), the result must be skewed. If you generate X_i uniformly distributed on (0, 2/n), the conditional distribution given the sum is 1 will be less skewed. U - matrix(runif(1000*100)/50,nrow=1000) s - apply(U,1,sum) V - U/s qqplot(U[,1],V[,1]) albyn On Wed, Nov 07, 2012 at 05:02:10AM -0800, Bärbel wrote: Hi, I am looking for a way to generate a matrix of random numbers in a way that each row of the matrix would sum to 1 and that the numbers in the columns of the matrix would have a uniform distribution. So far I have found several ways to create random numbers that would sum to 1, but then the distribution of the individual elements is more or less skewed - there are much more small numbers than larger ones. Any help and suggestions? - Bärbel -- View this message in context: http://r.789695.n4.nabble.com/how-to-generate-a-set-of-random-numbers-that-sum-to-1-with-uniform-distribution-of-elements-tp4648695.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. -- Albyn Jones Reed College jo...@reed.edu __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] row index for max values of row groups
Hi, One method will be: row.names(df1[unlist(tapply(df1$values,df1$groups,FUN=function(x) x==max(x))),]) #[1] 4 8 11 #or row.names(df1[as.logical(ave(df1$values,df1$groups,FUN=function(x) x==max(x))),]) #[1] 4 8 11 A.K. - Original Message - From: Omphalodes Verna omphalodes.ve...@yahoo.com To: r-help@r-project.org r-help@r-project.org Cc: Sent: Wednesday, November 7, 2012 1:41 PM Subject: [R] row index for max values of row groups Dear list members! I am looking for ''nice solution'' for (maybe) simple problem. I need a code (small program) to calculate row index for max value (example below: df1$values) by groups (example below: df1$groups). df1 - data.frame( groups = c(1,1,1,1,1,2,2,2,3,3,3,3), values = c(1,1,1,2,1,1,2,3,2,1,4,3) ) df1 expected results 4 8 11 # row index of max values by group Thansk to all for help, OV [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] how to generate a set of random numbers that sum to 1 with uniform distribution of elements
Hi, This is a humble try. Matrix=function(n){Tab=cbind(runif(n,0,1)) for(i in 2:n) {x=NULL for(j in 1:n) {x=c(x,runif(1,0,1-sum(Tab[j,])))} Tab=cbind(Tab,x) } Table-Tab } n=1,2,3,4. Matrix(n) 1. The columns will follow uniform distribution with respective parameters. 2. The row sums will be approximately equal to '1'. 3. The discrepancy in 2nd Point can be removed if the number of columns are increased. I hope this works Best, Heramb M. Gadgil -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Bärbel Sent: Wednesday, November 07, 2012 6:32 PM To: r-help@r-project.org Subject: [R] how to generate a set of random numbers that sum to 1 with uniform distribution of elements Hi, I am looking for a way to generate a matrix of random numbers in a way that each row of the matrix would sum to 1 and that the numbers in the columns of the matrix would have a uniform distribution. So far I have found several ways to create random numbers that would sum to 1, but then the distribution of the individual elements is more or less skewed - there are much more small numbers than larger ones. Any help and suggestions? - Bärbel -- View this message in context: http://r.789695.n4.nabble.com/how-to-generate-a-set-of-random-numbers-that-sum-to-1-with-uniform-distribution-of-elements-tp4648695.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] save/load and package namespaces
Could someone explain to me what namespaces are loaded/saved when objects are saved? Specifically, I'm using this: save(list = ls(all.names = TRUE, envir = envir), file = name, envir = envir) to save out everything from an environment. Later, loading it on another machine, I'm surprised to see the load failing for being unable to load certain packages. Could anyone help me understand why this happens? Jamie Olson [[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] times-series HLM in R
Hello, If you have any advice on how to code a time-series HLM model in R? The code I have right now is: glmer(sale ~ agent_techmc*CultDistmc + ismc*CultDistmc + contactsmc*CultDistmc + pfmc + warranty + engineering_diff_res + Cust_internet + Cust_mobility_mobile + durationmc + (1| JOURNALTECHNAME)+ (1| Location), family = binomial(link=probit), data=Essay2res) I am not sure how to specify that CultDist is time-varying whereas some of the other models are time-invariant. The DV is also time-varying. Any help would be greatly appreciated. Tahnk you, Nita Umashankar [[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] R + Hadoop on Amazon
I've been using Amazon Elastic Mapreduce combined with RHadoop with great success. The only real problem is that the default JAVA_HOME doesn't points to a jdk that works with rJava, so you have to correct it. I've been meaning to do a writeup on it and will update you once it's up. Jamie Olson On Wed, Nov 7, 2012 at 5:32 AM, Vignesh Prajapati vign...@tatvic.comwrote: Hello All, Having some issue with local machine, I need to locate myself on Amazon for running R and Hadoop with Amazon instance. After searching a lot, I can't able to take a decision for choosing Image for Amazon instance. Can any one using R + Hadoop on Amazon. Thanks [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[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] pivot table
Hi there, Thanks forhelping. I really appreciate it. The only thing is I get this error: Error in gsub([\\_], ., paste0(Lab, colnames(res2)[-1])) : could not find function paste0 Thanks. Best,Farnoosh Sheikhi Cc: R help r-help@r-project.org Sent: Tuesday, November 6, 2012 5:50 PM Subject: Re: [R] pivot table Hi, May be this helps: dat1-read.table(text= ID Lab Status a 1 N a 1 A a 2 N b 3 N b 1 A ,sep=,header=TRUE,stringsAsFactors=FALSE) library(reshape2) res1-dcast(dat1,ID~Lab+Status,value.var=Lab) res1[,-1]-ifelse(is.na(res1[,-1]),0,1) colnames(res1)[-1]-gsub([\\_],.,paste0(Lab,colnames(res1)[-1])) res1 # ID Lab1.A Lab1.N Lab2.N Lab3.N #1 a 1 1 1 0 #2 b 1 0 0 1 A.K. Cc: R help r-help@r-project.org Sent: Tuesday, November 6, 2012 7:31 PM Subject: Re: [R] pivot table Hi again, I have another question for different data. Here is how my data looks like: ID Lab Status a 1 N a 1 A a 2 N b 3 N b 1 A I need to reformat this data as following. ID Lab1.N Lab1.A Lab2.N Lab2.A Lab3.N Lab3.A a 11 1000 b 0 1001 0 Thanks a lot:) Best,Farnoosh Sheikhi Cc: R help r-help@r-project.org Sent: Tuesday, November 6, 2012 2:44 PM Subject: Re: [R] pivot table Hi, Is this okay? library(reshape2) dat1-read.table(text= ID Diag Proc DOB Gender a diag1 proc1 10/15/1969 M b diag2 proc2 8/25/1978 F c diag1 proc1 1/10/1985 M a diag3 proc3 10/15/1969 M b diag4 proc4 8/25/1978 F b diag6 proc5 8/25/1978 F ,sep=,header=TRUE,stringsAsFactors=FALSE) res-dcast(melt(dat1,id.var=c(ID,DOB,Gender)),ID+Gender+DOB~value) res[,4:13]-ifelse(is.na(res[,4:13]),0,1) res # ID Gender DOB diag1 diag2 diag3 diag4 diag6 proc1 proc2 proc3 proc4 #1 a M 10/15/1969 1 0 1 0 0 1 0 1 0 #2 b F 8/25/1978 0 1 0 1 1 0 1 0 1 #3 c M 1/10/1985 1 0 0 0 0 1 0 0 0 # proc5 #1 0 #2 1 #3 0 A.K. Cc: R help r-help@r-project.org Sent: Tuesday, November 6, 2012 5:12 PM Subject: Re: [R] pivot table Hi there, Thanks a lot for your help, but Proc doesn't show in the result. I also want to assign 1 and 0 instead of the name of variables. Thanks a lot. Best,Farnoosh Sheikhi Cc: R help r-help@r-project.org Sent: Tuesday, November 6, 2012 1:42 PM Subject: Re: [R] pivot table HI, It is better to dput() an example dataset to work with. May be this helps: dat1-read.table(text= ID Diag Proc DOB Gender a diag1 1 10/15/1969 M b diag2 2 8/25/1978 F c diag1 1 1/10/1985 M a diag3 3 10/15/1969 M b diag4 4 8/25/1978 F b diag4 5 8/25/1978 F ,sep=,header=TRUE,stringsAsFactors=FALSE) library(reshape) res-reshape(dat1,idvar=c(ID,DOB,Gender),v.names=Diag,timevar=Proc,direction=wide) res # ID DOB Gender Diag.1 Diag.2 Diag.3 Diag.4 Diag.5 #1 a 10/15/1969 M diag1 NA diag3 NA NA #2 b 8/25/1978 F NA diag2 NA diag4 diag4 #3 c 1/10/1985 M diag1 NA NA NA NA A.K. - Original Message - From: farnoosh To: r-help@R-project.org r-help@r-project.org Cc: Sent: Tuesday, November 6, 2012 3:37 PM Subject: [R] pivot table Hello, I have a data which looks like below: Some of the patients have multiple diagnosis. ID(200 patients) Diag (100 unique Diag-200 in general) Proc (50 uniqe Proc) DOB (200) Gender (200) a daig1 b diag2 c diag1 I want to reformat this data to : ID diag1 diag 2 diag 3.. diagx proc1 proc2 proc3... procx DOB Gender a1011 20F Thanks a lot for your help and time. Best,Farnoosh Sheikhi [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Executing SAS Codes in R
I certainly hope not! There are of course many resources on R for SAS users and the like. -- Bert On Wed, Nov 7, 2012 at 10:24 AM, Peter Maclean pmaclean2...@yahoo.com wrote: Is there a way of executing SAS codes in R environment? Peter Maclean Department of Economics UDSM [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Bert Gunter Genentech Nonclinical Biostatistics Internal Contact Info: Phone: 467-7374 Website: http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] how to generate a set of random numbers that sum to 1 with uniform distribution of elements
This is a modified code if it helps. Matrix=function(n,simulations){Tab=cbind(runif(n,0,1)) for(i in 2:simulations) {x=NULL for(j in 1:n) {x=c(x,runif(1,0,1-sum(Tab[j,])))} Tab=cbind(Tab,x) } Table-Tab } Matrix(n,simulations) #Matrix(5,100) colnames(Table)=NULL Best, Heramb -Original Message- From: Heramb [mailto:heramb.gad...@gmail.com] Sent: Thursday, November 08, 2012 12:26 AM To: 'Bärbel'; 'r-help@r-project.org' Subject: RE: [R] how to generate a set of random numbers that sum to 1 with uniform distribution of elements Hi, This is a humble try. Matrix=function(n){Tab=cbind(runif(n,0,1)) for(i in 2:n) {x=NULL for(j in 1:n) {x=c(x,runif(1,0,1-sum(Tab[j,])))} Tab=cbind(Tab,x) } Table-Tab } n=1,2,3,4. Matrix(n) 1. The columns will follow uniform distribution with respective parameters. 2. The row sums will be approximately equal to '1'. 3. The discrepancy in 2nd Point can be removed if the number of columns are increased. I hope this works Best, Heramb M. Gadgil -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Bärbel Sent: Wednesday, November 07, 2012 6:32 PM To: r-help@r-project.org Subject: [R] how to generate a set of random numbers that sum to 1 with uniform distribution of elements Hi, I am looking for a way to generate a matrix of random numbers in a way that each row of the matrix would sum to 1 and that the numbers in the columns of the matrix would have a uniform distribution. So far I have found several ways to create random numbers that would sum to 1, but then the distribution of the individual elements is more or less skewed - there are much more small numbers than larger ones. Any help and suggestions? - Bärbel -- View this message in context: http://r.789695.n4.nabble.com/how-to-generate-a-set-of-random-numbers-that-sum-to-1-with-uniform-distribution-of-elements-tp4648695.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] row index for max values of row groups
Hello, Though my function is equal to Arun's, it's wrapped by a different way of returning the index. which(unlist(tapply(df1$values, df1$groups, FUN=function(x) x == max(x Hope this helps, Rui Barradas Em 07-11-2012 18:54, arun escreveu: Hi, One method will be: row.names(df1[unlist(tapply(df1$values,df1$groups,FUN=function(x) x==max(x))),]) #[1] 4 8 11 #or row.names(df1[as.logical(ave(df1$values,df1$groups,FUN=function(x) x==max(x))),]) #[1] 4 8 11 A.K. - Original Message - From: Omphalodes Verna omphalodes.ve...@yahoo.com To: r-help@r-project.org r-help@r-project.org Cc: Sent: Wednesday, November 7, 2012 1:41 PM Subject: [R] row index for max values of row groups Dear list members! I am looking for ''nice solution'' for (maybe) simple problem. I need a code (small program) to calculate row index for max value (example below: df1$values) by groups (example below: df1$groups). df1 - data.frame( groups = c(1,1,1,1,1,2,2,2,3,3,3,3), values = c(1,1,1,2,1,1,2,3,2,1,4,3) ) df1 expected results 4 8 11 # row index of max values by group Thansk to all for help, OV [[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] row index for max values of row groups
Note that the unlist(tapply()) algorithm depends on the groups column being in order. Here is one that works no matter how the data frame is ordered. which( with(df1, {tmp - logical(length(groups)) ; split(tmp, groups) - lapply(split(values, groups), function(x)x==max(x)) ; tmp})) [1] 4 8 11 df1[.Last.value, ] groups values 4 1 2 8 2 3 11 3 4 Try reordering the data.frame and you get essentially the same result: df1a - df1[c(12,1,11,2,10,3,9,4,8,5,7,6),] which( with(df1a, {tmp - logical(length(groups)) ; split(tmp, groups) - lapply(split(values, groups), function(x)x==max(x)) ; tmp})) [1] 3 8 9 df1a[.Last.value, ] groups values 11 3 4 4 1 2 8 2 3 Where unlist(tapply()) gives: which(unlist(tapply(df1a$values, df1a$groups, FUN=function(x) x == max(x)), use.names=FALSE)) [1] 4 6 10 df1a[.Last.value, ] groups values 2 1 1 3 1 1 5 1 1 You could sort the data.frame and unsort the result from the tapply approach: ord - with(df1a, order(groups)) with(df1a[ord,], which(unlist(tapply(values, groups, FUN=function(x) x == max(x)), use.names=FALSE)[order(ord)])) [1] 3 8 9 df1a[.Last.value, ] groups values 11 3 4 4 1 2 8 2 3 (The split()-split() is close to what ave() does, but ave() requires that the first argument to FUN have the same type as FUN's output but we want a numeric input and a logical output. Perhaps ave() could use a new argument to handle this kind of thing.) 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 Rui Barradas Sent: Wednesday, November 07, 2012 11:13 AM To: arun Cc: R help; Omphalodes Verna Subject: Re: [R] row index for max values of row groups Hello, Though my function is equal to Arun's, it's wrapped by a different way of returning the index. which(unlist(tapply(df1$values, df1$groups, FUN=function(x) x == max(x Hope this helps, Rui Barradas Em 07-11-2012 18:54, arun escreveu: Hi, One method will be: row.names(df1[unlist(tapply(df1$values,df1$groups,FUN=function(x) x==max(x))),]) #[1] 4 8 11 #or row.names(df1[as.logical(ave(df1$values,df1$groups,FUN=function(x) x==max(x))),]) #[1] 4 8 11 A.K. - Original Message - From: Omphalodes Verna omphalodes.ve...@yahoo.com To: r-help@r-project.org r-help@r-project.org Cc: Sent: Wednesday, November 7, 2012 1:41 PM Subject: [R] row index for max values of row groups Dear list members! I am looking for ''nice solution'' for (maybe) simple problem. I need a code (small program) to calculate row index for max value (example below: df1$values) by groups (example below: df1$groups). df1 - data.frame( groups = c(1,1,1,1,1,2,2,2,3,3,3,3), values = c(1,1,1,2,1,1,2,3,2,1,4,3) ) df1 expected results 4 8 11 # row index of max values by group Thansk to all for help, OV [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] HELP! Excel and R give me totally different regression results using the exact same data
Okay. Sorry for being vague in my earlier message. I had missed a few lines from your message because they were hiding well in my own email. I am really on the learning side with this, so it will take some time. Sorry. There seem to be two issues: (1) Me preparing the data incorrectly and (2) the data not being fit for regression. Right? Ad1. Point about header taken. As to using characters in a matrix, I extract the data from data files from the National Weather Service. I extract observations together with dates and location names. Each row comes consists of date, location and observations. I chose to store them in matrices because I can combine them to arrays. A matrix can only have one type of data, so I chose to leave them all as characters. When I proceed to do a regression analysis I transform the observations into numbers using as.numeric(). Do you have a different suggestion? Will R give me different results if I store characters in a matrix? Even though such excerpts from a long script aren't very informative, to be complete: collection - matrix(rep(NA,25),ncol=25)#collection will be a row of the output matrix later on. #extract dates collection[1]-paste(year,/,substring(.file,125,126),/,substring(.file,127,128),sep=) #extract observations collection[start.write+i]-(substring(input , fields[[i]][1] , fields[[i]][2])) Ad2. You mention heteroscedasticity and non-normality of residuals. To keep it short I had provided just a subset of the data I have (100 of 4000 matrix rows). But the same is true for the whole dataset. I attached the whole thing this time. test_complete.txt http://r.789695.n4.nabble.com/file/n4648759/test_complete.txt How do I deal with this? I admit I am pretty clueless in this case. Can I do meaningful regression at all? (I didn't expect test[,3] to be good predictor but had hopes for test[,2]. The residuals are definitely not normally distributed. They do not seem to related to either of the two predictors. What is the conclusion from that? Thanks for your patience! Frauke -- View this message in context: http://r.789695.n4.nabble.com/HELP-Excel-and-R-give-me-totally-different-regression-results-using-the-exact-same-data-tp4648648p4648759.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 generate a set of random numbers that sum to 1 with uniform distribution of elements
On Nov 7, 2012, at 10:48 AM, Albyn Jones wrote: What uniform distribution do you want for the columns? The average value of X_k given \sum X_i = 1 must be 1/n. If you start with X_i ~ U(0,1), the result must be skewed. If you generate X_i uniformly distributed on (0, 2/n), the conditional distribution given the sum is 1 will be less skewed. U - matrix(runif(1000*100)/50,nrow=1000) s - apply(U,1,sum) V - U/s qqplot(U[,1],V[,1]) Couldn't one just do: mat - matrix(runif(1000*10), ncol=10) # mean value per element = 0.5 mat2 - mat/rowSums(mat) # mean value of rowSums= 5 -- David. albyn On Wed, Nov 07, 2012 at 05:02:10AM -0800, Bärbel wrote: Hi, I am looking for a way to generate a matrix of random numbers in a way that each row of the matrix would sum to 1 and that the numbers in the columns of the matrix would have a uniform distribution. So far I have found several ways to create random numbers that would sum to 1, but then the distribution of the individual elements is more or less skewed - there are much more small numbers than larger ones. Any help and suggestions? - Bärbel -- View this message in context: http://r.789695.n4.nabble.com/how-to-generate-a-set-of-random-numbers-that-sum-to-1-with-uniform-distribution-of-elements-tp4648695.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. -- Albyn Jones Reed College jo...@reed.edu __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. 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] Executing SAS Codes in R
On Nov 7, 2012, at 19:34 , Bert Gunter wrote: I certainly hope not! fortune(reverse the procedure) There are of course many resources on R for SAS users and the like. -- Bert On Wed, Nov 7, 2012 at 10:24 AM, Peter Maclean pmaclean2...@yahoo.com wrote: Is there a way of executing SAS codes in R environment? Peter Maclean Department of Economics UDSM [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Bert Gunter Genentech Nonclinical Biostatistics Internal Contact Info: Phone: 467-7374 Website: http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- 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.
[R] customizing asix in xyplot in lattice
Hello, I have a time series dataset in long format (15 minute data over approximately 2 years). The data set is composed of time series of multiple sensors; much of the time series are duplicate dates and times, but of different lengths. I can plot the data converting the datetime to as.numeric, but they do not plot if I keep the data as POSIXlt. I know xyplot would plot the data if it was a zoo object, but my understanding (which could be wrong) is that I can’t convert to a zoo due to different lengths between my time series. Does anyone have experience plotting DateTime series in xyplot and having the axis labels be meaningful? The following is my working code so far xyplot(Cond ~ as.numeric(DateTime) | Sensor, data = dat, groups = id, layout=c(1, 2), type=l, xlab=Date, ylab=Relative Conductivity) I've incorporated scales but without luck xyplot(Cond ~ as.numeric(DateTime) | Sensor, data = dat, groups = id, layout=c(1, 2), type=l, xlab=Date, ylab=Relative Conductivity, scales = list(x = list(julian(dat$DateTime) ))) Thanks very much for any assistance. Kris -- View this message in context: http://r.789695.n4.nabble.com/customizing-asix-in-xyplot-in-lattice-tp4648755.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] pivot table
I'm using Revolution R Enterprise. This command worked perfectly. Thank you so much for your help and time:-) Best,Farnoosh Sheikhi Cc: R help r-help@r-project.org Sent: Wednesday, November 7, 2012 10:47 AM Subject: Re: [R] pivot table HI, Could you tell me which version of R you are using? I guess paste0() works from R.2.14. YOu can use instead: colnames(res1)[-1]-gsub([\\_],.,paste(Lab,colnames(res1)[-1],sep=)) res1 # ID Lab1.A Lab1.N Lab2.N Lab3.N #1 a 1 1 1 0 #2 b 1 0 0 1 A.K. Cc: R help r-help@r-project.org Sent: Wednesday, November 7, 2012 1:40 PM Subject: Re: [R] pivot table Hi there, Thanks forhelping. I really appreciate it. The only thing is I get this error: Error in gsub([\\_], ., paste0(Lab, colnames(res2)[-1])) : could not find function paste0 Thanks. Best,Farnoosh Sheikhi Cc: R help r-help@r-project.org Sent: Tuesday, November 6, 2012 5:50 PM Subject: Re: [R] pivot table Hi, May be this helps: dat1-read.table(text= ID Lab Status a 1 N a 1 A a 2 N b 3 N b 1 A ,sep=,header=TRUE,stringsAsFactors=FALSE) library(reshape2) res1-dcast(dat1,ID~Lab+Status,value.var=Lab) res1[,-1]-ifelse(is.na(res1[,-1]),0,1) colnames(res1)[-1]-gsub([\\_],.,paste0(Lab,colnames(res1)[-1])) res1 # ID Lab1.A Lab1.N Lab2.N Lab3.N #1 a 1 1 1 0 #2 b 1 0 0 1 A.K. Cc: R help r-help@r-project.org Sent: Tuesday, November 6, 2012 7:31 PM Subject: Re: [R] pivot table Hi again, I have another question for different data. Here is how my data looks like: ID Lab Status a 1 N a 1 A a 2 N b 3 N b 1 A I need to reformat this data as following. ID Lab1.N Lab1.A Lab2.N Lab2.A Lab3.N Lab3.A a 11 1000 b 0 1001 0 Thanks a lot:) Best,Farnoosh Sheikhi Cc: R help r-help@r-project.org Sent: Tuesday, November 6, 2012 2:44 PM Subject: Re: [R] pivot table Hi, Is this okay? library(reshape2) dat1-read.table(text= ID Diag Proc DOB Gender a diag1 proc1 10/15/1969 M b diag2 proc2 8/25/1978 F c diag1 proc1 1/10/1985 M a diag3 proc3 10/15/1969 M b diag4 proc4 8/25/1978 F b diag6 proc5 8/25/1978 F ,sep=,header=TRUE,stringsAsFactors=FALSE) res-dcast(melt(dat1,id.var=c(ID,DOB,Gender)),ID+Gender+DOB~value) res[,4:13]-ifelse(is.na(res[,4:13]),0,1) res # ID Gender DOB diag1 diag2 diag3 diag4 diag6 proc1 proc2 proc3 proc4 #1 a M 10/15/1969 1 0 1 0 0 1 0 1 0 #2 b F 8/25/1978 0 1 0 1 1 0 1 0 1 #3 c M 1/10/1985 1 0 0 0 0 1 0 0 0 # proc5 #1 0 #2 1 #3 0 A.K. Cc: R help r-help@r-project.org Sent: Tuesday, November 6, 2012 5:12 PM Subject: Re: [R] pivot table Hi there, Thanks a lot for your help, but Proc doesn't show in the result. I also want to assign 1 and 0 instead of the name of variables. Thanks a lot. Best,Farnoosh Sheikhi Cc: R help r-help@r-project.org Sent: Tuesday, November 6, 2012 1:42 PM Subject: Re: [R] pivot table HI, It is better to dput() an example dataset to work with. May be this helps: dat1-read.table(text= ID Diag Proc DOB Gender a diag1 1 10/15/1969 M b diag2 2 8/25/1978 F c diag1 1 1/10/1985 M a diag3 3 10/15/1969 M b diag4 4 8/25/1978 F b diag4 5 8/25/1978 F ,sep=,header=TRUE,stringsAsFactors=FALSE) library(reshape) res-reshape(dat1,idvar=c(ID,DOB,Gender),v.names=Diag,timevar=Proc,direction=wide) res # ID DOB Gender Diag.1 Diag.2 Diag.3 Diag.4 Diag.5 #1 a 10/15/1969 M diag1 NA diag3 NA NA #2 b 8/25/1978 F NA diag2 NA diag4 diag4 #3 c 1/10/1985 M diag1 NA NA NA NA A.K. - Original Message - From: farnoosh To: r-help@R-project.org r-help@r-project.org Cc: Sent: Tuesday, November 6, 2012 3:37 PM Subject: [R] pivot table Hello, I have a data which looks like below: Some of the patients have multiple diagnosis. ID(200 patients) Diag (100 unique Diag-200 in general) Proc (50 uniqe Proc) DOB (200) Gender (200) a daig1 b diag2 c diag1 I want to reformat this data to : ID diag1 diag 2 diag 3.. diagx proc1 proc2 proc3... procx DOB Gender a1011 20F Thanks a lot for your help and time. Best,Farnoosh Sheikhi [[alternative HTML version deleted]] __
[R] rJava not loading on Windows
Hi, I've successfully used it on a Linux setup, but when I try to load rJava on Windows 7 64-bit (session info below) I get: % R --vanilla library(rJava) Error : .onLoad failed in loadNamespace() for 'rJava', details: call: dirname(this$RuntimeLib) error: a character vector argument expected Error: package/namespace load failed for 'rJava' traceback() 2: stop(gettextf(package/namespace load failed for %s, sQuote(package)), call. = FALSE, domain = NA) 1: library(rJava) For the record, I have Java SDK installed and on the PATH: Sys.which(javac) javac C:\\PROGRA~1\\Java\\JDK17~1.0_0\\bin\\javac.exe system(javac -version) javac 1.7.0_02 Sys.which(java) java C:\\PROGRA~1\\Java\\JDK17~1.0_0\\bin\\java.exe system(java -version) java version 1.7.0_02 Java(TM) SE Runtime Environment (build 1.7.0_02-b13) Java HotSpot(TM) 64-Bit Server VM (build 22.0-b10, mixed mode) I'm sure there is at least one other Windows user who bumped into this. Any suggestions how to fix/troubleshoot this? Thanks, Henrik sessionInfo() R version 2.15.2 Patched (2012-11-04 r61084) Platform: x86_64-w64-mingw32/x64 (64-bit) locale: [1] LC_COLLATE=English_United States.1252 [2] LC_CTYPE=English_United States.1252 [3] LC_MONETARY=English_United States.1252 [4] LC_NUMERIC=C [5] LC_TIME=English_United States.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base loaded via a namespace (and not attached): [1] tools_2.15.2 packageDescription(rJava) Package: rJava Version: 0.9-3 Title: Low-level R to Java interface Author: Simon Urbanek simon.urba...@r-project.org Maintainer: Simon Urbanek simon.urba...@r-project.org Depends: R (= 2.5.0), methods Description: Low-level interface to Java VM very much like .C/.Call and friends. Allows creation of objects, calling methods and accessing fields. License: GPL-2 URL: http://www.rforge.net/rJava/ SystemRequirements: java Repository: CRAN Date/Publication: 2011-12-11 10:41:33 Built: R 2.15.2; i386-w64-mingw32; 2012-10-31 19:21:34 UTC; windows sessionInfo() R Under development (unstable) (2012-11-04 r61084) Platform: x86_64-w64-mingw32/x64 (64-bit) locale: [1] LC_COLLATE=English_United States.1252 [2] LC_CTYPE=English_United States.1252 [3] LC_MONETARY=English_United States.1252 [4] LC_NUMERIC=C [5] LC_TIME=English_United States.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base loaded via a namespace (and not attached): [1] tools_2.16.0 packageDescription(rJava) Package: rJava Version: 0.9-3.1 Title: Low-level R to Java interface Author: Simon Urbanek simon.urba...@r-project.org Maintainer: Simon Urbanek simon.urba...@r-project.org Depends: R (= 2.5.0), methods Description: Low-level interface to Java VM very much like .C/.Call and friends. Allows creation of objects, calling methods and accessing fields. License: GPL-2 URL: http://www.rforge.net/rJava/ SystemRequirements: java Repository: CRAN Date/Publication: 2011-12-11 10:41:33 Packaged: 2012-10-19 17:13:34 UTC; biocbuild Built: R 2.16.0; i386-w64-mingw32; 2012-10-19 17:36:53 UTC; windows __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] save/load and package namespaces
Stop being surprised. Loaded packages are not part of envir (whatever that is), nor are they part of the global environment. You have to reload any packages needed separately from the load call. --- 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. Jamie Olson inspired2apa...@gmail.com wrote: Could someone explain to me what namespaces are loaded/saved when objects are saved? Specifically, I'm using this: save(list = ls(all.names = TRUE, envir = envir), file = name, envir = envir) to save out everything from an environment. Later, loading it on another machine, I'm surprised to see the load failing for being unable to load certain packages. Could anyone help me understand why this happens? Jamie Olson [[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] Can you turn a string into a (working) symbol?
Others have shown you ways to do what you asked, and what you asked happens to also be FAQ 7.22 (but with terms different enough that that FAQ is not obvious). However the solutions that you are tending towards are running into the problems addressed in fortune(106) and fortune(236), the solutions are getting complex, prone to error or worse problems. Can you tell us more about what you are trying to accomplish? There may be a much simpler solution than the approach that you are trying. For example it may greatly simplify things if you store some of your objects in a list rather than the global environment and worked with them there: doppel - list() doppel$aa - 3.1416 doppel$bb - function(x) {x^2} r - 2 xx - c(aa, bb) out - doppel[[ xx[1] ]] * doppel[[ xx[2] ]](r) out [1] 12.5664 doppel[[ paste( 'a','a', sep='' ) ]] - 3 doppel$aa [1] 3 with(doppel, aa) [1] 3 On Sat, Nov 3, 2012 at 3:31 PM, andrewH ahoer...@rprogress.org wrote: Dear folks-- Suppose I have an expression that evaluates to a string, and that that string, were it not a character vector, would be a symbol. I would like a function, call it doppel(), that will take that expression as an argument and produce something that functions exactly like the symbol would have if I typed it in the place of the function of the expression. It should go as far along the path to evaluation as the symbol would have, and then stop, and be available for subsequent manipulation. For example, if aa - 3.1416 bb - function(x) {x^2} r - 2 xx - c(aa, bb) out - doppel(xx[1])*doppel(xx[2])(r) Then out should be 13.3664 Or similarly, after doppel(paste(a, a, sep='')) - 3 aa typing aa should return 3. Is there such a function? Can there be? I thought as.symbol would do this, but it does not. as.symbol (xx[1])*as.symbol (xx[2])(r) Error: attempt to apply non-function Looking forward to hearing from y'all.--andrewH -- View this message in context: http://r.789695.n4.nabble.com/Can-you-turn-a-string-into-a-working-symbol-tp4648343.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. -- Gregory (Greg) L. Snow Ph.D. 538...@gmail.com [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] c weirdness
is there a way to avoid c() appending .0 and .1 to seed? --8---cut here---start-8--- c(nons=1, seed=3) nons seed ## good! 13 c(nons=1, seed=tab[1]) nons seed.0 ## don't want .0! 1 2344600 c(nons=1, seed=tab[2]) nons seed.1 ## don't want .1! 1 6843 tab 0 1 23446006843 --8---cut here---end---8--- -- Sam Steingold (http://sds.podval.org/) on Ubuntu 12.04 (precise) X 11.0.11103000 http://www.childpsy.net/ http://pmw.org.il http://memri.org http://ffii.org http://openvotingconsortium.org Islam is a religion of Peace. Its adherents will kill anyone who disagrees. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] save/load and package namespaces
On Nov 7, 2012, at 9:50 AM, Jamie Olson wrote: Could someone explain to me what namespaces are loaded/saved when objects are saved? None. That's what require() or library() or source() are for. Specifically, I'm using this: save(list = ls(all.names = TRUE, envir = envir), file = name, envir = envir) to save out everything from an environment. You need to read more carefully: ?ls ?objects ?search Later, loading it on another machine, I'm surprised to see the load failing for being unable to load certain packages. Could anyone help me understand why this happens? `ls` with default settings only lists data and function objects that the user has defined. The history mechanism could be used to restore packages that were loaded during a session. ?history You should be able to see this by looking at what ls() produces. It does not generally return a listing of items in loaded packages. -- 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] LiblineaR: accept sparse matrices
Thibault, It would be nice if LiblineaR() accepted data in the form of a sparse matrix (it does not accept whatever e1071::read.matrix.csr returns). It would also be nice if there were functions to read/write files in the native liblinear file format; I am sure the original liblinear library provides at least the input code. Thanks! -- Sam Steingold (http://sds.podval.org/) on Ubuntu 12.04 (precise) X 11.0.11103000 http://www.childpsy.net/ http://iris.org.il http://pmw.org.il http://ffii.org http://dhimmi.com http://www.PetitionOnline.com/tap12009/ Sex is like air. It's only a big deal if you can't get any. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] c weirdness
On 07/11/2012 3:53 PM, Sam Steingold wrote: is there a way to avoid c() appending .0 and .1 to seed? Don't give it a named vector. You can use the unname() function to strip the names from tab: c(nons=1, seed=unname(tab[1])) --8---cut here---start-8--- c(nons=1, seed=3) nons seed ## good! 13 c(nons=1, seed=tab[1]) nons seed.0 ## don't want .0! 1 2344600 c(nons=1, seed=tab[2]) nons seed.1 ## don't want .1! 1 6843 tab 0 1 23446006843 --8---cut here---end---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] Executing SAS Codes in R
On Nov 7, 2012, at 10:34 AM, Bert Gunter wrote: I certainly hope not! There are of course many resources on R for SAS users and the like. One could even think of R-help as a distributed support group for recovering-SAS-users. -- Bert On Wed, Nov 7, 2012 at 10:24 AM, Peter Maclean pmaclean2...@yahoo.com wrote: Is there a way of executing SAS codes in R environment? Peter Maclean Department of Economics UDSM [[alternative HTML version deleted]] 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] Executing SAS Codes in R
On 08/11/12 09:09, peter dalgaard wrote: On Nov 7, 2012, at 19:34 , Bert Gunter wrote: I certainly hope not! fortune(reverse the procedure) See also fortune(SAS to R parser). cheers, Rolf __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] plm(): observations not used for modelling
Thank you for your help. That's an interesting point, I haven't thought about that. Altough I would find it strange that I get a model, where just some observations are missing, if the problem is due to invalid variable names. That's the first thing I will try to change. -- View this message in context: http://r.789695.n4.nabble.com/plm-observations-not-used-for-modelling-tp4648571p4648766.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
Hi, I've followed these steps: I set the MYSQL_HOME environmental variable like this: c:\PROGRA~1\MySQL\MYSQLS~1.5, then I opened a command prompt, got to the folder that contains the RMySQL_0.9-3.tar.gz file, and run the command: c:\Program Files\R\R-2.15.1\bin\x64\R CMD INSTALL RMySQL_0.9-3.tar.gz However, I keep getting those cygwin warnings. When I try to load the package: library(RMySQL) R tells that there is no package called 'RMySQL') My R version is 2.15.1 (x64), on Windows 7 (64-bit). I have installed MySQL Server 5.5 (64-bit), and MySQL Connector C 6.0.2 (64-bit). How could you solve those warnings you've mentioned? -- View this message in context: http://r.789695.n4.nabble.com/RMySQL-install-on-windows-tp4645629p4648769.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] A warning message in glht
Dear all, I was wondering if you could give me any suggestions/help on the following issue. So I carried out the analysis of my data using generalized linear model (glm). After that, to check for multiple comparisons, I applied the glht function from the multcomp package in R. The output, however, gave me a warning (please see below). So my question is whether this warning is smth that I should ignore or not. And if not, what I should do about it (I kind of know how to deal with this problem for categorical factors, however, in my data, one of the factors (AveScore) is continuous). Thanks a lot! Yuliia Simultaneous Tests for General Linear Hypotheses Multiple Comparisons of Means: Tukey Contrasts Fit: glm(formula = EW1 ~ AveScore + Speaker + File + factor(Bplace) + factor(Sex) + AveScore:File, family = binomial(link = logit), data = data.0) Linear Hypotheses: Estimate Std. Error z value Pr(|z|) In - A == 0 -0.9055 0.3573 -2.534 0.0302 * O - A == 0 -2.5638 0.3917 -6.545 0.001 *** O - In == 0 -1.6584 0.3766 -4.404 0.001 *** --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 (Adjusted p values reported -- single-step method) *Warning message: In mcp2matrix(model, linfct = linfct) : covariate interactions found -- default contrast might be inappropriate* -- View this message in context: http://r.789695.n4.nabble.com/A-warning-message-in-glht-tp4648770.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] sample from list
Ben, Can you provide a small example data set for inds so that we can run the code you have supplied? It's difficult for me to follow what you've got and where you're trying to go. Jean Benjamin Ward (ENV) b.w...@uea.ac.uk wrote on 11/06/2012 03:29:52 PM: Hi all, I have a list of genes present in 500 individuals, the individuals are the elements: Genes - lapply(1:nrow(inds),function(x) sample(1:1,inds $No_of_Genes,replace=TRUE)) (This was later written to a dataframe as well as kept as the list object: inds2 - data.frame(inds,Genes=I(Genes))) I also have a vector of how many of those genes are expressed in the individuals, this can also kept as a vector object or written to a data frame: inds2$No_Expressed_Genes - round(as.numeric(lapply(1:nrow (inds2),function(x) runif(1, min=10, max=50 I want to create another list which consists of each individuals expressed genes - essentially a subset of the total genes the individuals have in the Genes list, by sampling from the Genes list for each individual, the number of genes (values)in the Num_Expressed_Genes vector. i.e. if Num_Expressed_Genes = 3 then sample 3 values from the element in the Genes list. I can't quite figure it out though. So far I have the following: #Defines The number of expressed genes for each individual in my data frame. Num_Expressed_Genes - round(as.numeric(lapply(1:nrow (inds2),function(x) runif(1, min=10, max=50 #My attempts to apply the sample function to every element (individual organism) of the Genes list , to subset the genes expressed. Expressed_Genes - lapply(1:nrow(inds),function(x) sample (Genes,Num_Expressed_Genes, replace=FALSE)) Expressed_Genes - lapply(Genes,function(x) sample (Genes,Num_Expressed_Genes, replace=FALSE)) So far though I'm getting results like this: [[49]] [[49]][[1]] [1] 3540 27 5344 7278 9758 8077 ... [217] [[49]][[2]] [1] 740 3362 8588 8574 4371 1447 .. [340] When what I need is more: [[49]] [1] 6070 1106 6275 In a case where Num_Expressed_Genes = 3 and the values are taken from the much larger set of values for element (individual) 49 in my Genes list. I'm not sure what I'm doing wrong but it seems what is happening is instead of picking out a few values according to the Num_Expressed_Genes vector - as an example say 3 again, It's drawing a large number of values, if not all of them, from elements in the list, 3 times. Any help is greatly appreciated, I've thought of using loops to achieve the same task, but I'm trying to get my individual/genes/expressed genes data.frame set up for my individual based model and get it running using vectors and as little loops as possible. Thanks, Ben. [[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] save/load and package namespaces
On 07/11/2012 12:50 PM, Jamie Olson wrote: Could someone explain to me what namespaces are loaded/saved when objects are saved? None are loaded or saved when you save the object, but the names of some are saved. For example, library(Hmisc) # not normally loaded/attached x - zoom # copy a function from Hmisc save(x, file=x.RData) This will save a copy of a function from Hmisc to the file, but the function's environment is the Hmisc namespace. To properly load that function via load(x.RData) R will load the referenced namespace. You will see it appear in loadedNamespaces() after the load (assuming you still have Hmisc available). I believe this will also happen if you try to load an S4 object; you'll need to be able to load the namespace of its class. Duncan Murdoch Specifically, I'm using this: save(list = ls(all.names = TRUE, envir = envir), file = name, envir = envir) to save out everything from an environment. Later, loading it on another machine, I'm surprised to see the load failing for being unable to load certain packages. Could anyone help me understand why this happens? Jamie Olson [[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] plm(): observations not used for modelling
Restoring some context: DB wrote: The fuction plm only uses 286 of these observations (also if the model is changed to first differences and the effect to individual) and omits 23 observations due to na.action, but in my dataset they do not contain NAs. Is this due to the Transformation used in the plm function? If it is of any help, these are the observations that are omitted (which obviously don't contain NAs): 176 1995 Spanien 177 1996 Spanien 178 1997 Spanien Verkehrstote_Quote Autobahnlaenge_Quote PKW_Quote$Value LKW$Value DW I was surprised to [see] a $ in a variable name. Are you sure that is not the source of your problems? dat - data.frame(a$b = 1:3, d=1:3) Error: unexpected '=' in dat - data.frame(a$b = DW I would not expect the internal parsing routines to necessarily properly handle invalid column names. On Nov 7, 2012, at 12:26 PM, Daniel Bab. wrote: Thank you for your help. That's an interesting point, I haven't thought about that. Altough I would find it strange that I get a model, where just some observations are missing, if the problem is due to invalid variable names. That's the first thing I will try to change. I wasn't able to fully explain it either. You provided no code and the data was in a form that suggested some pathology in preparation. So I probably should have just suggested that you post all the output from : dput(dataframe[ c( 90:110 , 370:400), ]) ... so we could see what rows looked like from both excluded and non-excluded categories. -- View this message in context: We don't use Nabble. Omitting context makes your postings unintelligible for people expecting to see an email chain. Nabble makes it easy to include context (although editing is not so easy.) Sent from the R help mailing list archive at Nabble.com. Rhelp is a mailing list. -- 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] on Rclusterpp package usage
Hello I have a large dataset to make a cluster analysis and I'm trying to use Rclusterpp to do so. Nevertheless in a sample matrix analysis (see http://dl.dropbox.com/u/755659/gillnet.txt) I'm getting different results from Rclusterpp and hclust. Following the example from An Introduction to Rclusterpp ( http://cran.r-project.org/web/packages/Rclusterpp/vignettes/Rclusterpp.pdf) I got: dat.gillnet - read.csv(http://dl.dropbox.com/u/755659/gillnet.txt ,sep=,,dec=.,row.names=1) h - hclust(dist(dat.gillnet, method=euclidean), method=ward) r - Rclusterpp.hclust(dat.gillnet, method=ward, distance=euclidean) identical(h$merge, r$merge) all.equal(h$height, r$height) [1] FALSE If one plot the clusters will see the differences. But the purpose of the package is to deliver identical results as the stock stats::hclust implementation. Am I doing something wrong? Thanks for any help. Best regards, Antonio Olinto [[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] c weirdness
Your example doesn't work here - you didn't show what 'tab' was. Perhaps it was an output of table: tab - table(c(16,16,17,17,17)) c(n=1, seed=tab[2]) n seed.17 1 3 c(n=1, seed=unname(tab[2])) n seed 13 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 Sam Steingold Sent: Wednesday, November 07, 2012 12:53 PM To: r-help@r-project.org Subject: [R] c weirdness is there a way to avoid c() appending .0 and .1 to seed? --8---cut here---start-8--- c(nons=1, seed=3) nons seed ## good! 13 c(nons=1, seed=tab[1]) nons seed.0 ## don't want .0! 1 2344600 c(nons=1, seed=tab[2]) nons seed.1 ## don't want .1! 1 6843 tab 0 1 23446006843 --8---cut here---end---8--- -- Sam Steingold (http://sds.podval.org/) on Ubuntu 12.04 (precise) X 11.0.11103000 http://www.childpsy.net/ http://pmw.org.il http://memri.org http://ffii.org http://openvotingconsortium.org Islam is a religion of Peace. Its adherents will kill anyone who disagrees. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] c weirdness
Or use [[ instead of [ (assuming you are only selecting one item) tab - table(c(16,16,17,17,17)) c(n=1, seed=tab[2]) n seed.17 1 3 c(n=1, seed=unname(tab[2])) n seed 13 c(n=1, seed=tab[[2]]) n seed 13 c(n=1, seed=tab[[17]]) n seed 13 Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com -Original Message- From: William Dunlap Sent: Wednesday, November 07, 2012 1:24 PM To: 's...@gnu.org'; r-help@r-project.org Subject: RE: [R] c weirdness Your example doesn't work here - you didn't show what 'tab' was. Perhaps it was an output of table: tab - table(c(16,16,17,17,17)) c(n=1, seed=tab[2]) n seed.17 1 3 c(n=1, seed=unname(tab[2])) n seed 13 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 Sam Steingold Sent: Wednesday, November 07, 2012 12:53 PM To: r-help@r-project.org Subject: [R] c weirdness is there a way to avoid c() appending .0 and .1 to seed? --8---cut here---start-8--- c(nons=1, seed=3) nons seed ## good! 13 c(nons=1, seed=tab[1]) nons seed.0 ## don't want .0! 1 2344600 c(nons=1, seed=tab[2]) nons seed.1 ## don't want .1! 1 6843 tab 0 1 23446006843 --8---cut here---end---8--- -- Sam Steingold (http://sds.podval.org/) on Ubuntu 12.04 (precise) X 11.0.11103000 http://www.childpsy.net/ http://pmw.org.il http://memri.org http://ffii.org http://openvotingconsortium.org Islam is a religion of Peace. Its adherents will kill anyone who disagrees. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] fdrtool
Dear list members: I am using the package fdrtool to calculate qval from my input p values. My input pvalue ranged from 0.5-0. And the result I got for qval and lfdr are all much less than 0.01, I feel very confused about the result. The command used there is very easy: fdrtool(pvalue, statistic=pvalue) I am wondering if it is caused by the range of my pvalue or something else. If you have any similar experience, could you please share it with me? I will appreciate your comments very much! Best regards Li [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] how to generate a set of random numbers that sum to 1 with uniform distribution of elements
It sounds like you are trying to generate a uniform distribution on the simplex (e.g. compositional analysis where the values represent the proportion of each constituent in the whole). If so, you probably want the compositions package. Here's a simple example with just 3 parts so we can plot the results on a ternary plot: library(compositions) mat - runif.rcomp(1000, 3) plot(mat) -- David L Carlson Associate Professor of Anthropology Texas AM University College Station, TX 77843-4352 From: Heramb heramb.gadgil at gmail.com Date: Wed Nov 7 20:12:20 CET 2012 Re: [R] how to generate a set of random numbers that sum to 1 with uniform distribution of elements This is a modified code if it helps. Matrix=function(n,simulations){Tab=cbind(runif(n,0,1)) for(i in 2:simulations) {x=NULL for(j in 1:n) {x=c(x,runif(1,0,1-sum(Tab[j,])))} Tab=cbind(Tab,x) } Table-Tab } Matrix(n,simulations) #Matrix(5,100) colnames(Table)=NULL Best, Heramb -Original Message- From: Heramb [mailto:heramb.gadgil at gmail.com] Sent: Thursday, November 08, 2012 12:26 AM To: 'Bärbel'; 'r-help at r-project.org' Subject: RE: [R] how to generate a set of random numbers that sum to 1 with uniform distribution of elements Hi, This is a humble try. Matrix=function(n){Tab=cbind(runif(n,0,1)) for(i in 2:n) {x=NULL for(j in 1:n) {x=c(x,runif(1,0,1-sum(Tab[j,])))} Tab=cbind(Tab,x) } Table-Tab } n=1,2,3,4. Matrix(n) 1. The columns will follow uniform distribution with respective parameters. 2. The row sums will be approximately equal to '1'. 3. The discrepancy in 2nd Point can be removed if the number of columns are increased. I hope this works Best, Heramb M. Gadgil -Original Message- From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of Bärbel Sent: Wednesday, November 07, 2012 6:32 PM To: r-help at r-project.org Subject: [R] how to generate a set of random numbers that sum to 1 with uniform distribution of elements Hi, I am looking for a way to generate a matrix of random numbers in a way that each row of the matrix would sum to 1 and that the numbers in the columns of the matrix would have a uniform distribution. So far I have found several ways to create random numbers that would sum to 1, but then the distribution of the individual elements is more or less skewed - there are much more small numbers than larger ones. Any help and suggestions? - Bärbel - View this message in context: http://r.789695.n4.nabble.com/how-to-generate-a-set-of-random-numbers-that-s um-to-1-with-uniform-distribution-of-elements-tp4648695.html Sent from the R help mailing list archive at Nabble.com. __ R-help at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Executing SAS Codes in R
On Wed, Nov 7, 2012 at 4:03 PM, Rolf Turner rolf.tur...@xtra.co.nz wrote: On 08/11/12 09:09, peter dalgaard wrote: On Nov 7, 2012, at 19:34 , Bert Gunter wrote: I certainly hope not! fortune(reverse the procedure) See also fortune(SAS to R parser). Yes, all delightful and amusing! But perhaps the OP is looking for something as simple as system(sas -SYSIN path/to/sas/script.sas) Peter M., is that what you were after (calling SAS from R) or are you really looking to evaluate SAS code inside R? Best, Ista cheers, Rolf __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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.