[R] element-by-element comparison
Hi, I have a vector and a matrix. For example, A = [ 12 3 4]; B = [ 4 13 10 2 4 8]; I am comparing A to each column of B using AB[,ii], so the expected result is C = [ 10 01 00]; I am looking for a way to do this quickly instead of going through the for loop, but haven't had any luck yet? Any advice is appreciated. Thank you very much. Wendy -- View this message in context: http://r.789695.n4.nabble.com/element-by-element-comparison-tp3952301p3952301.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] reasonable theory?
SG == Spencer Graves spencer.gra...@structuremonitoring.com writes: SG If you know nothing about the black box except that its domain is SG bounded, then I would random sample uniformly from the domain. If the SG function is monotonically increasing in all variables, then you only SG need to test the two extreme points. If you know other things, you SG may be able to use the other logic. So I was overthinking it, then. As it turns out, for most of the functions in question, the convex hull of the range, as determined by uniform samples w/in the domain, was only slightly bigger than the convex hull of the full set of extreme points of the domain. And for my needs, then, the latter is a good-enough approximation of the former after all. Thanks! -JimC -- James Cloos cl...@jhcloos.com OpenPGP: 1024D/ED7DAEA6 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Redundancy canonical analysis plot problem in 3D using VEGAN, RGL, SCATTERPLOT3D and SFSMISC
Thomas.Rousseaubeaumier at uqtr.ca writes: Hi Guys, First, English is not my native language so sorry if the question is too difficult to understand. I can rephrase it if necessary. I noticed the following code to explain as clearly as possible the problems encountered. I am not able to add species scores from RDA results in 3D plot like i can in 2D plot. With the code i used , i get errors like ; ERROR dans t$sites : $ operator is invalid for atomic vectors, Erreur dans match.arg (display, items) : 'arg' should be one of xyz.convert, points3d, plane3d, box3d, points, arrows I saw that I can use other functions, but it is impossible to extract the 3D scores ( and add species to 3d plot ), Other fonctions works but, add elements in a 2D space. How can I add the species scores (sites and arrows are added correctly) to the 3D plot as with the 2D plot. Thomas, Function ordiplot3d() can only add one kind of scores (and I have no plans of changing this, but contributions are welcome). Adding species scores as text is possible but needs a bit work. One of the items you received from the plotting was xyz.convert (see your error message above). This is a function that changes 3D coordinates onto your plotting plane. You may proceed like this: sp - scores(ENVIESRDA, choices=1:3, display=species) text(pl$xyz.convert(sp), rownames(sp)) HTH, Jari Oksanen __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] element-by-element comparison
On 10/30/2011 02:51 PM, Wendy wrote: Hi, I have a vector and a matrix. For example, A = [ 12 3 4]; B = [ 4 13 10 2 4 8]; I am comparing A to each column of B using AB[,ii], so the expected result is C = [ 10 01 00]; I am looking for a way to do this quickly instead of going through the for loop, but haven't had any luck yet? Any advice is appreciated. Hi Wendy, You probably mean something like this: apply(B,2,``,A) which means roughly To each column of B, apply the function `` using A as the comparison values You will get a matrix of TRUE/FALSE values that are pretty much equivalent to your 0/1 values. Note that there are quite a few '*apply' functions and 'apply' is only guaranteed to work on arrays and matrices. 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.
Re: [R] element-by-element comparison
Hi Wendy, Most of the binary operators can deal with matrices and vectors natively: A-c(12,3,4) B-matrix(c(4,10,4,13,2,8),3,2) B [,1] [,2] [1,]4 13 [2,] 102 [3,]48 BA [,1] [,2] [1,] TRUE FALSE [2,] FALSE TRUE [3,] FALSE FALSE Cheers, Tsjerk On Sun, Oct 30, 2011 at 8:55 AM, Jim Lemon j...@bitwrit.com.au wrote: On 10/30/2011 02:51 PM, Wendy wrote: Hi, I have a vector and a matrix. For example, A = [ 12 3 4]; B = [ 4 13 10 2 4 8]; I am comparing A to each column of B using AB[,ii], so the expected result is C = [ 1 0 0 1 0 0]; I am looking for a way to do this quickly instead of going through the for loop, but haven't had any luck yet? Any advice is appreciated. Hi Wendy, You probably mean something like this: apply(B,2,``,A) which means roughly To each column of B, apply the function `` using A as the comparison values You will get a matrix of TRUE/FALSE values that are pretty much equivalent to your 0/1 values. Note that there are quite a few '*apply' functions and 'apply' is only guaranteed to work on arrays and matrices. 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. -- Tsjerk A. Wassenaar, Ph.D. post-doctoral researcher Molecular Dynamics Group * Groningen Institute for Biomolecular Research and Biotechnology * Zernike Institute for Advanced Materials University of Groningen The Netherlands __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] element-by-element comparison
Given that you want to compare columns, you can just do: A B If you wanted to compare rows, then it is more troublesome. One approach would be: rep(A, each=nrow(B)) B On 30/10/2011 03:51, Wendy wrote: Hi, I have a vector and a matrix. For example, A = [ 12 3 4]; B = [ 4 13 10 2 4 8]; I am comparing A to each column of B using AB[,ii], so the expected result is C = [ 10 01 00]; I am looking for a way to do this quickly instead of going through the for loop, but haven't had any luck yet? Any advice is appreciated. Thank you very much. Wendy -- View this message in context: http://r.789695.n4.nabble.com/element-by-element-comparison-tp3952301p3952301.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. -- Patrick Burns pbu...@pburns.seanet.com twitter: @portfolioprobe http://www.portfolioprobe.com/blog http://www.burns-stat.com (home of 'Some hints for the R beginner' and 'The R Inferno') __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] element-by-element comparison
Hi, To compare row wise is merely to compare column wise using the transpose matrix: t(B) A or t(t(B)A) if the result needs to be a matrix with dimensions equal to B. Cheers, Tsjerk On Sun, Oct 30, 2011 at 9:44 AM, Patrick Burns pbu...@pburns.seanet.com wrote: Given that you want to compare columns, you can just do: A B If you wanted to compare rows, then it is more troublesome. One approach would be: rep(A, each=nrow(B)) B On 30/10/2011 03:51, Wendy wrote: Hi, I have a vector and a matrix. For example, A = [ 12 3 4]; B = [ 4 13 10 2 4 8]; I am comparing A to each column of B using AB[,ii], so the expected result is C = [ 1 0 0 1 0 0]; I am looking for a way to do this quickly instead of going through the for loop, but haven't had any luck yet? Any advice is appreciated. Thank you very much. Wendy -- View this message in context: http://r.789695.n4.nabble.com/element-by-element-comparison-tp3952301p3952301.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. -- Patrick Burns pbu...@pburns.seanet.com twitter: @portfolioprobe http://www.portfolioprobe.com/blog http://www.burns-stat.com (home of 'Some hints for the R beginner' and 'The R Inferno') __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Tsjerk A. Wassenaar, Ph.D. post-doctoral researcher Molecular Dynamics Group * Groningen Institute for Biomolecular Research and Biotechnology * Zernike Institute for Advanced Materials University of Groningen The Netherlands __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] element-by-element comparison
The recycling rule should apply here (see 'An Introduction to R', Sec. 5.4.1; and ?Comparison, under 'Value'). x - -5:5 A - cbind(x, x, x) vec - numeric(length(x)) A vec ### recycling apply(A,2,``,vec) ### using apply vec - numeric(11) + 3; vec[1] - -6 A vec ### recycling apply(A,2,``,vec) ### using apply It should be faster than apply, but then apply seems much clearer. Regards, Enrico Am 30.10.2011 08:55, schrieb Jim Lemon: On 10/30/2011 02:51 PM, Wendy wrote: Hi, I have a vector and a matrix. For example, A = [ 12 3 4]; B = [ 4 13 10 2 4 8]; I am comparing A to each column of B using AB[,ii], so the expected result is C = [ 1 0 0 1 0 0]; I am looking for a way to do this quickly instead of going through the for loop, but haven't had any luck yet? Any advice is appreciated. Hi Wendy, You probably mean something like this: apply(B,2,``,A) which means roughly To each column of B, apply the function `` using A as the comparison values You will get a matrix of TRUE/FALSE values that are pretty much equivalent to your 0/1 values. Note that there are quite a few '*apply' functions and 'apply' is only guaranteed to work on arrays and matrices. 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. -- Enrico Schumann Lucerne, Switzerland http://nmof.net/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] element-by-element comparison
On 30.10.2011 04:51, Wendy wrote: Hi, I have a vector and a matrix. For example, A = [ 12 3 4]; B = [ 4 13 10 2 4 8]; I am comparing A to each column of B using AB[,ii], so the expected result is C = [ 10 01 00]; This list is about R rather than Matlab dialects. For R: AB gives logical values and, e.g., apply(AB, 2, as.integer) converts to integer. Uwe Ligges I am looking for a way to do this quickly instead of going through the for loop, but haven't had any luck yet? Any advice is appreciated. Thank you very much. Wendy -- View this message in context: http://r.789695.n4.nabble.com/element-by-element-comparison-tp3952301p3952301.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] calculating joint entropy of many variables
Hello list. I need help (e.g., a reference, code, package, etc.) in calculating the joint entropy of many variables (some sure highly mutually-informative and some not). Is there anyone here who knows a computationally-efficient solution (such as an R package)? I appreciate you help ... Best, Reza [[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] Rpart
Dear users, I'm using rpart for classification trees, but my code isn't working when I try to use all the variables in my data frame. This data frame was created from a data frame with 1775 variables, but I choose only 13. arv13-rpart(iv~.,data=gn,method=class,parms=list(split=information)) #Error: Error in `[.data.frame`(frame, predictors) : undefined columns selected gn is a data.frame, so I don't understand where is my mistake. If I read the data.frame from a txt file g13.txt previously saved, instead creating the data.frame gn from the data frame with 1775 variables (columns), it works. My question is: which properties must the data file have to use rpart doing iv ~ . ? Thank you very much, My best regards Luísa Sêco iv 754 923 972 1058 1223 2118 2593 2605 2777 3055 3186 3193 3393 1 3 1 0 1 1 1 1 0 0 0 1 0 0 0 2 2 1 1 1 1 0 0 1 0 0 0 1 1 1 3 2 1 0 1 1 0 0 1 1 0 0 1 0 1 4 3 1 1 1 1 0 0 0 0 0 1 1 0 0 5 2 1 1 1 1 0 0 1 0 0 1 1 0 0 6 2 1 1 1 1 0 0 1 0 0 0 0 1 1 7 1 1 0 1 1 0 1 0 1 0 0 0 1 1 8 3 1 1 1 1 0 1 0 0 0 0 1 1 1 9 2 1 0 1 1 0 0 0 0 0 1 0 0 1 10 2 1 1 0 1 0 0 1 0 0 1 0 1 0 11 2 1 0 1 1 0 0 0 0 0 1 0 0 1 12 1 1 1 1 1 1 1 0 1 0 1 0 0 0 13 1 1 0 1 1 1 0 1 1 1 0 0 1 0 14 1 1 1 1 1 1 1 0 1 0 0 0 1 0 15 2 1 0 1 1 1 0 1 0 0 1 1 1 0 16 1 1 0 1 0 0 0 1 0 1 1 0 1 0 17 1 0 1 1 1 1 1 0 1 1 0 0 1 0 18 2 1 1 1 1 0 0 0 0 0 1 0 0 0 19 1 0 0 1 1 0 1 1 1 0 1 0 1 0 20 3 1 0 1 1 0 1 0 1 0 0 0 1 1 21 2 1 0 0 1 0 0 0 0 0 1 0 0 1 22 1 0 0 1 1 1 1 1 1 0 1 0 1 0 23 1 0 0 1 0 0 0 1 0 0 1 0 1 0 24 2 0 1 1 1 1 0 1 0 0 1 0 1 1 25 1 0 0 1 1 0 0 0 1 1 0 0 1 0 26 3 1 0 0 1 0 0 0 0 0 1 0 1 1 27 2 1 1 0 1 0 0 1 0 0 1 1 0 0 28 3 1 1 1 1 0 0 0 1 0 0 0 1 0 29 1 0 0 1 0 1 0 0 1 1 1 0 1 0 30 3 1 0 0 1 0 1 1 1 0 0 1 1 1 31 3 0 0 0 1 0 0 0 0 0 0 0 1 1 32 3 0 0 1 1 1 1 1 0 1 0 0 1 0 33 1 1 1 1 1 1 1 0 1 1 1 0 1 0 34 1 1 0 1 0 1 0 0 1 0 0 0 0 0 35 3 1 1 1 1 0 0 0 1 0 1 0 1 1 36 2 1 1 0 1 0 0 0 0 1 1 0 1 1 37 3 1 0 1 1 0 0 1 0 0 0 0 1 1 38 3 0 0 1 1 0 1 0 0 0 0 0 1 1 39 2 1 1 1 1 0 0 1 0 0 1 1 1 1 40 2 1 1 1 1 0 0 1 0 1 0 0 1 1 41 3 1 1 1 1 1 1 0 1 1 1 1 1 1 42 3 1 0 1 1 0 1 0 1 1 1 0 1 0 43 1 0 0 1 1 0 0 0 1 1 0 0 1 0 44 3 0 1 0 1 0 0 1 1 0 1 0 1 0 45 2 1 1 1 1 1 0 0 0 0 0 0 1 0 46 3 1 1 1 1 0 0 0 1 0 0 1 1 1 47 2 1 0 0 1 0 0 0 0 0 1 0 0 1 48 1 0 0 1 1 1 0 1 1 1 0 1 1 0 49 3 1 1 0 1 0 0 0 1 0 0 0 1 0 50 2 1 1 0 1 1 0 1 1 0 1 1 1 1 51 2 1 0 1 1 1 0 1 1 0 1 1 0 1 52 1 1 0 1 1 1 0 0 1 1 0 0 1 0 53 3 1 1 0 1 0 0 0 0 0 1 1 0 0 54 1 1 0 0 1 1 0 1 0 0 0 0 1 1 55 2 1 0 0 1 0 0 1 1 0 1 1 0 0 56 2 1 0 0 1 0 0 1 1 0 1 1 0 1 57 2 1 1 0 1 0 0 1 1 1 0 1 1 1 58 3 1 1 0 1 0 0 0 0 0 0 0 1 0 59 3 1 1 0 1 0 0 0 0 0 0 0 1 0 60 1 1 0 1 1 0 0 0 0 1 1 0 1 0 61 1 1 1 0 0 0 0 0 0 0 1 1 1 1 62 2 1 1 0 1 0 0 1 0 1 1 1 0 1 63 2 1 1 1 1 0 0 1 0 0 1 0 1 1 64 2 1 1 1 1 0 0 1 0 0 1 0 1 1 65 1 1 0 1 0 1 1 0 1 1 0 0 1 0 66 2 1 1 0 1 0 0 1 0 1 1 1 0 0 67 2 1 0 0 1 0 0 0 0 0 1 0 1 0 68 2 1 1 0 1 0 0 0 0 0 1 0 0 0 69 2 1 1 0 1 0 0 1 1 0 1 1 1 1 70 1 1 0 0 1 1 0 0 0 0 0 0 1 1 71 3 1 1 0 1 0 0 0 1 0 0 1 1 1 72 3 1 0 1 1 1 0 0 1 1 0 0 0 0 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Maximization
On Tue, Oct 25, 2011 at 12:04 PM, Eliano eliano.m.marq...@gmail.com wrote: hi people, I'm trying to maximize this function: fn= function (x) {x[1]^2+5*x[2]^2} with this restriction fn1 = function (x) {x[1]+x[2] =5} Can someone help me how to procedure this? I tried in the alabama and genoud package but i have problems with the setting of constrains. Your problem corresponds to a quadratic programming problem. Thus, you can solve it with the following package: http://cran.r-project.org/web/packages/quadprog/index.html Hope this helps you, Paul __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] jarquebera_test_results
Hi! I got a loop where i print out the results of Jarque Bera tests, but I have to put, the p-values in a vector. Can you help me how to do it in an effective way and not just typing in the results to a vector? Thanks a lot, here is the code: for(i in 1:60){ print(jarque.bera.test(loghozamok[((20*(i-1))+1):(20*(i+11))]))} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] why the a[-indx] does not work?
Dear all, Could you please explain me why OverloadsTesT [1] 1 0 1 0 0 0 0 0 0 0 a-matrix(data=seq(1,10),nrow=10) a [,1] [1,]1 [2,]2 [3,]3 [4,]4 [5,]5 [6,]6 [7,]7 [8,]8 [9,]9 [10,] 10 a[-OverloadsTesT] [1] 2 3 4 5 6 7 8 9 10 the last line does not remove the first and third element and only does the first element.? What I want to do is for zeros to return the elements and for any positive value to remove it. What I am doing wrong? B.R Alex [[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] Summary stats in table
On 11-10-24 7:16 PM, Hadley Wickham wrote: On Mon, Oct 24, 2011 at 5:39 AM, Duncan Murdoch murdoch.dun...@gmail.com wrote: Suppose I have data like this: A- sample(letters[1:3], 1000, replace=TRUE) B- sample(LETTERS[1:2], 1000, replace=TRUE) x- rnorm(1000) I can get a table of means via tapply(x, list(A, B), mean) and I can add the marginal means to this using cbind/rbind: main- tapply(x, list(A,B), mean) Amargin- tapply(x, list(A), mean) Bmargin- tapply(x, list(B), mean) rbind(cbind(main, all=Amargin),all=c(Bmargin, mean(x))) But this is tedious. Has some package got some code that makes this easier? Have a look at reshape2::add_margins - it's not super efficient, but I think cool because it works for arbitrarily many dimensions. Hadley I actually was hoping for something more like what I remember vaguely from SAS PROC TABULATE, which I haven't used in about 20 years. Anyway, I decided to go ahead and write it; it's fun enough that I'll probably put it on CRAN eventually. Here's what it currently gives: tabular( x*mean*(A+1) ~ (B+1) ) B A BAll x mean A a 0.05058 0.02308 0.036279 b 0.02878 0.01188 0.020953 c 0.06869 -0.08192 -0.003033 All 0.04906 -0.01511 0.017875 and here's a more elaborate example: example(tabular) tabulr tabular( (Species + 1) ~ (n=1) + Format(digits=2)* tabulr+ (Sepal.Length + Sepal.Width)*(mean + sd), data=iris ) Sepal.Length Sepal.Width n mean sd meansd Species setosa 50 5.01 0.35 3.430.38 versicolor 50 5.94 0.52 2.770.31 virginica 50 6.59 0.64 2.970.32 All150 5.84 0.83 3.060.44 Duncan Murdoch __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] why the a[-indx] does not work?
On 11-10-30 2:52 PM, Alaios wrote: Dear all, Could you please explain me why OverloadsTesT [1] 1 0 1 0 0 0 0 0 0 0 a-matrix(data=seq(1,10),nrow=10) a [,1] [1,]1 [2,]2 [3,]3 [4,]4 [5,]5 [6,]6 [7,]7 [8,]8 [9,]9 [10,] 10 a[-OverloadsTesT] [1] 2 3 4 5 6 7 8 9 10 the last line does not remove the first and third element and only does the first element.? What I want to do is for zeros to return the elements and for any positive value to remove it. What I am doing wrong? You are asking it to remove item 1, and it does. If you want to negate a logical vector, you need to use a logical vector and negate it, e.g. OverloadsTesT - as.logical(OverloadsTeSt) a[!OverloadsTest] Duncan Murdoch __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Generic Plot and save function
Dear all, I was reading for the nice ... parameter option in R, which if I got it right it is used to pass other parameter to some other function inside your function for example plot_duty_cycle- function(data, ...) { barplot(duty_cycle_per_bin(data), ...) } I can put some parameters to pass inside the barplot function inside my function. I would like to ask you if there is a smart way to also put some parameter in the input section of my function so to also save the plot in the given path I am thinking for something like that plot_duty_cycle- function(data, ...) { barplot(duty_cycle_per_bin(data), ...) if (is(path) { save somehow the plot in the path} } Could you please give me a nice hint for that case B.R Alex [[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] why the a[-indx] does not work?
a[overLoadTesT==0] [1] 2 4 5 6 7 8 9 10 Look into help('[') or help('Subscript') to see how integer and logical (Boolean) subscripts differ. 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 Alaios Sent: Sunday, October 30, 2011 11:52 AM To: R-help@r-project.org Subject: [R] why the a[-indx] does not work? Dear all, Could you please explain me why OverloadsTesT [1] 1 0 1 0 0 0 0 0 0 0 a-matrix(data=seq(1,10),nrow=10) a [,1] [1,]1 [2,]2 [3,]3 [4,]4 [5,]5 [6,]6 [7,]7 [8,]8 [9,]9 [10,] 10 a[-OverloadsTesT] [1] 2 3 4 5 6 7 8 9 10 the last line does not remove the first and third element and only does the first element.? What I want to do is for zeros to return the elements and for any positive value to remove it. What I am doing wrong? B.R Alex [[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] Normality tests on groups of rows in a data frame, grouped based on content in other columns
Dear R users, I have a data frame in the form below, on which I would like to make normality tests on the values in the ExpressionLevel column. head(df) ID Plant Tissue Gene ExpressionLevel 1 1 p1 t1 g1 366.53 2 2 p1 t1 g2 0.57 3 3 p1 t1 g311.81 4 4 p1 t2 g1 498.43 5 5 p1 t2 g2 2.14 6 6 p1 t2 g3 7.85 I would like to make the tests on every group according to the content of the Plant, Tissue and Gene columns. My first problem is how to run a function for all these sub groups. I first thought of making subsets: group1 - subset(df, Plant==p1 Tissue==t1 Gene==g1) group2 - subset(df, Plant==p1 Tissue==t1 Gene==g2) group3 - subset(df, Plant==p1 Tissue==t1 Gene==g3) group4 - subset(df, Plant==p1 Tissue==t2 Gene==g1) group5 - subset(df, Plant==p1 Tissue==t2 Gene==g2) group6 - subset(df, Plant==p1 Tissue==t2 Gene==g3) etc... But that would be very time consuming and I would like to be able to use the code for other data frames... I have also tried to store these in a list, which I am looping through, running the tests, something like this: alist=list(group1, group2, group3, group4, group5, group6) for(i in alist) { print(shapiro.test(i$ExpressionLevel)) print(pearson.test(i$ExpressionLevel)) print(pearson.test(i$ExpressionLevel, adjust=FALSE)) } But, there must be an easier and more elegant way of doing this... I found the example below at http://stackoverflow.com/questions/4716152/why-do-r-objects-not-print-in-a-function-or-a-for-loop. I think might be used for the printing of the results, but I do not know how to adjust for my data frame, since the functions are applied on several columns instead of certain rows in one column. DF - data.frame(A = rnorm(100), B = rlnorm(100)) obj2 - lapply(DF, shapiro.test) tab2 - lapply(obj, function(x) c(W = unname(x$statistic), p.value = x$p.value)) tab2 - data.frame(do.call(rbind, tab2)) printCoefmat(tab2, has.Pvalue = TRUE) Finally, I have found several different functions for testing for normality, but which one(s) should I choose? As far as I can see in the help files they only differ in the minimum number of samples required. Thanks in advance! Kind regards, Joel [[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] Confidence interval for Support Vector Regression
Hi, Is it possible to calculate confidence intervals for support vector regression? In the ksvm{kernlab} manual, it says that it supports confidence intervals for regression. However, i couldn't find any information about how to calculate confidence interval. Do you have any documents or examples about this or any other suggestions? Thanks in advance -- [[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] why the a[-indx] does not work?
probably you mean For â[â-indexing only: âiâ, âjâ, â...â can be logical vectors, indicating elements/slices to select. Such vectors are recycled if necessary to match the corresponding extent. âiâ, âjâ, â...â can also be negative integers, indicating elements/slices to leave out of the selection. How can i convert the positives to TRUE and zeros and FALSE? From: William Dunlap wdun...@tibco.com Sent: Sunday, October 30, 2011 9:17 PM Subject: RE: [R] why the a[-indx] does not work?  a[overLoadTesT==0]  [1] 2 4 5 6 7 8 9 10 Look into help('[') or help('Subscript') to see how integer and logical (Boolean) subscripts differ. 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 Alaios Sent: Sunday, October 30, 2011 11:52 AM To: R-help@r-project.org Subject: [R] why the a[-indx] does not work? Dear all, Could you please explain me why OverloadsTesT [1] 1 0 1 0 0 0 0 0 0 0 a-matrix(data=seq(1,10),nrow=10) a [,1] [1,]  1 [2,]  2 [3,]  3 [4,]  4 [5,]  5 [6,]  6 [7,]  7 [8,]  8 [9,]  9 [10,] 10 a[-OverloadsTesT] [1] 2 3 4 5 6 7 8 9 10 the last line does not remove the first and third element and only does the first element.? What I want to do is for zeros to return the elements and for any positive value to remove it. What I am doing wrong? B.R Alex    [[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] Graphics Reciprocal labeling
I suppose I wasn't clear enough. For some purposes, I want to label the horizontal axis like the first label-line below. It separates the longer periods better even though it squashes the shorter ones. The real scale for the corresponding plotted data is the second label-line. The same-range linear-in-frequency horizontal scale would be the third label-line, giving the period reciprocal labeling in the fourth label-line. |--|--|--|--|--|--|--|--|--|--| 100.0 50.00 25.00 12.50 6.250 3.125 1.563 .7813 .3906 .1953 .0977 period .0100 .0200 .0400 .0800 .1600 .3200 .6400 1.280 2.560 5.120 10.24 frequency .0100 1.033 2.056 3.079 4.102 5.125 6.148 7.171 8.194 9.217 10.24 frequency 100.0 .9681 .4864 .3248 .2438 .1951 .1627 .1395 .1220 .1085 .0977 period I will sometimes want to label the axis nonequidistantly like this (maybe manually) |--|--|---|--|---|--|--|--|---| 100yr 50yr 25yr 10yr 5yr 2mo 1yr 6mo3mo 35da Can this scale be done, and how? -- View this message in context: http://r.789695.n4.nabble.com/Graphics-Reciprocal-labeling-tp3949054p3953895.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] why the a[-indx] does not work?
ifelse(myvec == 0, FALSE, TRUE) # set 0 to FALSE, other values to TRUE On Sun, Oct 30, 2011 at 3:50 PM, Alaios ala...@yahoo.com wrote: probably you mean For ‘[’-indexing only: ‘i’, ‘j’, ‘...’ can be logical vectors, indicating elements/slices to select. Such vectors are recycled if necessary to match the corresponding extent. ‘i’, ‘j’, ‘...’ can also be negative integers, indicating elements/slices to leave out of the selection. How can i convert the positives to TRUE and zeros and FALSE? From: William Dunlap wdun...@tibco.com Sent: Sunday, October 30, 2011 9:17 PM Subject: RE: [R] why the a[-indx] does not work? a[overLoadTesT==0] [1] 2 4 5 6 7 8 9 10 Look into help('[') or help('Subscript') to see how integer and logical (Boolean) subscripts differ. 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 Alaios Sent: Sunday, October 30, 2011 11:52 AM To: R-help@r-project.org Subject: [R] why the a[-indx] does not work? Dear all, Could you please explain me why OverloadsTesT [1] 1 0 1 0 0 0 0 0 0 0 a-matrix(data=seq(1,10),nrow=10) a [,1] [1,] 1 [2,] 2 [3,] 3 [4,] 4 [5,] 5 [6,] 6 [7,] 7 [8,] 8 [9,] 9 [10,] 10 a[-OverloadsTesT] [1] 2 3 4 5 6 7 8 9 10 the last line does not remove the first and third element and only does the first element.? What I want to do is for zeros to return the elements and for any positive value to remove it. What I am doing wrong? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] why the a[-indx] does not work?
as.logical(c(1,0,1,1)) [1] TRUE FALSE TRUE TRUE ?as.logical On Sun, Oct 30, 2011 at 8:50 PM, Alaios ala...@yahoo.com wrote: probably you mean For [-indexing only: i, j, ... can be logical vectors, indicating elements/slices to select. Such vectors are recycled if necessary to match the corresponding extent. i, j, ... can also be negative integers, indicating elements/slices to leave out of the selection. How can i convert the positives to TRUE and zeros and FALSE? From: William Dunlap wdun...@tibco.com Sent: Sunday, October 30, 2011 9:17 PM Subject: RE: [R] why the a[-indx] does not work? a[overLoadTesT==0] [1] 2 4 5 6 7 8 9 10 Look into help('[') or help('Subscript') to see how integer and logical (Boolean) subscripts differ. 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 Alaios Sent: Sunday, October 30, 2011 11:52 AM To: R-help@r-project.org Subject: [R] why the a[-indx] does not work? Dear all, Could you please explain me why OverloadsTesT [1] 1 0 1 0 0 0 0 0 0 0 a-matrix(data=seq(1,10),nrow=10) a [,1] [1,]1 [2,]2 [3,]3 [4,]4 [5,]5 [6,]6 [7,]7 [8,]8 [9,]9 [10,] 10 a[-OverloadsTesT] [1] 2 3 4 5 6 7 8 9 10 the last line does not remove the first and third element and only does the first element.? What I want to do is for zeros to return the elements and for any positive value to remove it. What I am doing wrong? B.R Alex [[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. [[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] jarquebera_test_results
Hi: I'd double check the form of the upper bound of the sequence. In the first case (i = 1), it uses the subvector loghozamok[1:220]; when i = 2, it uses the subvector loghozamok[21:260], etc. In the last case, it uses loghozamok[1181:1420]. If instead you want to split the vector into 60 groups of size 20, then this is easier (assuming that loghozamok has length 1200): gp - rep(1:60, each = 20) # Returns a vector do.call(c, lapply(split(loghozamok, gp), function(z) unname(tseries::jarque.bera.test(z)$p.value))) This works when gp and loghozamok have the same length. # Small test: x - rnorm(100) gp - rep(1:5, each = 20) do.call(c, lapply(split(x, gp), function(z) unname(tseries::jarque.bera.test(z)$p.value))) 1 2 3 4 5 0.5849843 0.6745735 0.9453412 0.5978477 0.7207138 HTH, Dennis On Sun, Oct 30, 2011 at 10:23 AM, Szűcs Ákos szucsa...@t-online.hu wrote: Hi! I got a loop where i print out the results of Jarque Bera tests, but I have to put, the p-values in a vector. Can you help me how to do it in an effective way and not just typing in the results to a vector? Thanks a lot, here is the code: for(i in 1:60){ print(jarque.bera.test(loghozamok[((20*(i-1))+1):(20*(i+11))]))} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Problem with svyvar in survey package
Well, you need to use the current version, then. -thomas On Fri, Oct 28, 2011 at 10:09 PM, amitava amtv.statpr...@gmail.com wrote: I am using Package survey version 3.20 and R 2.11.1. --Amitava -- View this message in context: http://r.789695.n4.nabble.com/Problem-with-svyvar-in-survey-package-tp3932818p3947306.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. -- Thomas Lumley Professor of Biostatistics University of Auckland __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Normality tests on groups of rows in a data frame, grouped based on content in other columns
Hi: Here are a few ways (untested, so caveat emptor): # plyr package library('plyr') ddply(df, .(Plant, Tissue, Gene), summarise, ntest = shapiro.test(ExpressionLevel)) # data.table package library('data.table') dt - data.table(df, key = 'Plant, Tissue, Gene') dt[, list(ntest = shapiro.test(ExpressionLevel)), by = key(dt)] # aggregate() function aggregate(ExpressionLevel ~ Plant + Tissue + Gene, data = df, FUN = shapiro.test) # doBy package: summaryBy(ExpressionLevel ~ Plant + Tissue + Gene, data = df, FUN = shapiro.test) There are others, too... HTH, Dennis 2011/10/30 Joel Fürstenberg-Hägg jo...@life.ku.dk: Dear R users, I have a data frame in the form below, on which I would like to make normality tests on the values in the ExpressionLevel column. head(df) ID Plant Tissue Gene ExpressionLevel 1 1 p1 t1 g1 366.53 2 2 p1 t1 g2 0.57 3 3 p1 t1 g3 11.81 4 4 p1 t2 g1 498.43 5 5 p1 t2 g2 2.14 6 6 p1 t2 g3 7.85 I would like to make the tests on every group according to the content of the Plant, Tissue and Gene columns. My first problem is how to run a function for all these sub groups. I first thought of making subsets: group1 - subset(df, Plant==p1 Tissue==t1 Gene==g1) group2 - subset(df, Plant==p1 Tissue==t1 Gene==g2) group3 - subset(df, Plant==p1 Tissue==t1 Gene==g3) group4 - subset(df, Plant==p1 Tissue==t2 Gene==g1) group5 - subset(df, Plant==p1 Tissue==t2 Gene==g2) group6 - subset(df, Plant==p1 Tissue==t2 Gene==g3) etc... But that would be very time consuming and I would like to be able to use the code for other data frames... I have also tried to store these in a list, which I am looping through, running the tests, something like this: alist=list(group1, group2, group3, group4, group5, group6) for(i in alist) { print(shapiro.test(i$ExpressionLevel)) print(pearson.test(i$ExpressionLevel)) print(pearson.test(i$ExpressionLevel, adjust=FALSE)) } But, there must be an easier and more elegant way of doing this... I found the example below at http://stackoverflow.com/questions/4716152/why-do-r-objects-not-print-in-a-function-or-a-for-loop. I think might be used for the printing of the results, but I do not know how to adjust for my data frame, since the functions are applied on several columns instead of certain rows in one column. DF - data.frame(A = rnorm(100), B = rlnorm(100)) obj2 - lapply(DF, shapiro.test) tab2 - lapply(obj, function(x) c(W = unname(x$statistic), p.value = x$p.value)) tab2 - data.frame(do.call(rbind, tab2)) printCoefmat(tab2, has.Pvalue = TRUE) Finally, I have found several different functions for testing for normality, but which one(s) should I choose? As far as I can see in the help files they only differ in the minimum number of samples required. Thanks in advance! Kind regards, Joel [[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] why the a[-indx] does not work?
I think this does the work return(m[!as.logical(data)]) I am not sure though if this is the same with return(m[!as.logical(data)]) From: andrija djurovic djandr...@gmail.com Cc: R-help@r-project.org R-help@r-project.org Sent: Sunday, October 30, 2011 9:58 PM Subject: Re: [R] why the a[-indx] does not work? as.logical(c(1,0,1,1)) [1]  TRUE FALSE  TRUE  TRUE ?as.logical probably you mean For â[â-indexing only: âiâ, âjâ, â...â can be logical vectors, indicating elements/slices to select.  Such vectors are recycled if necessary to match the corresponding extent. âiâ, âjâ, â...â can also be negative integers, indicating elements/slices to leave out of the selection. How can i convert the positives to TRUE and zeros and FALSE? From: William Dunlap wdun...@tibco.com Sent: Sunday, October 30, 2011 9:17 PM Subject: RE: [R] why the a[-indx] does not work?  a[overLoadTesT==0]  [1] 2 4 5 6 7 8 9 10 Look into help('[') or help('Subscript') to see how integer and logical (Boolean) subscripts differ. 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 Alaios Sent: Sunday, October 30, 2011 11:52 AM To: R-help@r-project.org Subject: [R] why the a[-indx] does not work? Dear all, Could you please explain me why OverloadsTesT [1] 1 0 1 0 0 0 0 0 0 0 a-matrix(data=seq(1,10),nrow=10) a [,1] [1,]  1 [2,]  2 [3,]  3 [4,]  4 [5,]  5 [6,]  6 [7,]  7 [8,]  8 [9,]  9 [10,]  10 a[-OverloadsTesT] [1] 2 3 4 5 6 7 8 9 10 the last line does not remove the first and third element and only does the first element.? What I want to do is for zeros to return the elements and for any positive value to remove it. What I am doing wrong? B.R Alex    [[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. [[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] why the a[-indx] does not work?
myvec != 0 does the same as ifelse(myvec == 0, FALSE, TRUE) but more quickly 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 Sarah Goslee Sent: Sunday, October 30, 2011 12:57 PM To: Alaios Cc: R-help@r-project.org Subject: Re: [R] why the a[-indx] does not work? ifelse(myvec == 0, FALSE, TRUE) # set 0 to FALSE, other values to TRUE On Sun, Oct 30, 2011 at 3:50 PM, Alaios ala...@yahoo.com wrote: probably you mean For '['-indexing only: 'i', 'j', '...' can be logical vectors, indicating elements/slices to select. Such vectors are recycled if necessary to match the corresponding extent. 'i', 'j', '...' can also be negative integers, indicating elements/slices to leave out of the selection. How can i convert the positives to TRUE and zeros and FALSE? From: William Dunlap wdun...@tibco.com Sent: Sunday, October 30, 2011 9:17 PM Subject: RE: [R] why the a[-indx] does not work? a[overLoadTesT==0] [1] 2 4 5 6 7 8 9 10 Look into help('[') or help('Subscript') to see how integer and logical (Boolean) subscripts differ. 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 Alaios Sent: Sunday, October 30, 2011 11:52 AM To: R-help@r-project.org Subject: [R] why the a[-indx] does not work? Dear all, Could you please explain me why OverloadsTesT [1] 1 0 1 0 0 0 0 0 0 0 a-matrix(data=seq(1,10),nrow=10) a [,1] [1,] 1 [2,] 2 [3,] 3 [4,] 4 [5,] 5 [6,] 6 [7,] 7 [8,] 8 [9,] 9 [10,] 10 a[-OverloadsTesT] [1] 2 3 4 5 6 7 8 9 10 the last line does not remove the first and third element and only does the first element.? What I want to do is for zeros to return the elements and for any positive value to remove it. What I am doing wrong? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] why the a[-indx] does not work?
I like to use numericVector != 0 instead of is.logical(numericVector) because the former more directly indicates what you want to happen instead of relying on knowledge that numeric 0 maps to logical FALSE. 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 Alaios Sent: Sunday, October 30, 2011 1:40 PM To: andrija djurovic Cc: R-help@r-project.org Subject: Re: [R] why the a[-indx] does not work? I think this does the work return(m[!as.logical(data)]) I am not sure though if this is the same with return(m[!as.logical(data)]) From: andrija djurovic djandr...@gmail.com Cc: R-help@r-project.org R-help@r-project.org Sent: Sunday, October 30, 2011 9:58 PM Subject: Re: [R] why the a[-indx] does not work? as.logical(c(1,0,1,1)) [1] TRUE FALSE TRUE TRUE ?as.logical probably you mean For ‘[’-indexing only: ‘i’, ‘j’, ‘...’ can be logical vectors, indicating elements/slices to select. Such vectors are recycled if necessary to match the corresponding extent. ‘i’, ‘j’, ‘...’ can also be negative integers, indicating elements/slices to leave out of the selection. How can i convert the positives to TRUE and zeros and FALSE? From: William Dunlap wdun...@tibco.com Sent: Sunday, October 30, 2011 9:17 PM Subject: RE: [R] why the a[-indx] does not work? a[overLoadTesT==0] [1] 2 4 5 6 7 8 9 10 Look into help('[') or help('Subscript') to see how integer and logical (Boolean) subscripts differ. 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 Alaios Sent: Sunday, October 30, 2011 11:52 AM To: R-help@r-project.org Subject: [R] why the a[-indx] does not work? Dear all, Could you please explain me why OverloadsTesT [1] 1 0 1 0 0 0 0 0 0 0 a-matrix(data=seq(1,10),nrow=10) a [,1] [1,] 1 [2,] 2 [3,] 3 [4,] 4 [5,] 5 [6,] 6 [7,] 7 [8,] 8 [9,] 9 [10,] 10 a[-OverloadsTesT] [1] 2 3 4 5 6 7 8 9 10 the last line does not remove the first and third element and only does the first element.? What I want to do is for zeros to return the elements and for any positive value to remove it. What I am doing wrong? B.R Alex [[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. [[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] why the a[-indx] does not work?
You are absolutely right it is better. This was just an example how one can convert the positives to TRUE and zeros to FALSE as it was asked. Andrija On Sun, Oct 30, 2011 at 9:57 PM, William Dunlap wdun...@tibco.com wrote: I like to use numericVector != 0 instead of is.logical(numericVector) because the former more directly indicates what you want to happen instead of relying on knowledge that numeric 0 maps to logical FALSE. 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 Alaios Sent: Sunday, October 30, 2011 1:40 PM To: andrija djurovic Cc: R-help@r-project.org Subject: Re: [R] why the a[-indx] does not work? I think this does the work return(m[!as.logical(data)]) I am not sure though if this is the same with return(m[!as.logical(data)]) From: andrija djurovic djandr...@gmail.com Cc: R-help@r-project.org R-help@r-project.org Sent: Sunday, October 30, 2011 9:58 PM Subject: Re: [R] why the a[-indx] does not work? as.logical(c(1,0,1,1)) [1] TRUE FALSE TRUE TRUE ?as.logical probably you mean For [-indexing only: i, j, ... can be logical vectors, indicating elements/slices to select. Such vectors are recycled if necessary to match the corresponding extent. i, j, ... can also be negative integers, indicating elements/slices to leave out of the selection. How can i convert the positives to TRUE and zeros and FALSE? From: William Dunlap wdun...@tibco.com Sent: Sunday, October 30, 2011 9:17 PM Subject: RE: [R] why the a[-indx] does not work? a[overLoadTesT==0] [1] 2 4 5 6 7 8 9 10 Look into help('[') or help('Subscript') to see how integer and logical (Boolean) subscripts differ. 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 Alaios Sent: Sunday, October 30, 2011 11:52 AM To: R-help@r-project.org Subject: [R] why the a[-indx] does not work? Dear all, Could you please explain me why OverloadsTesT [1] 1 0 1 0 0 0 0 0 0 0 a-matrix(data=seq(1,10),nrow=10) a [,1] [1,]1 [2,]2 [3,]3 [4,]4 [5,]5 [6,]6 [7,]7 [8,]8 [9,]9 [10,] 10 a[-OverloadsTesT] [1] 2 3 4 5 6 7 8 9 10 the last line does not remove the first and third element and only does the first element.? What I want to do is for zeros to return the elements and for any positive value to remove it. What I am doing wrong? B.R Alex [[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. [[alternative HTML version deleted]] [[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] Generic Plot and save function
I am replying to myself as regardless of the save I described below I also want to do something like the following do_analysis_for_data_sets - function(AnalysisFunction, DataSets, ...) { lapply(DataSets,AnalysisFunction, how to pass the ... to lapply) } which means that I want to pass the also to the lapply (I am using mclapply actually that have the same syntax). Could you please comment on that as well as too my point before (About how to write a function that given a path inpuit saves the file as eps) B.R Alex To: R-help@r-project.org R-help@r-project.org Sent: Sunday, October 30, 2011 9:15 PM Subject: [R] Generic Plot and save function Dear all, I was reading for the nice ... parameter option in R, which if I got it right it is used to pass other parameter to some other function inside your function for example plot_duty_cycle- function(data, ...) { barplot(duty_cycle_per_bin(data), ...) } I can put some parameters to pass inside the barplot function inside my function. I would like to ask you if there is a smart way to also put some parameter in the input section of my function so to also save the plot in the given path I am thinking for something like that plot_duty_cycle- function(data, ...) { barplot(duty_cycle_per_bin(data), ...) if (is(path) { save somehow the plot in the path} } Could you please give me a nice hint for that case B.R Alex [[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] Parametric tests
Cem Girit-2 wrote: Hello, I am interested in parametric multi comparison tests such as Dunnett, Duncan, Tukey, Newman-Keuls, Bonferonni, Scheffe, and non-parametric tests such as Kruskal-Wallis, and Mann-Whitney U. Are there packages that include most of these tests in each category? Many packages exist for an individual test but their outputs vary in great detail (test statistics, p-values, etc.) formats. It is desirable to have one that allows comparison of different test results such as Tukey versus Duncan. Cem For parametric tests look at pkg:multcomp For nonparametric, pkg:coin Cem Girit [[alternative HTML version deleted]] __ R-help@ mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- View this message in context: http://r.789695.n4.nabble.com/Parametric-tests-tp3952268p3953763.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 to extract data with R
With the following dataset, trl =1, 2,3, how to extract data with the time repeated 3 times. For example, I am only interested in the data records with time repeated 3 times. time=0.1 only has 1 time, we don't want it, time=0.3 only has two times, we don't want it, and so on. Thanks a lot. time surv trl 1 0.0 0.990 1 124 0.0 0.995 2 250 0.0 0.980 3 125 0.1 0.990 2 2 0.2 0.985 1 126 0.2 0.985 2 251 0.2 0.975 3 3 0.3 0.980 1 127 0.3 0.980 2 4 0.4 0.975 1 128 0.4 0.975 2 252 0.4 0.965 3 5 0.5 0.970 1 6 0.6 0.965 1 129 0.6 0.970 2 253 0.6 0.955 3 7 0.8 0.960 1 130 0.8 0.960 2 254 0.8 0.950 3 131 0.9 0.955 2 255 0.9 0.945 3 8 1.0 0.955 1 256 1.0 0.940 3 time surv trl 257 1.3 0.935 3 9 1.7 0.950 1 132 1.8 0.950 2 258 1.8 0.930 3 133 1.9 0.945 2 259 1.9 0.925 3 10 2.0 0.945 1 134 2.0 0.935 2 260 2.1 0.915 3 11 2.2 0.935 1 135 2.2 0.930 2 261 2.2 0.905 3 12 2.4 0.930 1 262 2.4 0.900 3 13 2.5 0.925 1 136 2.5 0.925 2 263 2.5 0.895 3 137 2.6 0.915 2 264 2.6 0.880 3 14 2.7 0.915 1 138 2.7 0.895 2 265 2.7 0.870 3 15 2.8 0.910 1 time surv trl 266 2.8 0.860 3 16 2.9 0.895 1 267 2.9 0.855 3 17 3.0 0.890 1 139 3.0 0.885 2 268 3.0 0.840 3 18 3.1 0.885 1 269 3.1 0.835 3 19 3.2 0.880 1 270 3.2 0.830 3 20 3.3 0.875 1 140 3.3 0.880 2 141 3.4 0.870 2 21 3.5 0.870 1 142 3.8 0.855 2 271 3.8 0.825 3 22 3.9 0.860 1 143 3.9 0.845 2 272 3.9 0.820 3 273 4.0 0.805 3 144 4.1 0.840 2 274 4.1 0.800 3 145 4.2 0.835 2 time surv trl 275 4.2 0.795 3 23 4.3 0.855 1 24 4.4 0.850 1 146 4.4 0.830 2 276 4.4 0.790 3 25 4.5 0.835 1 147 4.5 0.825 2 277 4.5 0.785 3 26 4.6 0.820 1 278 4.6 0.780 3 27 4.7 0.810 1 148 4.7 0.820 2 28 4.8 0.805 1 29 4.9 0.800 1 149 4.9 0.815 2 279 5.0 0.770 3 30 5.1 0.790 1 150 5.1 0.805 2 31 5.2 0.785 1 151 5.2 0.800 2 32 5.3 0.780 1 152 5.3 0.795 2 33 5.4 0.775 1 time surv trl 280 5.4 0.750 3 153 5.5 0.790 2 34 5.6 0.765 1 281 5.7 0.745 3 154 5.8 0.775 2 155 5.9 0.770 2 35 6.0 0.760 1 282 6.0 0.740 3 283 6.1 0.735 3 36 6.2 0.750 1 284 6.2 0.725 3 285 6.3 0.720 3 37 6.4 0.745 1 156 6.4 0.765 2 157 6.5 0.760 2 286 6.5 0.710 3 38 6.6 0.735 1 158 6.6 0.755 2 159 6.7 0.745 2 287 6.7 0.700 3 288 6.8 0.690 3 39 6.9 0.725 1 160 6.9 0.735 2 time surv trl 289 6.9 0.685 3 40 7.0 0.715 1 161 7.0 0.720 2 41 7.1 0.710 1 162 7.1 0.710 2 42 7.2 0.705 1 290 7.2 0.670 3 43 7.3 0.700 1 163 7.3 0.705 2 44 7.4 0.690 1 164 7.4 0.700 2 291 7.4 0.660 3 165 7.5 0.690 2 292 7.6 0.650 3 45 7.7 0.685 1 166 7.8 0.685 2 46 7.9 0.680 1 167 7.9 0.680 2 293 7.9 0.645 3 47 8.0 0.675 1 168 8.0 0.675 2 294 8.0 0.640 3 48 8.1 0.665 1 time surv trl 295 8.1 0.635 3 49 8.4 0.655 1 296 8.4 0.625 3 169 8.5 0.670 2 297 8.5 0.620 3 170 8.6 0.665 2 50 8.7 0.645 1 171 8.7 0.660 2 298 8.7 0.615 3 172 8.8 0.655 2 51 8.9 0.635 1 52 9.0 0.630 1 53 9.1 0.620 1 173 9.1 0.650 2 54 9.2 0.610 1 174 9.2 0.640 2 55 9.3 0.600 1 175 9.4 0.635 2 299 9.4 0.605 3 176 9.5 0.620 2 177 9.6 0.610 2 300 9.6 0.595 3 178 9.7 0.605 2 time surv trl 179 9.8 0.600 2 301 9.8 0.590 3 56 9.9 0.595 1 180 9.9 0.595 2 302 9.9 0.585 3 303 10.0 0.580 3 181 10.1 0.590 2 57 10.2 0.590 1 304 10.2 0.575 3 182 10.4 0.585 2 183 10.5 0.570 2 184 10.6 0.565 2 305 10.6 0.570 3 58 10.7 0.580 1 185 10.7 0.560 2 186 10.8 0.555 2 187 11.0 0.545 2 188 11.1 0.540 2 306 11.1 0.565 3 59 11.2 0.575 1 189 11.3 0.535 2 307 11.3 0.555 3 60 11.4 0.560 1 time surv trl 190 11.4 0.530 2 308 11.6 0.550 3 61 11.7 0.555 1 309 11.8 0.545 3 62 11.9 0.550 1 191 11.9 0.525 2 310 11.9 0.540 3 63 12.0 0.545 1 192 12.0 0.520 2 311 12.0 0.535 3 193 12.1 0.505 2 312 12.2 0.525 3 64 12.3 0.540 1 194 12.6 0.500 2 313 12.6 0.520 3 314 12.9 0.515 3 195 13.0 0.495 2 315 13.2 0.505 3 316 13.4 0.500 3 65 13.5 0.535 1 196 13.5 0.490 2 317 13.5 0.495 3 66 13.6 0.530 1 time surv trl 197 13.6 0.485 2 318 13.6 0.480 3 67 13.7 0.525 1 198 13.7 0.480 2 199 13.8 0.475 2 319 13.9 0.475 3 68 14.1 0.520 1 200 14.1 0.470 2 69 14.2 0.515 1 201 14.2 0.465 2 70 14.5 0.510 1 320 14.5 0.470 3 321 14.6 0.460 3 202 14.8 0.460 2 71 15.0 0.505 1 72 15.2 0.495 1 322 15.4 0.450 3 73 15.5 0.490 1 203 15.5 0.455 2 323 15.5 0.445 3 74 15.6 0.485 1 204 15.7 0.450 2 324 15.7 0.440 3 time surv trl 205 15.8 0.445 2 325 15.8 0.435 3 75 16.0 0.480 1 76 16.1 0.475 1 206 16.1 0.440 2 77 16.2 0.470 1 326 16.2 0.430 3 207 16.3 0.435 2 327 16.5 0.425 3 78 16.6 0.465 1 208 16.7 0.430 2 328 16.7 0.420 3 209 16.8 0.420 2 329 16.8 0.415 3 330 16.9 0.410 3 79 17.0 0.460 1 80 17.1 0.455 1 210 17.1 0.415 2 81 17.2 0.450 1 331 17.2 0.405 3 82 17.3 0.435 1 332 17.3 0.400 3 83 17.4 0.430 1 time surv trl 333 17.5 0.390 3 334 17.6 0.385 3 84 17.7 0.425 1 335 17.7 0.380 3 211 18.1 0.410 2 212 18.2 0.405 2 85 18.3 0.420 1 213 18.4 0.400 2 336 18.4 0.370 3 214 18.5 0.395 2 86 18.6 0.415 1 87 18.9 0.410 1 337 18.9 0.365 3 338 19.2 0.355 3 339 19.3 0.350 3 88 19.4 0.405 1 340 19.4 0.345 3 89 19.5 0.400 1 215 19.5 0.390 2 216 19.6 0.385 2 217 19.7 0.380 2 341 19.7 0.340 3 90 19.8 0.395 1 time surv trl 91 19.9 0.390 1 92 20.0 0.385 1 93 20.1 0.380 1 218 20.4 0.370 2 219 20.5
Re: [R] jarquebera_test_results
Szűcs Ákos wrote: Hi! I got a loop where i print out the results of Jarque Bera tests, but I have to put, the p-values in a vector. Can you help me how to do it in an effective way and not just typing in the results to a vector? Thanks a lot, here is the code: for(i in 1:60){ print(jarque.bera.test(loghozamok[((20*(i-1))+1):(20*(i+ The power is out here so I have no access to R. I can tell you what I would have done. Go to the help page for that function and look at the Value section. Generally functions return a list and you need to find the name of the item that has the p-value. It's possible that there will be a print method for the object returned and you might need to look at that page. As a last resort you would look at the object returned with str(). -- David. -- View this message in context: http://r.789695.n4.nabble.com/jarquebera-test-results-tp3953541p3953795.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] why the a[-indx] does not work?
Duncan Murdoch-2 wrote: On 11-10-30 2:52 PM, Alaios wrote: Dear all, Could you please explain me why OverloadsTesT [1] 1 0 1 0 0 0 0 0 0 0 a-matrix(data=seq(1,10),nrow=10) a [,1] [1,]1 [2,]2 [3,]3 [4,]4 [5,]5 [6,]6 [7,]7 [8,]8 [9,]9 [10,] 10 a[-OverloadsTesT] [1] 2 3 4 5 6 7 8 9 10 the last line does not remove the first and third element and only does the first element.? What I want to do is for zeros to return the elements and for any positive value to remove it. What I am doing wrong? You are asking it to remove item 1, and it does. If you want to negate a logical vector, you need to use a logical vector and negate it, e.g. OverloadsTesT - as.logical(OverloadsTeSt) a[!OverloadsTest] Duncan Murdoch Or: a[-c(1,3)] -- David. -- View this message in context: http://r.789695.n4.nabble.com/why-the-a-indx-does-not-work-tp3953737p3953815.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] why the a[-indx] does not work?
Good point indeed, actually I want to have numericVector==0 (get that points). What is the difference between though !numericVector==0 and -numericVector==0 when used inside a matrix to pinpoint matrix entries? B.R Alex From: William Dunlap wdun...@tibco.com Cc: R-help@r-project.org R-help@r-project.org Sent: Sunday, October 30, 2011 10:57 PM Subject: RE: [R] why the a[-indx] does not work? I like to use numericVector != 0 instead of is.logical(numericVector) because the former more directly indicates what you want to happen instead of relying on knowledge that numeric 0 maps to logical FALSE. 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 Alaios Sent: Sunday, October 30, 2011 1:40 PM To: andrija djurovic Cc: R-help@r-project.org Subject: Re: [R] why the a[-indx] does not work? I think this does the work return(m[!as.logical(data)]) I am not sure though if this is the same with return(m[!as.logical(data)]) From: andrija djurovic djandr...@gmail.com Cc: R-help@r-project.org R-help@r-project.org Sent: Sunday, October 30, 2011 9:58 PM Subject: Re: [R] why the a[-indx] does not work? as.logical(c(1,0,1,1)) [1]  TRUE FALSE  TRUE  TRUE ?as.logical probably you mean For â[â-indexing only: âiâ, âjâ, â...â can be logical vectors, indicating elements/slices to select.  Such vectors are recycled if necessary to match the corresponding extent. âiâ, âjâ, â...â can also be negative integers, indicating elements/slices to leave out of the selection. How can i convert the positives to TRUE and zeros and FALSE? From: William Dunlap wdun...@tibco.com Sent: Sunday, October 30, 2011 9:17 PM Subject: RE: [R] why the a[-indx] does not work?  a[overLoadTesT==0]  [1] 2 4 5 6 7 8 9 10 Look into help('[') or help('Subscript') to see how integer and logical (Boolean) subscripts differ. 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 Alaios Sent: Sunday, October 30, 2011 11:52 AM To: R-help@r-project.org Subject: [R] why the a[-indx] does not work? Dear all, Could you please explain me why OverloadsTesT [1] 1 0 1 0 0 0 0 0 0 0 a-matrix(data=seq(1,10),nrow=10) a [,1] [1,]  1 [2,]  2 [3,]  3 [4,]  4 [5,]  5 [6,]  6 [7,]  7 [8,]  8 [9,]  9 [10,]  10 a[-OverloadsTesT] [1] 2 3 4 5 6 7 8 9 10 the last line does not remove the first and third element and only does the first element.? What I want to do is for zeros to return the elements and for any positive value to remove it. What I am doing wrong? B.R Alex    [[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.    [[alternative HTML version deleted]] [[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] help to extract data with R
One option is to use table to get the number of repeats tab-table(tr1$time)==3 time3-names(tab)[tab] tr1[tr1$time%in%time3,] Weidong Gu On Sun, Oct 30, 2011 at 5:10 PM, Zheng Lu luy...@hotmail.com wrote: With the following dataset, trl =1, 2,3, how to extract data with the time repeated 3 times. For example, I am only interested in the data records with time repeated 3 times. time=0.1 only has 1 time, we don't want it, time=0.3 only has two times, we don't want it, and so on. Thanks a lot. time surv trl 1 0.0 0.990 1 124 0.0 0.995 2 250 0.0 0.980 3 125 0.1 0.990 2 2 0.2 0.985 1 126 0.2 0.985 2 251 0.2 0.975 3 3 0.3 0.980 1 127 0.3 0.980 2 4 0.4 0.975 1 128 0.4 0.975 2 252 0.4 0.965 3 5 0.5 0.970 1 6 0.6 0.965 1 129 0.6 0.970 2 253 0.6 0.955 3 7 0.8 0.960 1 130 0.8 0.960 2 254 0.8 0.950 3 131 0.9 0.955 2 255 0.9 0.945 3 8 1.0 0.955 1 256 1.0 0.940 3 time surv trl 257 1.3 0.935 3 9 1.7 0.950 1 132 1.8 0.950 2 258 1.8 0.930 3 133 1.9 0.945 2 259 1.9 0.925 3 10 2.0 0.945 1 134 2.0 0.935 2 260 2.1 0.915 3 11 2.2 0.935 1 135 2.2 0.930 2 261 2.2 0.905 3 12 2.4 0.930 1 262 2.4 0.900 3 13 2.5 0.925 1 136 2.5 0.925 2 263 2.5 0.895 3 137 2.6 0.915 2 264 2.6 0.880 3 14 2.7 0.915 1 138 2.7 0.895 2 265 2.7 0.870 3 15 2.8 0.910 1 time surv trl 266 2.8 0.860 3 16 2.9 0.895 1 267 2.9 0.855 3 17 3.0 0.890 1 139 3.0 0.885 2 268 3.0 0.840 3 18 3.1 0.885 1 269 3.1 0.835 3 19 3.2 0.880 1 270 3.2 0.830 3 20 3.3 0.875 1 140 3.3 0.880 2 141 3.4 0.870 2 21 3.5 0.870 1 142 3.8 0.855 2 271 3.8 0.825 3 22 3.9 0.860 1 143 3.9 0.845 2 272 3.9 0.820 3 273 4.0 0.805 3 144 4.1 0.840 2 274 4.1 0.800 3 145 4.2 0.835 2 time surv trl 275 4.2 0.795 3 23 4.3 0.855 1 24 4.4 0.850 1 146 4.4 0.830 2 276 4.4 0.790 3 25 4.5 0.835 1 147 4.5 0.825 2 277 4.5 0.785 3 26 4.6 0.820 1 278 4.6 0.780 3 27 4.7 0.810 1 148 4.7 0.820 2 28 4.8 0.805 1 29 4.9 0.800 1 149 4.9 0.815 2 279 5.0 0.770 3 30 5.1 0.790 1 150 5.1 0.805 2 31 5.2 0.785 1 151 5.2 0.800 2 32 5.3 0.780 1 152 5.3 0.795 2 33 5.4 0.775 1 time surv trl 280 5.4 0.750 3 153 5.5 0.790 2 34 5.6 0.765 1 281 5.7 0.745 3 154 5.8 0.775 2 155 5.9 0.770 2 35 6.0 0.760 1 282 6.0 0.740 3 283 6.1 0.735 3 36 6.2 0.750 1 284 6.2 0.725 3 285 6.3 0.720 3 37 6.4 0.745 1 156 6.4 0.765 2 157 6.5 0.760 2 286 6.5 0.710 3 38 6.6 0.735 1 158 6.6 0.755 2 159 6.7 0.745 2 287 6.7 0.700 3 288 6.8 0.690 3 39 6.9 0.725 1 160 6.9 0.735 2 time surv trl 289 6.9 0.685 3 40 7.0 0.715 1 161 7.0 0.720 2 41 7.1 0.710 1 162 7.1 0.710 2 42 7.2 0.705 1 290 7.2 0.670 3 43 7.3 0.700 1 163 7.3 0.705 2 44 7.4 0.690 1 164 7.4 0.700 2 291 7.4 0.660 3 165 7.5 0.690 2 292 7.6 0.650 3 45 7.7 0.685 1 166 7.8 0.685 2 46 7.9 0.680 1 167 7.9 0.680 2 293 7.9 0.645 3 47 8.0 0.675 1 168 8.0 0.675 2 294 8.0 0.640 3 48 8.1 0.665 1 time surv trl 295 8.1 0.635 3 49 8.4 0.655 1 296 8.4 0.625 3 169 8.5 0.670 2 297 8.5 0.620 3 170 8.6 0.665 2 50 8.7 0.645 1 171 8.7 0.660 2 298 8.7 0.615 3 172 8.8 0.655 2 51 8.9 0.635 1 52 9.0 0.630 1 53 9.1 0.620 1 173 9.1 0.650 2 54 9.2 0.610 1 174 9.2 0.640 2 55 9.3 0.600 1 175 9.4 0.635 2 299 9.4 0.605 3 176 9.5 0.620 2 177 9.6 0.610 2 300 9.6 0.595 3 178 9.7 0.605 2 time surv trl 179 9.8 0.600 2 301 9.8 0.590 3 56 9.9 0.595 1 180 9.9 0.595 2 302 9.9 0.585 3 303 10.0 0.580 3 181 10.1 0.590 2 57 10.2 0.590 1 304 10.2 0.575 3 182 10.4 0.585 2 183 10.5 0.570 2 184 10.6 0.565 2 305 10.6 0.570 3 58 10.7 0.580 1 185 10.7 0.560 2 186 10.8 0.555 2 187 11.0 0.545 2 188 11.1 0.540 2 306 11.1 0.565 3 59 11.2 0.575 1 189 11.3 0.535 2 307 11.3 0.555 3 60 11.4 0.560 1 time surv trl 190 11.4 0.530 2 308 11.6 0.550 3 61 11.7 0.555 1 309 11.8 0.545 3 62 11.9 0.550 1 191 11.9 0.525 2 310 11.9 0.540 3 63 12.0 0.545 1 192 12.0 0.520 2 311 12.0 0.535 3 193 12.1 0.505 2 312 12.2 0.525 3 64 12.3 0.540 1 194 12.6 0.500 2 313 12.6 0.520 3 314 12.9 0.515 3 195 13.0 0.495 2 315 13.2 0.505 3 316 13.4 0.500 3 65 13.5 0.535 1 196 13.5 0.490 2 317 13.5 0.495 3 66 13.6 0.530 1 time surv trl 197 13.6 0.485 2 318 13.6 0.480 3 67 13.7 0.525 1 198 13.7 0.480 2 199 13.8 0.475 2 319 13.9 0.475 3 68 14.1 0.520 1 200 14.1 0.470 2 69 14.2 0.515 1 201 14.2 0.465 2 70 14.5 0.510 1 320 14.5 0.470 3 321 14.6 0.460 3 202 14.8 0.460 2 71 15.0 0.505 1 72 15.2 0.495 1 322 15.4 0.450 3 73 15.5 0.490 1 203 15.5 0.455 2 323 15.5 0.445 3 74 15.6 0.485 1 204 15.7 0.450 2 324 15.7 0.440 3 time surv trl 205 15.8 0.445 2 325 15.8 0.435 3 75 16.0 0.480 1 76 16.1 0.475 1 206 16.1 0.440 2 77 16.2 0.470 1 326 16.2 0.430 3 207 16.3 0.435 2 327 16.5 0.425 3 78 16.6 0.465 1 208 16.7 0.430 2 328 16.7 0.420 3 209 16.8 0.420 2 329 16.8 0.415 3 330 16.9 0.410 3 79 17.0 0.460 1 80 17.1 0.455 1 210 17.1 0.415 2 81 17.2 0.450 1 331 17.2 0.405 3 82 17.3 0.435 1 332 17.3 0.400 3 83 17.4 0.430 1 time surv trl 333 17.5
Re: [R] Generic Plot and save function
Hi, Regarding, ..., you literally just pass For example: f - function(d, ...) { lapply(d, mean, ...) } f(1:10) # but you could pass other arguments to lapply. Regarding saving, my thought would be to just switch which device is started based on path. I'm sure thre are other, possibly cleverer ways out there. foo - function(d, path = NULL, ...) { if (!is.null(path)) { postscript(paste(path, plot1.eps, sep=''), other settings) } else dev.new() barplot(d, ...) ## the postscript device needs to be shutdown ## but if going to default device, probably do not want ## it closed before user can view it if (!is.null(path)) dev.off() } Hope this helps, Josh PS all typed on my phone so expect typos On Oct 30, 2011, at 14:48, Alaios ala...@yahoo.com wrote: I am replying to myself as regardless of the save I described below I also want to do something like the following do_analysis_for_data_sets - function(AnalysisFunction, DataSets, ...) { � � lapply(DataSets,AnalysisFunction, how to pass the ... to lapply) } which means that I want to pass the also to the lapply (I am using mclapply actually that have the same syntax). Could you please comment on that as well as too my point before (About how to write a function that given a path inpuit saves the file as eps) B.R Alex To: R-help@r-project.org R-help@r-project.org Sent: Sunday, October 30, 2011 9:15 PM Subject: [R] Generic Plot and save function Dear all, I was reading for the nice ... parameter option in R, which if I got it right it is used to pass other parameter to some other function inside your function for example plot_duty_cycle- function(data, ...) { �� � � � � �barplot(duty_cycle_per_bin(data), ...) } I can put some parameters to pass inside the barplot function inside my function. I would like to ask you if there is a smart way to also put some parameter in the input section of my function so to also save the plot in the given path I am thinking for something like that plot_duty_cycle- function(data, ...) { �� � � � � �barplot(duty_cycle_per_bin(data), ...) � � � �if (is(path) { save somehow the plot in the path} } Could you please give me a nice hint for that case B.R Alex ��� [[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. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] curiosity only: gpu ?
dear R experts. about once a year, I wonder where GPU computing is. this is of course a quickly moving field, so I am hoping to elicit some advice from those that have followed the developments more actively. fortunately, unlike my many other cries for help, this post is not critical. it is more curiosity. Integration: for me, I want to substitute the basic statistical functions with GPU versions: mean, var, sd, lm, lm.summary, sort, order, quantile (, and maybe lapply with plain arithmetic functions). one of these functions is already in gputools (gLm). I did not see the others, but some functions (like mean) may well be used internally. is there an R GPU library that can swap-and-replace these eight functions seamlessly and transparently? Benchmarks: I wonder what the typical speedup for these functions are in mainstream systems---say a $300 CPU vs. a $200 GPU. if it is a factor of 20, it is well worth it *for me*. if it is a factor of 5, I may as well use mcapply for most of *my* problems (which can be split nicely across a quad-core CPU). is there still an overhead cost for switching between CPU and GPU calculations? I think modern GPUs have unified memory space, so the data copy problem is hopefully long gone. /iaw Ivo Welch (ivo.we...@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] finding row duplicates, regardless of element order
Dear list, Suppose I have the following matrix: M - matrix(c(1,2,3,2,4,5,5,3,2,1,3,2,4,4), ncol=2) M [,1] [,2] [1,] 1 3 [2,] 2 2 [3,] 3 1 [4,] 2 3 [5,] 4 2 [6,] 5 4 [7,] 5 4 In this matrix, row 1 contains elements 1 and 3 and row 3 does the same. Similarly, rows 6 and 7 contain the same elements. I am looking for a way to efficiently identify these rows. I cannot use duplicated(M), since the order of the names in the rows does not matter, all that matters is that *all* names in a row also *all* appear in another row. How can I identify such duplicated rows, without going through a process of looping and shifting elements around? thanks, Peter __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] finding row duplicates, regardless of element order
try this: M - matrix(c(1,2,3,2,4,5,5,3,2,1,3,2,4,4), ncol=2) M [,1] [,2] [1,] 1 3 [2,] 2 2 [3,] 3 1 [4,] 2 3 [5,] 4 2 [6,] 5 4 [7,] 5 4 # not the most efficient M.sorted - apply(M, 1, function(x) paste(sort(x), collapse = ',')) M.sorted [1] 1,3 2,2 1,3 2,3 2,4 4,5 4,5 # remove duplicated entries M[!duplicated(M.sorted), ] [,1] [,2] [1,] 1 3 [2,] 2 2 [3,] 2 3 [4,] 4 2 [5,] 5 4 On Sun, Oct 30, 2011 at 7:49 PM, Wet Bell Diver wetbelldi...@gmail.com wrote: Dear list, Suppose I have the following matrix: M - matrix(c(1,2,3,2,4,5,5,3,2,1,3,2,4,4), ncol=2) M [,1] [,2] [1,] 1 3 [2,] 2 2 [3,] 3 1 [4,] 2 3 [5,] 4 2 [6,] 5 4 [7,] 5 4 In this matrix, row 1 contains elements 1 and 3 and row 3 does the same. Similarly, rows 6 and 7 contain the same elements. I am looking for a way to efficiently identify these rows. I cannot use duplicated(M), since the order of the names in the rows does not matter, all that matters is that *all* names in a row also *all* appear in another row. How can I identify such duplicated rows, without going through a process of looping and shifting elements around? thanks, Peter __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Data Munger Guru What is the problem that you are trying to solve? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 R debugging tool
Rainer wrote: * On Thu, Oct 20, 2011 at 12:22 AM, Norm Matloff * matl...@cs.ucdavis.eduwrote: * * * I've developed a new R debugging tool, debugR, available at * http://heather.cs.ucdavis.edu/debugR.html * * This basically replaces my edtdbg, which I will no longer be * supporting. * The new tool is now decoupled from one's text editor, and has a lot * more * features than edtdbg did. * * * Sounds interesting. Do I have to write a script file for debugging, or * is * there an option to run it from within R to debug a function instead of a * script? * * Rainer One does indeed basically debug at the function level (or set of functions), as desired. The user specifies on the command line a file in which those functions reside. (In time, I can broaden this.) The best way to see the operation is to try the Quick Start. It really IS quick! Just go to http://heather.cs.ucdavis.edu/debugR.html where I've now included the Quick Start. I hope to write up a longer example for Tal's e-newsletter. Norm __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Get missinfg values with dataframe using read.spss
Hi All, Here is my problem. I need to get data frame (and not a list) while reading spss file using read.spss. For which I can put one parameter of read.spss as to.data.frame=TRUE. Now in doing so, I dont get missing values. Is there a way to get missings values along with data frame? Thanks in advance. -- SG [[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] Get missinfg values with dataframe using read.spss
Hi Smart Guy, You can try use.missings = TRUE. I am not sure how well this will work. If you really need it and use.missings = TRUE does not work, I would just read it in as a list, and then maybe create a new data frame based on the list. See ?as.data.frame for a way to do this. Then you could have two datasets, one as a list with the missings, one as a data frame for easy use. HTH, Josh On Sun, Oct 30, 2011 at 10:12 PM, Smart Guy smartgu...@gmail.com wrote: Hi All, Here is my problem. I need to get data frame (and not a list) while reading spss file using read.spss. For which I can put one parameter of read.spss as to.data.frame=TRUE. Now in doing so, I dont get missing values. Is there a way to get missings values along with data frame? Thanks in advance. -- SG [[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. -- Joshua Wiley Ph.D. Student, Health Psychology Programmer Analyst II, ATS Statistical Consulting Group University of California, Los Angeles https://joshuawiley.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.