Re: [R] remove low frequent rows
Dear jayuan2008, See ?subset. If I understand your description below, something like this could do the job: a1-data.frame(x=c(a,b,a,b,a),y=c(4,3,6,1,2)) subset(a1,y2) x y 1 a 4 2 b 3 3 a 6 BTW, I think that the final result you described in your post is incorrect. HTH, Jorge On Sun, Aug 31, 2008 at 2:19 AM, Yuan Jian [EMAIL PROTECTED] wrote: Hi, I have a matrix. a-cbind(c(a,b,a),c(4,3,6)) [,1] [,2] [1,] a 4 [2,] b 3 [3,] a 6 I want to remove rows in matrix a whose first column has frequency less than 2. in about example matrix a becomes [,1] [,2] [1,] a 4 [2,] a 6 [[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] remove low frequent rows
DF-cbind(c(a,b,a),c(4,3,6)) DF[(DF[,1] %in% names(which(table(DF[,1]) = 2))),] On Sun, Aug 31, 2008 at 2:19 AM, Yuan Jian wrote: Hi, � I have a matrix. a-cbind(c(a,b,a),c(4,3,6)) [,1] [,2] [1,] a� 4 [2,] b� 3 [3,] a� 6 I want to remove rows in matrix a whose first column has frequency less than 2. in about example matrix a becomes [,1] [,2] [1,] a� 4 [2,] a� 6 [[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] remove low frequent rows
See ?ave and try this: a[as.numeric(ave(a[,1], a[,1], FUN = length)) 1, ] On Sun, Aug 31, 2008 at 2:19 AM, Yuan Jian [EMAIL PROTECTED] wrote: Hi, I have a matrix. a-cbind(c(a,b,a),c(4,3,6)) [,1] [,2] [1,] a 4 [2,] b 3 [3,] a 6 I want to remove rows in matrix a whose first column has frequency less than 2. in about example matrix a becomes [,1] [,2] [1,] a 4 [2,] a 6 [[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] give all combinations
Hello, is there a simple way to give all combinations for a given vector: v-c(a,b,c) combination(v,v) becomes aa,ab,ac,bb,bc,cc' combination(v,v,v) becomes aaa,aab,aac,abb,.. [[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] Avoiding factors and levels in data frames
Hello all. I am an experienced R user, I have used R for many years for a wide variety of applications. However, I keep on running into one obstacle: I never want factors or levels in my data frames, but I keep on getting them. Is there any way to globally turn this whole feature of data frames off? Using options(stringAsFactors=FALSE) does not seem to work. Alternatively, if I have a data frame with levels, can I just get rid of them in that data frame? Here is an example: I have a large text file, of which part is in the fixed-width tabular form I need. I created a widths vector and a column names vector. I then read the file as follows: raw1-read.fwf(fn1,widths=widmax,col.names=headermax,stringsAsFactors=FALSE) But raw1 still has factors! It is an old class data frame: is(raw1) [1] data.frame oldClass And it still has levels: raw1[1,1] [1] Gustav wind 229 Levels: - - - - - - - - - - - WIN - - - M ... Z INDICATES C My question is: 1. Can I get rid of the levels in raw1? 2. Even better -- can I stop it getting read in as a data frame with factors? 3. Even better -- can I just tell R to never use factors in my data frames? Or any other solution that occurs to people -- maybe this is the wrong way to go about reading in fixed width data in this kind of file. I would appreciate any help. Asher __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] give all combinations
Yuan Jian jayuan2008 at yahoo.com writes: Hello, is there a simple way to give all combinations for a given vector: v-c(a,b,c) combination(v,v) becomes aa,ab,ac,bb,bc,cc' combination(v,v,v) becomes aaa,aab,aac,abb,.. vv-c(outer(v,v,paste)) vv [1] a a b a c a a b b b c b a c b c c c vvv-c(outer(vv,v,paste) vvv [1] a a a b a a c a a a b a b b a c b a a c a b c a c c a a a b b a b c a b a b b b b b c b b [16] a c b b c b c c b a a c b a c c a c a b c b b c c b c a c c b c c c c c [[alternative HTML version deleted]] __ 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] Avoiding factors and levels in data frames
On Sun, 31-Aug-2008 at 12:01PM +0300, Asher Meir wrote: | Hello all. | | I am an experienced R user, I have used R for many years for a wide | variety of applications. However, I keep on running into one obstacle: | I never want factors or levels in my data frames, but I keep on | getting them. Is there any way to globally turn this whole feature of | data frames off? Using options(stringAsFactors=FALSE) does not seem to | work. Have you tried the as.is option? -- ~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~. ___Patrick Connolly {~._.~} Great minds discuss ideas _( Y )_Middle minds discuss events (:_~*~_:)Small minds discuss people (_)-(_) . Anon ~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] give all combinations
Lucien Lemmens wrote: Yuan Jian jayuan2008 at yahoo.com writes: Hello, is there a simple way to give all combinations for a given vector: v-c(a,b,c) combination(v,v) becomes aa,ab,ac,bb,bc,cc' combination(v,v,v) becomes aaa,aab,aac,abb,.. vv-c(outer(v,v,paste)) vv [1] a a b a c a a b b b c b a c b c c c vvv-c(outer(vv,v,paste) vvv [1] a a a b a a c a a a b a b b a c b a a c a b c a c c a a a b b a b c a b a b b b b b c b b [16] a c b b c b c c b a a c b a c c a c a b c b b c c b c a c c b c c c c c Notice that ca was not in the request for combination(v,v), so it's a bit trickier. I was thinking ?combn, but that doesn't count the duplicated cases: combn(v,2) [,1] [,2] [,3] [1,] a a b [2,] b c c -- O__ Peter Dalgaard Øster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] give all combinations
I had a similar problem recently where I used the following code: v - factor(letters[1:3]) all.cases - expand.grid(v, v) all.cases[as.numeric(all.cases[, 2]) = as.numeric(all.cases[, 1]), ] I'm not sure how to extend it cleanly to an arbitrary number of vectors, though. Baptiste On 31 Aug 2008, at 11:18, Peter Dalgaard wrote: Lucien Lemmens wrote: Yuan Jian jayuan2008 at yahoo.com writes: Hello, is there a simple way to give all combinations for a given vector: v-c(a,b,c) combination(v,v) becomes aa,ab,ac,bb,bc,cc' combination(v,v,v) becomes aaa,aab,aac,abb,.. vv-c(outer(v,v,paste)) vv [1] a a b a c a a b b b c b a c b c c c vvv-c(outer(vv,v,paste) vvv [1] a a a b a a c a a a b a b b a c b a a c a b c a c c a a a b b a b c a b a b b b b b c b b [16] a c b b c b c c b a a c b a c c a c a b c b b c c b c a c c b c c c c c Notice that ca was not in the request for combination(v,v), so it's a bit trickier. I was thinking ?combn, but that doesn't count the duplicated cases: combn(v,2) [,1] [,2] [,3] [1,] a a b [2,] b c c -- O__ Peter Dalgaard Øster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. _ Baptiste Auguié School of Physics University of Exeter Stocker Road, Exeter, Devon, EX4 4QL, UK Phone: +44 1392 264187 http://newton.ex.ac.uk/research/emag __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] give all combinations
thanks. how to remove the combinations that has same ingredients: in C, the following sentences are used. for i = 1 to 3 for a b a, a a b and b a a, only one of them is kept, others are remove. v-c(a,b,c) v v should be aa, ab, ac, bc --- On Sun, 8/31/08, Lucien Lemmens [EMAIL PROTECTED] wrote: From: Lucien Lemmens [EMAIL PROTECTED] Subject: Re: [R] give all combinations To: [EMAIL PROTECTED] Date: Sunday, August 31, 2008, 8:38 AM Yuan Jian jayuan2008 at yahoo.com writes: Hello, is there a simple way to give all combinations for a given vector: v-c(a,b,c) combination(v,v) becomes aa,ab,ac,bb,bc,cc' combination(v,v,v) becomes aaa,aab,aac,abb,.. vv-c(outer(v,v,paste)) vv [1] a a b a c a a b b b c b a c b c c c vvv-c(outer(vv,v,paste) vvv [1] a a a b a a c a a a b a b b a c b a a c a b c a c c a a a b b a b c a b a b b b b b c b b [16] a c b b c b c c b a a c b a c c a c a b c b b c c b c a c c b c c c c c [[alternative HTML version deleted]] __ 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. [[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] give all combinations
thanks. how to remove the combinations that has same ingredients: in C, the following sentences are used. for i = 1 to 3 for a b a, a a b and b a a, only one of them is kept, others are remove. v-c(a,b,c) v v should be aa, ab, ac, bc --- On Sun, 8/31/08, Lucien Lemmens [EMAIL PROTECTED] wrote: From: Lucien Lemmens [EMAIL PROTECTED] Subject: Re: [R] give all combinations To: [EMAIL PROTECTED] Date: Sunday, August 31, 2008, 8:38 AM Yuan Jian jayuan2008 at yahoo.com writes: Hello, is there a simple way to give all combinations for a given vector: v-c(a,b,c) combination(v,v) becomes aa,ab,ac,bb,bc,cc' combination(v,v,v) becomes aaa,aab,aac,abb,.. vv-c(outer(v,v,paste)) vv [1] a a b a c a a b b b c b a c b c c c vvv-c(outer(vv,v,paste) vvv [1] a a a b a a c a a a b a b b a c b a a c a b c a c c a a a b b a b c a b a b b b b b c b b [16] a c b b c b c c b a a c b a c c a c a b c b b c c b c a c c b c c c c c [[alternative HTML version deleted]] __ 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. [[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] give all combinations
thanks. how to remove the combinations that has same ingredients: in C, the following sentences are used. for i = 1 to 3 for a b a, a a b and b a a, only one of them is kept, others are remove. v-c(a,b,c) v v should be aa, ab, ac, bc --- On Sun, 8/31/08, Lucien Lemmens [EMAIL PROTECTED] wrote: From: Lucien Lemmens [EMAIL PROTECTED] Subject: Re: [R] give all combinations To: [EMAIL PROTECTED] Date: Sunday, August 31, 2008, 8:38 AM Yuan Jian jayuan2008 at yahoo.com writes: Hello, is there a simple way to give all combinations for a given vector: v-c(a,b,c) combination(v,v) becomes aa,ab,ac,bb,bc,cc' combination(v,v,v) becomes aaa,aab,aac,abb,.. vv-c(outer(v,v,paste)) vv [1] a a b a c a a b b b c b a c b c c c vvv-c(outer(vv,v,paste) vvv [1] a a a b a a c a a a b a b b a c b a a c a b c a c c a a a b b a b c a b a b b b b b c b b [16] a c b b c b c c b a a c b a c c a c a b c b b c c b c a c c b c c c c c [[alternative HTML version deleted]] __ 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. [[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] give all combinations
thanks. how to remove the combinations that has same ingredients: in other computer language, the following sentences are used. for i = 1 to 3 for j = i+1 to 3 for a b a, a a b and b a a, only one of them is kept, others are remove. v-c(a,b,c) v v should be aa, ab, ac, bc --- On Sun, 8/31/08, Lucien Lemmens [EMAIL PROTECTED] wrote: From: Lucien Lemmens [EMAIL PROTECTED] Subject: Re: [R] give all combinations To: [EMAIL PROTECTED] Date: Sunday, August 31, 2008, 8:38 AM Yuan Jian jayuan2008 at yahoo.com writes: Hello, is there a simple way to give all combinations for a given vector: v-c(a,b,c) combination(v,v) becomes aa,ab,ac,bb,bc,cc' combination(v,v,v) becomes aaa,aab,aac,abb,.. vv-c(outer(v,v,paste)) vv [1] a a b a c a a b b b c b a c b c c c vvv-c(outer(vv,v,paste) vvv [1] a a a b a a c a a a b a b b a c b a a c a b c a c c a a a b b a b c a b a b b b b b c b b [16] a c b b c b c c b a a c b a c c a c a b c b b c c b c a c c b c c c c c [[alternative HTML version deleted]] __ 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. [[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] give all combinations
thanks. how to remove the combinations that has same ingredients: in other computer language, the following sentences are used. for i = 1 to 3 for j = i+1 to 3 for a b a, a a b and b a a, only one of them is kept, others are remove. v-c(a,b,c) v v should be aa, ab, ac, bc --- On Sun, 8/31/08, Lucien Lemmens [EMAIL PROTECTED] wrote: From: Lucien Lemmens [EMAIL PROTECTED] Subject: Re: [R] give all combinations To: [EMAIL PROTECTED] Date: Sunday, August 31, 2008, 8:38 AM Yuan Jian jayuan2008 at yahoo.com writes: Hello, is there a simple way to give all combinations for a given vector: v-c(a,b,c) combination(v,v) becomes aa,ab,ac,bb,bc,cc' combination(v,v,v) becomes aaa,aab,aac,abb,.. vv-c(outer(v,v,paste)) vv [1] a a b a c a a b b b c b a c b c c c vvv-c(outer(vv,v,paste) vvv [1] a a a b a a c a a a b a b b a c b a a c a b c a c c a a a b b a b c a b a b b b b b c b b [16] a c b b c b c c b a a c b a c c a c a b c b b c c b c a c c b c c c c c [[alternative HTML version deleted]] __ 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. [[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] give all combinations
thanks. how to remove the combinations that has same ingredients: in other computer language, the following sentences are used. for i = 1 to 3 for j = i+1 to 3 for a b a, a a b and b a a, only one of them is kept, others are remove. v-c(a,b,c) v v should be aa, ab, ac, bc --- On Sun, 8/31/08, Lucien Lemmens [EMAIL PROTECTED] wrote: From: Lucien Lemmens [EMAIL PROTECTED] Subject: Re: [R] give all combinations To: [EMAIL PROTECTED] Date: Sunday, August 31, 2008, 8:38 AM Yuan Jian jayuan2008 at yahoo.com writes: Hello, is there a simple way to give all combinations for a given vector: v-c(a,b,c) combination(v,v) becomes aa,ab,ac,bb,bc,cc' combination(v,v,v) becomes aaa,aab,aac,abb,.. vv-c(outer(v,v,paste)) vv [1] a a b a c a a b b b c b a c b c c c vvv-c(outer(vv,v,paste) vvv [1] a a a b a a c a a a b a b b a c b a a c a b c a c c a a a b b a b c a b a b b b b b c b b [16] a c b b c b c c b a a c b a c c a c a b c b b c c b c a c c b c c c c c [[alternative HTML version deleted]] __ 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. [[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] give all combinations
thanks. how to remove the combinations that has same ingredients: in other computer language, the following sentences are used. for i = 1 to 3 for j = i+1 to 3 for a b a, a a b and b a a, only one of them is kept, others are remove. v-c(a,b,c) v v should be aa, ab, ac, bc --- On Sun, 8/31/08, Lucien Lemmens [EMAIL PROTECTED] wrote: From: Lucien Lemmens [EMAIL PROTECTED] Subject: Re: [R] give all combinations To: [EMAIL PROTECTED] Date: Sunday, August 31, 2008, 8:38 AM Yuan Jian jayuan2008 at yahoo.com writes: Hello, is there a simple way to give all combinations for a given vector: v-c(a,b,c) combination(v,v) becomes aa,ab,ac,bb,bc,cc' combination(v,v,v) becomes aaa,aab,aac,abb,.. vv-c(outer(v,v,paste)) vv [1] a a b a c a a b b b c b a c b c c c vvv-c(outer(vv,v,paste) vvv [1] a a a b a a c a a a b a b b a c b a a c a b c a c c a a a b b a b c a b a b b b b b c b b [16] a c b b c b c c b a a c b a c c a c a b c b b c c b c a c c b c c c c c [[alternative HTML version deleted]] __ 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. [[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] give all combinations
thanks. how to remove the combinations that has same ingredients: in C, the following sentences are used. for i = 1 to 3 for a b a, a a b and b a a, only one of them is kept, others are remove. v-c(a,b,c) v v should be aa, ab, ac, bc --- On Sun, 8/31/08, Lucien Lemmens [EMAIL PROTECTED] wrote: From: Lucien Lemmens [EMAIL PROTECTED] Subject: Re: [R] give all combinations To: [EMAIL PROTECTED] Date: Sunday, August 31, 2008, 8:38 AM Yuan Jian jayuan2008 at yahoo.com writes: Hello, is there a simple way to give all combinations for a given vector: v-c(a,b,c) combination(v,v) becomes aa,ab,ac,bb,bc,cc' combination(v,v,v) becomes aaa,aab,aac,abb,.. vv-c(outer(v,v,paste)) vv [1] a a b a c a a b b b c b a c b c c c vvv-c(outer(vv,v,paste) vvv [1] a a a b a a c a a a b a b b a c b a a c a b c a c c a a a b b a b c a b a b b b b b c b b [16] a c b b c b c c b a a c b a c c a c a b c b b c c b c a c c b c c c c c [[alternative HTML version deleted]] __ 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. [[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] give all combinations
thanks. how to remove the combinations that has same ingredients: v-c(a,b,c) v.v becomes ab, ac, bc (aa,bb,cc are removed) v.v.v becomes abc (aaa,aab,... are removed, because they have same ingredients) that is. the following sentences can be used. for(i in 1:3){ for (j in i+1:3){ v.v-c(v.v,paste(v[i],v[j])) } } is there simpler way to do? thanks Yu --- On Sun, 8/31/08, Lucien Lemmens [EMAIL PROTECTED] wrote: From: Lucien Lemmens [EMAIL PROTECTED] Subject: Re: [R] give all combinations To: [EMAIL PROTECTED] Date: Sunday, August 31, 2008, 8:38 AM Yuan Jian jayuan2008 at yahoo.com writes: Hello, is there a simple way to give all combinations for a given vector: v-c(a,b,c) combination(v,v) becomes aa,ab,ac,bb,bc,cc' combination(v,v,v) becomes aaa,aab,aac,abb,.. vv-c(outer(v,v,paste)) vv [1] a a b a c a a b b b c b a c b c c c vvv-c(outer(vv,v,paste) vvv [1] a a a b a a c a a a b a b b a c b a a c a b c a c c a a a b b a b c a b a b b b b b c b b [16] a c b b c b c c b a a c b a c c a c a b c b b c c b c a c c b c c c c c [[alternative HTML version deleted]] __ 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. [[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] Fitted probabilities in conditional logit regression
Dear R-help, I'm doing conditional logit regression for a discrete choice model. I want to know whether there's a way to get the fitted probabilities. In Stata, predict works for clogit, but it seems that in R predict does not. Thank you very much! Best wishes. Sincerely, Min -- Min Chen Graduate Student Department of Agricultural, Food and Resource Economics Michigan State University [[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] give all combinations
Another solution requiring also a bit of programming is: l-letters[1:3] c2-c() for(i in 1:3){c2-c(c2,paste(letters[i],letters[i:3],sep=))} c2 [1] aa ab ac bb bc cc n-length(c2) c3-c();for(i in 1:n){c3-c(c3,paste(c2[i],letters[ceiling(i/2):3],sep=))} c3 [1] aaa aab aac aba abb abc acb acc bbb bbc bcc ccc __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] cex.axis for the x axis
Thanks Mark, I was hoping I wouldn't have to annotate axes individually but have been able to work through it with your direction. Pavel. -- View this message in context: http://www.nabble.com/cex.axis-for-the-x-axis-tp18353453p19241307.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 question about minimization of two functions
if (typeof YAHOO == undefined) { var YAHOO = {}; } YAHOO.Shortcuts = YAHOO.Shortcuts || {}; YAHOO.Shortcuts.hasSensitiveText = false; YAHOO.Shortcuts.sensitivityType = []; YAHOO.Shortcuts.doUlt = false; YAHOO.Shortcuts.location = us; YAHOO.Shortcuts.document_id = 0; YAHOO.Shortcuts.document_type = ; YAHOO.Shortcuts.document_title = Minimization of two functions; YAHOO.Shortcuts.document_publish_date = ; YAHOO.Shortcuts.document_author = [EMAIL PROTECTED]; YAHOO.Shortcuts.document_url = ; YAHOO.Shortcuts.document_tags = ; YAHOO.Shortcuts.document_language = english; YAHOO.Shortcuts.annotationSet = { lw_1220183206_0: { text: monotone functions, extended: 0, startchar: 535, endchar: 552, start: 535, end: 552, extendedFrom: , predictedCategory: , predictionProbability: 0, weight: 0.231441, type: [shortcuts:/concept], category: [CONCEPT], wikiId: , relatedWikiIds: [], relatedEntities: [], showOnClick: [], context: location of x, i.e. min(f(x),g(x)). f and g are not monotone functions. So I need to obtain numerical minimization. How can I, metaData: { visible: true } } }; Hello, Let f(x) and g(x) be two functions of x in [a,b]. I want to find out the minimum of these two functions of x and location of x, i.e. min(f(x),g(x)). f and g are not monotone functions. So I need to obtain numerical minimization. How can I do it? Many thanks for your time. Farhad [[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] Parenthesis recognition with grep
Dear R-users, I need to dynamically recognize the index of a given string myStr in a vector of string. The problem is that myStr might contain parenthesis, causing grep not to recognize it the way I want (see below). The help mentions that the pattern used by grep should be in the POSIX format... I guess the problem is here; unfortunately, I am not familiar with the subtleties of the POSIX format ex: myStr - YD(001) headers -c(TD, YD(001), YD(002), T, Y(001), Y(002)) grep(myStr, headers) How should I modify my grep call to get the match right? Thank you for your help, Sebastien __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Unable to send color palette through plot.Design to method=image
David Winsemius wrote: I have been trying to specify a different color palette to the image method in plot.Design. My model has crossed two rcs() arguments and one two-level gender argument. The goal which appears to have been mostly achieved is to produce separate bivariate plots for men and women The call to plot does produce a level plot but it appears only with the default color palette despite various efforts to supply a col argument. I even took a crack at hacking the plot.Design function, adding a col=col parameter to be passed in the function call to image(), but failed to get the desired effect: I improved the source code to make use of col for 3-d plot types of image, contour, and persp. I don't know why your hack didn't work. The new changes work for me, and the updates will be in the next release of Design to CRAN. I will e-mail you a copy of the source code to use in the meantime. Frank # else image(xseqn, y, zmat, xlab = xlab, ylab = laby , col = col) library(Hmisc); library(Design) lr.fit6 - lrm(death ~ rcs(BL_CHOLEST.A,c(180,220,280))*rcs(BL_HDL.A,c(40,55,70))*Sex, data = pref900) # str(pref900[,c(BL_HDL.A,BL_CHOLEST.A,death)]) $'data.frame':910659 obs. of 3 variables: $ BL_HDL.A: num 34 35 40 46 39 45 46 34 42 52 ... $ BL_CHOLEST.A: num 181 184 238 134 180 220 125 256 265 175 ... $ death : logi FALSE FALSE FALSE FALSE FALSE FALSE ... plot(lr.fit6, BL_HDL.A=seq(25,125, length=50),BL_CHOLEST.A=seq(100, 350, length=70), Sex=Male, col = rainbow(15), method=image) Respectfully; David Winsemius, MD, MPH Heritage Laboratories, West Hartford, CT, 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. -- Frank E Harrell Jr Professor and Chair School of Medicine Department of Biostatistics Vanderbilt University __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Parenthesis recognition with grep
Dear Sébastien, Is this what you want? which(myStr==headers) [1] 2 which(headers%in%myStr) [1] 2 HTH, Jorge On Sun, Aug 31, 2008 at 10:28 AM, Sébastien [EMAIL PROTECTED] wrote: Dear R-users, I need to dynamically recognize the index of a given string myStr in a vector of string. The problem is that myStr might contain parenthesis, causing grep not to recognize it the way I want (see below). The help mentions that the pattern used by grep should be in the POSIX format... I guess the problem is here; unfortunately, I am not familiar with the subtleties of the POSIX format ex: myStr - YD(001) headers -c(TD, YD(001), YD(002), T, Y(001), Y(002)) grep(myStr, headers) How should I modify my grep call to get the match right? Thank you for your help, Sebastien __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Non-numeric argument to fft
[EMAIL PROTECTED] wrote: If this is the case then how to I take a list of numbers (residuals in this case) and create anothe list that is longer and padded by zeros? Maybe fft already does this for me but as I understood it I need to pass an vector to the fft that is of a power of 2 length. If I still need to do this then is there something wrong with the code below? spectrum() helps to make the intelligent tasks, but is sometimes too clever. If you just want the fft, then you can pad as follows: Replace the lines x - as.numeric(rep(0,512)) x - merge(residuals(fit), x) by something like x - rep(0, 512) res - residuals(fit) x[seq_along(res)] - res Uwe Ligges Thank you. Kevin Uwe Ligges [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] wrote: I am calling fft and getting a non-numeric error: + fit - lm(Quantity ~ DayOfYear, .sublist) + # Make the time series + x - as.numeric(rep(0,512)) + x - merge(residuals(fit), x) + # Transform range to -pi - pi + x - x - pi + x - x * (2 * pi)/(max(x) - min(x)) + fft(x) Error in fft(x) : non-numeric argument How can I tell what the non-numeric argument is? There is only one argument. What am I doing wrong? I guess merge() does something different from what you expect and your x is a data.frame rather than a vector now Uwe Ligges Thank you. Kevin __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Parenthesis recognition with grep
Hi Jorge, This is doing the work just fine. Thank you ! However, I would like to know what should be done with the grep call... just for my personal education :) Sebastien Jorge Ivan Velez a écrit : Dear Sébastien, Is this what you want? which(myStr==headers) [1] 2 which(headers%in%myStr) [1] 2 HTH, Jorge On Sun, Aug 31, 2008 at 10:28 AM, Sébastien [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: Dear R-users, I need to dynamically recognize the index of a given string myStr in a vector of string. The problem is that myStr might contain parenthesis, causing grep not to recognize it the way I want (see below). The help mentions that the pattern used by grep should be in the POSIX format... I guess the problem is here; unfortunately, I am not familiar with the subtleties of the POSIX format ex: myStr - YD(001) headers -c(TD, YD(001), YD(002), T, Y(001), Y(002)) grep(myStr, headers) How should I modify my grep call to get the match right? Thank you for your help, Sebastien __ R-help@r-project.org mailto:R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Parenthesis recognition with grep
Try: myStr - YD\\(001\\) In POSIX format, or in most such formats in fact, special characters like parentheses have a particular meaning, and need to be escaped if they are to have the parenthesis meaning. This is done typically by putting a backslash in front of them. Since however a backslash has a special meaning inside a ..., namely it is use to escape things, we need to escape it, hence the two backslashes you see back to back. You can use: cat(myStr) To see what hte string actually has in it. A better way to solve your problem in your case is to use the original myStr you had, but change the grep call to be: grep(myStr, headers, fixed=TRUE) The fixed=TRUE part tells it to treat myStr as a string to be matched exactly. Of course ?grep should probably have led you to this. Haris Skiadas Department of Mathematics and Computer Science Hanover College On Aug 31, 2008, at 10:54 AM, Sébastien wrote: Hi Jorge, This is doing the work just fine. Thank you ! However, I would like to know what should be done with the grep call... just for my personal education :) Sebastien Jorge Ivan Velez a écrit : Dear Sébastien, Is this what you want? which(myStr==headers) [1] 2 which(headers%in%myStr) [1] 2 HTH, Jorge On Sun, Aug 31, 2008 at 10:28 AM, Sébastien [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: Dear R-users, I need to dynamically recognize the index of a given string myStr in a vector of string. The problem is that myStr might contain parenthesis, causing grep not to recognize it the way I want (see below). The help mentions that the pattern used by grep should be in the POSIX format... I guess the problem is here; unfortunately, I am not familiar with the subtleties of the POSIX format ex: myStr - YD(001) headers -c(TD, YD(001), YD(002), T, Y(001), Y(002)) grep(myStr, headers) How should I modify my grep call to get the match right? Thank you for your help, Sebastien __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] lm() and dffits
Ranney, Steven steven.ranney at montana.edu writes: 1) fit a simple lm(LW~LL) 2) calculate the dffits for those data points 3) remove those data points that are 2*sqrt(p/n) (where p=the number of parameters and n=number of data points; p=3 in a linear model, correct? Intercept, slope, and error term?) 4) rerun the model MINUS those data points 5) compare the two lm() Now, each of these steps I can do seperately, but only by outputting the dffits to a .csv then removing the large dffits by hand, reading the .csv back into R, rerunning the lm(), and comparing the first lm() to the second lm(). I would imagine that there is a better (easier, I hope!) way to doing all of this. Any ideas? You could do the following: # x = rnorm(100) y=rnorm(100) y[40] = y[40]+30 # generate outliere df = data.frame(x=x,y=y) lmfit1 = lm(y~x, data=df) # fit all data thresh = 3 # Choose any data-dependent threshold nice = abs(dffits(lmfit)) thresh # note that nice[40] is the only FALSE df2 = df[nice,] lmfit2 = lm(y~x, data=df2) summary(lmfit1) summary(lmfit2) # However, this is a bit Denver-Style Home-Brewery. Instead of using this ad-hoc method, you are probably better off using one of the robust methods, for example in MASS. Dieter __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 do parallel computation?
Is it possible to do parallel computation in R? How? -- View this message in context: http://www.nabble.com/How-to-do-parallel-computation--tp19244438p19244438.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 do parallel computation?
On 31 August 2008 at 10:53, ZT2008 wrote: | Is it possible to do parallel computation in R? Yes. | How? MPI, PVM, NWS, Snow, ... You could have a look at the slides from my introductory tutorial at useR! earlier this months. About one-third of the material was about parallel computing approaches to R. It's at the top of this page: http://dirk.eddelbuettel.com/presentations.html Some other talks I gave at earlier conferences cover some of this too. Of course, other talks from the conference may be relevant for you too. See the 'Presentation' link at http://www.statistik.uni-dortmund.de/useR-2008/ Hope this helps, Dirk -- Three out of two people have difficulties with fractions. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 instead of warning?
dear R experts---is it possible to ask R to abort with an error instead of just giving a warning when I am mis-assigning vectors (or other data structures) that are not compatible? that is, I would like 1: In matrix(value, n, p) ... : data length [12] is not a sub-multiple or multiple of the number of columns [11] to force an error. are there any other warnings() that are really more programming errors that I could also convert into an abort? sincerely, /iaw __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] tryCatch
Hi All R-Gurus, I am trying to debug a program, and I think tryCatch will help. The functions involved process through so many times before I encounter the error, things are a bit slow to use debug and browser(). I've read the help file and postings on conditions, and am still having trouble. While running my program I am getting a NAN from a called function, and I want to know the input parameters that generate this, so I have included the following in the code of the main function (calling function): tryCatch(delM S, exception=function(e)print(list(S=S, Si=Si, D=D, theta=S/N, incr=del.t)), finally=print(finally)) This is actually part of an if statement, where delM S is the condition. Now if delM is an NAN an error results. Now the above tryCatch does not work in the way I wish it. What sort of condition does this little expression throw when it encounters delM=NAN? is it an exception? What is wrong with the above handler etc? Kind regards, Matt Redding DISCLAIMER The information contained in the above e-mail message or messages (which includes any attachments) is confidential and may be legally privileged. It is intended only for the use of the person or entity to which it is addressed. If you are not the addressee any form of disclosure, copying, modification, distribution or any action taken or omitted in reliance on the information is unauthorised. Opinions contained in the message(s) do not necessarily reflect the opinions of the Queensland Government and its authorities. If you received this communication in error, please notify the sender immediately and delete it from your computer system network. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 with Rcmdr package
Dear all, A friend of mine, who just installed Rcmdr package. When calling the package, the error as following comes up. And actually, I've checked in CRAN packages, the tcltk package doesn't exist anymore, but tcltk2. Any help is appreciated Regards Nguyen D Nguyen Garvan Institute of Medical Research Sydney, Australia library(Rcmdr) Loading required package: tcltk Loading Tcl/Tk interface ...Error in structure(.External(dotTclObjv, objv, PACKAGE = tcltk), class = tclObj) : [tcl] invalid command name se. Error : .onLoad failed in 'loadNamespace' for 'tcltk' Error: package 'tcltk' could not be loaded __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] error instead of warning?
ivo welch wrote: dear R experts---is it possible to ask R to abort with an error instead of just giving a warning when I am mis-assigning vectors (or other data structures) that are not compatible? that is, I would like 1: In matrix(value, n, p) ... : data length [12] is not a sub-multiple or multiple of the number of columns [11] to force an error. are there any other warnings() that are really more programming errors that I could also convert into an abort? You can convert all warnings to errors using option(warn=2). Duncan Murdoch sincerely, /iaw __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] reading data in serial port - win32
Hello all I'd like to get some instruments data by serial port (COM1 - win32) I make a loopback serial adapter for a testing with the code: system('mode COM1 9600,N,8,1') ser - file(COM1, open='r+') isOpen(ser) write('12345', ser) scan(ser, what=as.character(1), n=1) So I get the data that I wrote in the port... But I don't have a more fine control about the serial configuration with this approach like timeout, handshake etc... Is there a specific package (library?) for hardware communications? ( For serial port specifically ) Thanks Cleber ___ Experimente já e veja as novidades. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 draw a perspective pyramid
Dear list, I am trying to construct a perspective plot of a 2D triangle, or pyramid. I can easily do the one dimensional plot (code below), but I can't figure out how to do it in a perspective plot for two input variables. Does anyone have a simple solution? Thanks! Derek #code for a triangle u - seq(-1,1,.001) tri - (1-abs(u)) plot(tri~u,type=l,main=Second Iteration Kernel: Two Input Variables,lwd=2, xlab=x,ylab=y,col=blue) -- View this message in context: http://www.nabble.com/how-to-draw-a-perspective-pyramid-tp19247124p19247124.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] SQL Primer for R
stumped again by SQL... If I have a table named main in an SQLite data base, how do I get the names of all its columns? (I have a mysql book that claims the SHOW command does this sort of thing, but it does not seem to work on SQLite.) regards, /iaw PS: Thanks for the earlier emails on warn=2. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 draw a perspective pyramid
On Aug 31, 2008, at 7:21 PM, dxc13 wrote: Dear list, I am trying to construct a perspective plot of a 2D triangle, or pyramid. I can easily do the one dimensional plot (code below), but I can't figure out how to do it in a perspective plot for two input variables. Does anyone have a simple solution? Thanks! Derek #code for a triangle u - seq(-1,1,.001) tri - (1-abs(u)) plot(tri~u,type=l,main=Second Iteration Kernel: Two Input Variables,lwd=2, xlab=x,ylab=y,col=blue) You probably don't want to have quite so many points in your parameter variables. This is not a correct solution, but maybe it will get you further along: u - seq(-1,1,.1) v - seq(-1,1,.1) z - outer(u,v,f) f - function(u,v) { val - 1 -abs(u) -abs(v) } z - outer(u,v,f) persp(u,v,z, xlim = c(-2,2), phi = 30, theta=30) For one complete solution fry ?ifelse -- David Winsemius __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 isoMDS not found?
When I type isoMDS() in the R environment, a error shows up: no such function isoMDS. Why? And what should I do to use isoMDS? Additionally, I cannot install add-on packages. Typing Rcmd.exe INSTALL e:/VR_7.2-44.zip results in 'perl' is neither command nor executable file Why this happens?Thanks. The setup file I downloaded is R-2.7.2-win32.exe. After double click and installation, I did nothing more. [[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] SQL Primer for R
On Sun, Aug 31, 2008 at 9:29 PM, ivo welch [EMAIL PROTECTED] wrote: stumped again by SQL... If I have a table named main in an SQLite data base, how do I get the names of all its columns? (I have a mysql book that claims the SHOW command does this sort of thing, but it does not seem to work on SQLite.) look up the pragma command. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 isoMDS not found?
Hi there, You must load the MASS package first, i.e, library(MASS) ?isoMDS HTH, Jorge On Sun, Aug 31, 2008 at 10:14 PM, ³ÂÎä [EMAIL PROTECTED] wrote: When I type isoMDS() in the R environment, a error shows up: no such function isoMDS. Why? And what should I do to use isoMDS? Additionally, I cannot install add-on packages. Typing Rcmd.exe INSTALL e:/VR_7.2-44.zip results in 'perl' is neither command nor executable file Why this happens?Thanks. The setup file I downloaded is R-2.7.2-win32.exe. After double click and installation, I did nothing more. [[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 with stl
I just realized after some tips and a little digging that what I was trying to do manually has already been done. I was trying to fit my data using 'lm' then taking the residual data and trying to do a spectral estimate (for seasonality) usiing fft and then passing the residual of all of that to arima to get the irregular portion of the time series forecast equation. I found 'stl' that advertises that it does all of this (and probably better than my efforts). The only problem that I found was that it takes a time-series object. Time-series objects don't handle missing observations. Say I only have two observations for the year (enough to fit a line through). I can easily fit a line through the observation points but if I add in zeros for the missing observations least squares will undoubtedly throw my observations out and fit the wrong line. The other steps will more than likely have residual data so I don't have to worry for these steps about missing data. Has anyon! e used 'stl' with missing observations? If so what sort of tricks did you use to get around the missing data and time series? Thank you. Kevin __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.