Re: [R] Problems with merge
HI, Possibly R FAQ: 7.31 data1New-data1 data1New$A- round(data1New$A,2) data2New- data2 data2New$A- round(data2New$A,2) merge(data1New,data2New,by=A) # A B C #1 0.0 0.9 10.0 #2 1.1 0.6 11.1 #3 1.4 0.7 11.4 #4 3.1 0.4 13.1 #5 4.4 0.8 14.4 A.K. Hello, Lets say we have these two data frames: data1-data.frame(c(1.23,1.363332,6.43209,4.230593,3.10294,5.09333,1.1,1.4,4.4,0),seq(0,by=0.1,length.out=10)) names(data1)-c(A,B) data2-data.frame(seq(0,6,by=0.1),seq(10,16,by=0.1)) names(data2)-c(A,C) And we would like to merge only the similar values from column A. merge(data1,data2,by=A,all=FALSE) we get: A B C 1 0.0 0.9 10.0 2 1.1 0.6 11.1 3 4.4 0.8 14.4 Unfortunately, it's missing the value of 1.4 in both data.frame columns A. Similarly, if we instead use: merge(data1,data2,by=A,all=TRUE) the value of 1.4 is duplicated while 0, 1.1, and 4.4 is not. All of the mathematical functions work as they should on the 1.4, yet merge seems to think that the two 1.4 in the different data frames are completely different values. I must be going crazy, because I use the merge function all the time and I've never run into this problem before. Thanks. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Rank Amateur Question
Greetings, I have just downloaded R onto a 64bit PC running Microsoft 7 Home Edition via Rgui. I have quite a bit of programming experience, though not as a professional programmer. I am a Measurement and Assessment professional (standardized testing). I would like to be able to write R scripts, and call them from the command line in Rgui. After two attempts, I receive the following error messages R CMD BATCH test.R Error: unexpected symbol in R CMD Rscript test.R Error: unexpected symbol in Rscript test.R These commands were taken directly from the R documents found on the R-project website. Clearly, I am doing something wrong. The script test.R resides in the R directory, and includes 24 + 6 and nothing more. The path to test.R is C:\Program Files\R\test.R Any assistance would be appreciated. Mark Russell, MEd MESA Quidquid Latine dictum sit altum videtur. [[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] identical() function issue on R when built with ICC, ICL
Hello Guys, I am trying to build R using the Intel compilers: ICC, ICPC. The first time I ran the built I got the error below: mlutils.c(107): error: floating-point operation result is out of range double NA_REAL = ML_NAN; ^ mlutils.c(108): error: floating-point operation result is out of range double R_PosInf = ML_POSINF, R_NegInf = ML_NEGINF; ^ mlutils.c(108): error: floating-point operation result is out of range double R_PosInf = ML_POSINF, R_NegInf = ML_NEGINF; ^ compilation aborted for mlutils.c (code 2) I had to make a change to the mlutils.c file to avoid the issue, that problem is related to the Intel ICC compiler: http://software.intel.com/en-us/articles/floating-point-operation-result-out-of-range-in-static-initialization/ The workaround I tried first is to use some built in function: #ifdef __INTEL_COMPILER double NA_REAL = ((__builtin_nanl())); double R_PosInf = ((__builtin_huge_vall())); double R_NegInf = ((-__builtin_huge_vall())); #else double NA_REAL = ML_NAN; double R_PosInf = ML_POSINF, R_NegInf = ML_NEGINF; #endif Once I fix that issue, everything built without problems. However if I run the make check to test R, I got one issue: Testing examples for package 'base' Error: testing 'base' failed Execution halted make[3]: *** [test-Examples-Base] Error 1 This issue is related to the identical() function, it does not give the expected output when using the arguments: num.eq, single.NA, etc. Here is an example: ### --- Pickyness Flags : - ## the infamous example: identical(0., -0.) # TRUE, i.e. not differentiated [1] TRUE identical(0., -0., num.eq = FALSE) [1] TRUE ## similar: identical(NaN, -NaN) # TRUE [1] TRUE identical(NaN, -NaN, single.NA=FALSE) # differ on bit-level [1] TRUE ## for functions: f - function(x) x f function (x) x g - compiler::cmpfun(f) g function (x) x bytecode: 0x14840330 identical(f, g) [1] TRUE identical(f, g, ignore.bytecode=FALSE) [1] FALSE ## Don't show: m0 - m - structure(cbind(I=1, a=1:3), foo = bar, class = matrix) attributes(m0) - rev(attributes(m)) names(attributes(m0)) # 'dim' remains first, interestingly... [1] dim classfoo dimnames stopifnot(identical(0, -0), !identical(0, -0, num.eq=FALSE), + identical(NaN, -NaN), !identical(NaN, -NaN, single.NA=FALSE), + identical(m, m0), !identical(m, m0, attrib.as.set=FALSE) ) Error: !identical(0, -0, num.eq = FALSE) is not TRUE Do you have any idea what could be causing this issue? Is that a correct way to initialize the Infinitive Positive,Infinitive Negative, NA_REAL? Any help would be appreciated. Thanks in advance, Humberto. [[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] Discrete simulated annealing
On Tue, 28 May 2013, Marcus Nunes marcus.nu...@gmail.com writes: Hello all I'm trying to use simulated annealing to optimize a function. I know I can use ?optim with method=SANN to do it. However, I'd like to make optim to search for the best solution among a set of possible points in my domain, and not informing a lower and an upper bound to the optmization function. Do you have an idea on how to do it? Thanks, I have not often used optim/SANN, but you can provide a user-defined neighbourhood function, which you can pass via the 'gr' argument to optim. The neighbourhood function should take a solution as argument, change it slightly and return this changed solution. So you have to write the function such that it can only move from and to the possible points that you specify. A simple example: suppose the desired solution is a vector of length three, and the possible points are specified as integers such that x[1] can be 1, 2 or 7 x[2] can be 1:10 x[3] can be 2, 7 or 17 Then a simple neighbour function might look like this (certainly not the most efficient implementation, but it should give you an idea): neighbour - function(x) { ## possible points pp - list(x1 = c(1,2,7), x2 = c(1:10), x3 = c(2,7,17)) ## choose element of x to change ... change.what - sample.int(length(pp), 1) ## ... and change it x[change.what] - sample(pp[[change.what]], 1) x } (x - c(1,1,2)) ## a feasible initial solution ## [1] 1 1 2 (x - neighbour(x)) ## [1] 2 1 2 (x - neighbour(x)) ## [1] 2 9 2 (x - neighbour(x)) ## [1] 2 9 17 If upper/lower bounds are to be ignored, just set them to ridiculously-high or low values. -- Enrico Schumann Lucerne, Switzerland http://enricoschumann.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.
[R] (no subject)
hallo,i have a problem with running some code in R2Winbugs am getting the following error.Error in FUN(X[[2L]], ...) What might be the problem.with kind regards.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] Distribution, heteroskedasticity etc. tests for glm, tobit and heckit?
Hallo. Is there any package / code snippet to test the distribution assumption, heteroskedasticity, omitted variables, and linearity with the models estimated by maximum likelyhood? I especially need it for three type of models: * binary choice (probit and probit with non-normal distribution) -- estimated by glm * tobit and tobit with non-normal distribution -- estimated by AER or any other suitable package * heckit and heckit with non-normal distribution To be more precise, when I estimate e.g. probit model, I should test that the random part in the data/model is normally distributed. If it was not, the parameter estimates may be biased. In the help and books I found how to estimate the parameters but not how to test the distribution assumption (and other assumptions stated above). Is there any package or code snippet, or do I need to derive the test for every distribution and model, and code it myself? Best wishes, Michal __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Rank Amateur Question
Hi, I do not use R for Windows. But I would say that you have to run 'Rscript.exe' in a CMD prompt, if I am not mistaken. Not in 'Rgui'. In 'Rgui', use 'source'. Hope this helps, Pascal On 05/29/2013 03:07 AM, Mark Russell wrote: Greetings, I have just downloaded R onto a 64bit PC running Microsoft 7 Home Edition via Rgui. I have quite a bit of programming experience, though not as a professional programmer. I am a Measurement and Assessment professional (standardized testing). I would like to be able to write R scripts, and call them from the command line in Rgui. After two attempts, I receive the following error messages R CMD BATCH test.R Error: unexpected symbol in R CMD Rscript test.R Error: unexpected symbol in Rscript test.R These commands were taken directly from the R documents found on the R-project website. Clearly, I am doing something wrong. The script test.R resides in the R directory, and includes 24 + 6 and nothing more. The path to test.R is C:\Program Files\R\test.R Any assistance would be appreciated. Mark Russell, MEd MESA Quidquid Latine dictum sit altum videtur. [[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] Execution of larger blocks of pasted code often fails?
On May 28, 2013, at 19:26 , Mark Breman wrote: Thanks everyone for the suggestions. If the problem is caused by a restriction in one of the (software) components i'm using (OS, terminal etc), should the remaining of the pasted code simply be missing after the point where the error occurs? As can be seen from my example above the entire block of code is pasted and is executed by the R command line, although with errors from the point where the first error occured. Looks like it is dropping characters when its input buffer runs full. That's pretty typical behavior for terminals (real and emulated). Can it be that the paste mechanism i'm using (from GEdit to GNOME terminal on Ubuntu Linux) is adding control characters between pasting multiple blocks of code and these (invisible) characters are causing the problem? -- Peter Dalgaard, Professor, Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Email: pd@cbs.dk Priv: pda...@gmail.com __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] (no subject)
Hello, I would say: 1. Which R version? 2. Which OS? 3. Where is the requested commented, minimal, self-contained, reproducible code? Regards, Pascal On 05/29/2013 10:05 AM, alex mutuku wrote: hallo,i have a problem with running some code in R2Winbugs am getting the following error.Error in FUN(X[[2L]], ...) What might be the problem.with kind regards.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.
Re: [R] (no subject)
On May 29, 2013, at 08:48 , Pascal Oettli wrote: Hello, I would say: 1. Which R version? 2. Which OS? 3. Where is the requested commented, minimal, self-contained, reproducible code? 4. Use a sensible Subject: line, instead of contributing to the (no subject) thread, which on my machine brings up a couple of hundred messages from the last three years... -- Peter Dalgaard, Professor, Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Email: pd@cbs.dk Priv: pda...@gmail.com __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Rank Amateur Question
On 28-05-2013, at 20:07, Mark Russell gibsons...@cox.net wrote: Greetings, I have just downloaded R onto a 64bit PC running Microsoft 7 Home Edition via Rgui. I have quite a bit of programming experience, though not as a professional programmer. I am a Measurement and Assessment professional (standardized testing). I would like to be able to write R scripts, and call them from the command line in Rgui. After two attempts, I receive the following error messages R CMD BATCH test.R Error: unexpected symbol in R CMD Rscript test.R Error: unexpected symbol in Rscript test.R These commands were taken directly from the R documents found on the R-project website. Clearly, I am doing something wrong. The script test.R resides in the R directory, and includes 24 + 6 and nothing more. The path to test.R is C:\Program Files\R\test.R Any assistance would be appreciated. R CMD … and Rscript are not run from within R itself. You probably got this from section B1 of the An Introduction to R manual. You run these commands in a Windows console window. In an interactive R session you use source(…….). ?source There is no need to put your scripts in the same directory where R is installed. Put them somewhere in your user space. Read the introductory manual starting from the first page:-) Berend __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Split-plot and within-subjects
Dear all, I have a probably silly question on how to specify model for a split-plot design and for a within-subject design (1way). I have two factors: factor A with 5 levels and factor B with 2 levels, for each level of factor A I have 4 subjects that experiment both levels of factor B, so this should be a split-plot design without blocking. I've read tons of vignettes, old emails and whatsoever, but I've found somehow diffrent informations concerning the most appropriate way to code this using aov and lme/lmer. My guesses are as follows: aov(y ~ A * B + Error(Subject), data = mydata) lme(y ~ A * B, random = ~1 | Subject, data = mydata) lmer(y ~ A * B + (1 | Subject), data = mydata) This should provide results for a split-plot design without blocks where F statistics are computed according to the correct error strata am I right? I'm a little bit confused because most examples on help pages and vignettes involve blocking which is not present here. Additionally, suppose that instead of analyzing all the data as a whole I split them according to levels of factor A, thus having 5 different within-subjects models to run, how am I supposed to code the Error terms appropriately? This is what I figured out, yet I'm not sure it's what I want: aov(y ~ B + Error(Subject/B), data = mydata2) lme(y ~ B, random = ~1 | Subject/B, data = mydata2) lmer(y ~ B + (1 | Subject/B), data = mydata2) Thanks Niccolò __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Quantile regression for binary choice and heckit
Hallo. Is there any package / code snippet to estimate quantile regression for a binary choice model (like probit) and selection model (like heckit)? I found that quantreg package can estimate tobit-like model, but I can't figure out how to tweak it for probit / heckit. Best wishes, Michal __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] estimating VAR(p) model leaving out intermediate lags
Hi, I would like to estimate a VAR(5) model, but including lags T-1, T-7, T-14, T-21 and T-28 instead of the usual T-1, T-2, T-3, T-4, T-5. But it seems I cannot accomplish this by using the below function. VAR(y, p = 1, type = c(const, trend, both, none), season = NULL, exogen = NULL, lag.max = NULL, ic = c(AIC, HQ, SC, FPE)) Does there exist a function to do this of what code could I use instead? Hope you can help me out! [[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] Problems in running x12
Dear all, I have been experiencing difficulties in running the x12 package. I'm encountering the following error message which may or may not be R-related: CMD.EXE was started with the above path as the current directory. UNC paths are not supported. Defaulting to Windows directory. I don't know how to fix it or get round to it. I'm using R 3.0.0 and Windows 7 Enterprise. Any ideas? Thanks, José Prof. José Iparraguirre Chief Economist Age UK Profesor de Economía Universidad de Morón Morón, Buenos Aires, Argentina Age UK Tavis House, 1- 6 Tavistock Square London, WC1H 9NB T 020 303 31482 E jose.iparragui...@ageuk.org.ukmailto:jose.iparragui...@ageuk.org.uk Twitter @jose.iparraguirre@ageuk Can you spare 60 seconds to help Age UK fight loneliness? Vote for Age UK today at https://globalimpactchallenge.withgoogle.com/#/ageuk to help us win £500,000 which well use to tackle isolation and loneliness by getting 16,000 older people online. --- Age UK is a registered charity and company limited by guarantee, (registered charity number 1128267, registered company number 6825798). Registered office: Tavis House, 1-6 Tavistock Square, London WC1H 9NA. For the purposes of promoting Age UK Insurance, Age UK is an Appointed Representative of Age UK Enterprises Limited, Age UK is an Introducer Appointed Representative of JLT Benefit Solutions Limited and Simplyhealth Access for the purposes of introducing potential annuity and health cash plans customers respectively. Age UK Enterprises Limited, JLT Benefit Solutions Limited and Simplyhealth Access are all authorised and regulated by the Financial Services Authority. -- This email and any files transmitted with it are confide...{{dropped:25}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Problems in running x12
Hi, It is a Windows problem. CMD.exe does not support having a UNC path as the current directory. Regards, Pascal On 05/29/2013 07:39 PM, Jose Iparraguirre wrote: Dear all, I have been experiencing difficulties in running the x12 package. I'm encountering the following error message which may or may not be R-related: CMD.EXE was started with the above path as the current directory. UNC paths are not supported. Defaulting to Windows directory. I don't know how to fix it or get round to it. I'm using R 3.0.0 and Windows 7 Enterprise. Any ideas? Thanks, José Prof. José Iparraguirre Chief Economist Age UK Profesor de Economía Universidad de Morón Morón, Buenos Aires, Argentina Age UK Tavis House, 1- 6 Tavistock Square London, WC1H 9NB T 020 303 31482 E jose.iparragui...@ageuk.org.ukmailto:jose.iparragui...@ageuk.org.uk Twitter @jose.iparraguirre@ageuk Can you spare 60 seconds to help Age UK fight loneliness? Vote for Age UK today at https://globalimpactchallenge.withgoogle.com/#/ageuk to help us win £500,000 which we’ll use to tackle isolation and loneliness by getting 16,000 older people online. --- Age UK is a registered charity and company limited by guarantee, (registered charity number 1128267, registered company number 6825798). Registered office: Tavis House, 1-6 Tavistock Square, London WC1H 9NA. For the purposes of promoting Age UK Insurance, Age UK is an Appointed Representative of Age UK Enterprises Limited, Age UK is an Introducer Appointed Representative of JLT Benefit Solutions Limited and Simplyhealth Access for the purposes of introducing potential annuity and health cash plans customers respectively. Age UK Enterprises Limited, JLT Benefit Solutions Limited and Simplyhealth Access are all authorised and regulated by the Financial Services Authority. -- This email and any files transmitted with it are confide...{{dropped:25}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Download data
On 05/29/2013 02:02 AM, jcrosbie wrote: Hi, I'm trying to download data from: http://www.ngx.com/settlehistory.html Is it possible to fetch the data with R? Hi jcrosbie, The simplest way seems to be to highlight the desired spreadsheet (less the title row), copy (Ctrl-C) and paste (Ctrl-V) it into a text editor and save it (e.g. ss1.tab). This produces a TAB delimited file that can be read into a data frame in R with: ss1-read.table(ss1.tab) 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] Download data
Hi, The combination read.table (and its arguments) + stdin also can be used, directly in R. read.table(stdin(), ...) Regards, Pascal On 29/05/2013 21:35, Jim Lemon wrote: On 05/29/2013 02:02 AM, jcrosbie wrote: Hi, I'm trying to download data from: http://www.ngx.com/settlehistory.html Is it possible to fetch the data with R? Hi jcrosbie, The simplest way seems to be to highlight the desired spreadsheet (less the title row), copy (Ctrl-C) and paste (Ctrl-V) it into a text editor and save it (e.g. ss1.tab). This produces a TAB delimited file that can be read into a data frame in R with: ss1-read.table(ss1.tab) Jim __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Download data
I tried reading in the data using the XML package, but I can't figure out how to read either ALL of the tables or a particular table. The code below just reads the first table. Maybe someone else will know how. Jean library(XML) look - readHTMLTable(http://www.ngx.com/settlehistory.html;) head(look[[1]]) V1 V2 V3 V4 V5 V6 V7 V8 V9 V10 1 Crude Firm Phys AHS, ID, WTI, Edm-Enbridge 2013-05-01 2013-05-31 0 -16. 2 Crude Firm Phys AHS, ID, WTI, Edm-Enbridge 2013-06-01 2013-06-30 0 -18.2500 3 Crude Firm Phys AHS, ID, WTI, Edm-Enbridge 2013-07-01 2013-07-31 0 -19.7500 4 Crude Firm Phys AHS, ID, WTI, Edm-Enbridge 2013-08-01 2013-08-31 0 -21.2500 5 Crude Firm Phys AHS, ID, WTI, Edm-Enbridge 2013-09-01 2013-09-30 0 -22.7500 6 Crude Firm Phys AHS, ID, WTI, Edm-Enbridge 2013-10-01 2013-10-31 0 -23. On Tue, May 28, 2013 at 11:02 AM, jcrosbie ja...@crosb.ie wrote: Hi, I'm trying to download data from: http://www.ngx.com/settlehistory.html Is it possible to fetch the data with R? Thank you -- View this message in context: http://r.789695.n4.nabble.com/Download-data-tp4668138.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] supermodular function optimization
Does anybody know whether R has a package for supermodular function optimization? Regards Arjan Ruijs [[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] adding class attributes to strings: works in a loop, but not directly
Dear all I try to assign class attributes to strings. Depending on the approach I use, it works (including method dispatch) or fails. Let me clarify with an example. Let: AONtptmodelist - c(FOOT,BICY) When I assign class attributes directly to these strings, it fails: class(BICY) - AONmode Error in class(BICY) - AONmode : target of assignment expands to non-language object However, when I assign the attributes in a loop, it does work: for(tptmode in AONtptmodelist) { + class(tptmode) - AONmode + cat(The value of is.object(tptmode) for , tptmode , is: , is.object(tptmode) , .\n) + cat(The class of , tptmode , is: , class(tptmode) , .\n) + } The value of is.object(tptmode) for FOOT is: TRUE . The class of FOOT is: AONmode . The value of is.object(tptmode) for BICY is: TRUE . The class of BICY is: AONmode . Moreover, within this loop, method dispatch works correctly. However, when I start a new loop over the same vector, I get: for(tptmode in AONtptmodelist) { + cat(The value of is.object(tptmode) for , tptmode , is: , is.object(tptmode) , .\n) + cat(The class of , tptmode , is: , class(tptmode) , .\n) + } The value of is.object(tptmode) for FOOT is: FALSE . The class of FOOT is: character . The value of is.object(tptmode) for BICY is: FALSE . The class of BICY is: character . I find this troublesome for two reasons. First, I do not understand the difference between the two approaches. Why can I assign a class attribute to a string when it is called in a loop, but not directly? And why is the class attribution not permanent? Second, the problem was concealed until now precisely because I assigned the attributes in a link. However, I would like to centralise my class definition in one single place in my code, thus outside the loop where the methods are called. Laurent Franckx, PhD VITO NV Boeretang 200, 2400 MOL, Belgium Tel. + 32 14 33 58 22 Skype: laurent.franckx laurent.fran...@vito.be Visit our website: www.vito.be/english and http://www.vito.be/transport [http://www.vito.be/e-maildisclaimer/vito.png] Ontdek hoe VITO de transitie naar een duurzame maatschappij op gang trekt: www.vito.be/duurzaamheidsverslag2012http://www.vito.be/duurzaamheidsverslag2012 VITO Disclaimer: http://www.vito.be/e-maildisclaimer __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] bootstrap
Hi, You might need to check library(boot). I have never used that before. So, I can't comment much. It is better to post on R-help list. I had seen your postings on Nabble in the past. Unfortunately those postings were not accepted in R-help. You have to directly post at r-help@r-project.org after registering at: https://stat.ethz.ch/mailman/listinfo/r-help From: Angela Fel Padecio solewolf...@yahoo.com To: arun smartpink...@yahoo.com Sent: Wednesday, May 29, 2013 9:05 AM Subject: bootstrap hi. i have these dataset: set.seed(12345) S=1000 generate - function(size) { x1 - rnorm(size, mean=0, sd=1) x2 - rnorm(size, mean=0, sd=1) x3 - rnorm(size, mean=0, sd=1) x4 - rnorm(size, mean=0, sd=1) x5 - rnorm(size, mean=0, sd=1) x6 - rnorm(size, mean=0, sd=1) x7 - rnorm(size, mean=0, sd=1) x8 - rnorm(size, mean=0, sd=1) x9 - rnorm(size, mean=0, sd=1) x10 - rnorm(size, mean=0, sd=1) e-rnorm(size, mean=0, sd=1) t_trueps - (1 + exp( -(b0 + b1*x1 + b2*x2 + b3*x3 + b4*x4 + b5*x5 + b6*x6 + b7*x7 + b2*x2*x2 + b4*x4*x4 + b7*x7*x7 + b1*0.5*x1*x3 + b2*0.7*x2*x4 +b3*0.5*x3*x5 + b4*0.7*x4*x6 + b5*0.5*x5*x7 + b1*0.5*x1*x6 + b2*0.7*x2*x3 + b3*0.5*x3*x4 + b4*0.5*x4*x5 + b5*0.5*x5*x6) ) )^-1 prob.exposure - runif(size) t - ifelse(t_trueps prob.exposure, 1, 0) y - a0 + a1*x1 + a2*x2 + a3*x3 + a4*x4 +a5*x8 + a6*x9 + a7*x10 + g1*t + e sim - as.data.frame(cbind(x1, x2, x3 ,x4, x5, x6, x7, x8, x9, x10, t, y)) return(sim) } b0 - 0.05 b1 - 0.95 b2 - -0.25 b3 - 0.6 b4 - -0.4 b5 - -0.8 b6 - -0.5 b7 - 0.7 a0 - -3.85 a1 - 0.3 a2 - -0.36 a3 - -0.73 a4 - -0.2 a5 - 0.71 a6 - -0.19 a7 - 0.26 g1 - -0.4 How can i have a bootstrap sample of 5 from size 10 with 1000 replications, i.e, data-generate(10) where entire row is chosen. for example, if i have this result: data-generate(10) data x1 x2 x3 x4 x5 x6 1 0.9374775 -2.26118020 -1.7502526 -0.04386488 0.6760577 0.5125265 2 -1.3379878 0.54495810 -1.1884175 -0.25142873 -0.7389659 -2.7850113 3 -0.5633375 -0.59191774 -1.4772120 0.74107022 -0.2862497 0.8067138 4 0.3050390 -0.40174654 0.2980965 0.19234445 1.0762513 0.1604186 5 0.6919353 -0.13762332 -0.5352159 0.69566392 1.3655018 -0.8463535 6 0.2988476 1.15431908 -0.1172911 1.38397105 0.2631057 1.7943873 7 -0.1424191 -0.06971174 -1.2759867 -1.25774074 1.2320712 1.7419884 8 1.1835778 -0.06363542 -0.4772019 -0.46848004 1.0064428 -0.6327513 9 0.1942304 -0.79500297 -1.1120049 0.60023523 0.2210129 -1.7187271 10 -2.3568380 0.34227984 -1.0006803 -0.09190608 0.1187722 -0.5756797 x7 x8 x9 x10 t y 1 0.7249311 0.2420102 2.51106406 1.6699921 0 -2.019059 2 -0.5209441 0.4935232 -0.31236000 -0.7717535 1 -2.286814 3 -1.0086591 0.6120889 -0.19684965 0.3355901 0 -2.785737 4 -0.4003396 0.9890145 -2.10427706 0.5364553 1 -2.782166 5 -0.1662400 -0.1357740 0.80220396 -0.3509522 0 -2.424431 6 2.1162941 1.4961478 0.02505993 0.8154658 1 -6.140725 7 0.9965705 1.0531386 0.53474097 -0.1415918 0 -2.922637 8 -0.1959067 -0.3507144 1.15341204 0.6018451 1 -2.602453 9 1.0153402 -0.2612589 -0.70037063 0.4304613 1 -2.788079 10 0.5378466 0.8504346 1.66384979 -1.2695204 0 -3.749164 entire entries of row 1,3,5,7,9 for instance are chosen with 1000. your help is highly appreciated. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Rank Amateur Question
You probably want from windows GUI: source(test.R) To read help to learn about this command type: ?source at the command prompt. (Similar pattern get help on other commands too - its an important R skill/habit). If your are going to do a lot of script development, I would highly recommend you take a look at RStudio, http://www.rstudio.com/ide/download/ which is a front end for R that greatly streamlines script development and use. Rob On 5/28/2013 1:07 PM, Mark Russell wrote: Greetings, I have just downloaded R onto a 64bit PC running Microsoft 7 Home Edition via Rgui. I have quite a bit of programming experience, though not as a professional programmer. I am a Measurement and Assessment professional (standardized testing). I would like to be able to write R scripts, and call them from the command line in Rgui. After two attempts, I receive the following error messages R CMD BATCH test.R Error: unexpected symbol in R CMD Rscript test.R Error: unexpected symbol in Rscript test.R These commands were taken directly from the R documents found on the R-project website. Clearly, I am doing something wrong. The script test.R resides in the R directory, and includes 24 + 6 and nothing more. The path to test.R is C:\Program Files\R\test.R Any assistance would be appreciated. Mark Russell, MEd MESA Quidquid Latine dictum sit altum videtur. [[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. -- Robert W. Baer, Ph.D. Professor of Physiology Kirksille College of Osteopathic Medicine A. T. Still University of Health Sciences Kirksville, MO 63501 USA __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Rank Amateur Question
Second the RStudio but also suggest Tinn-R for a beginner as the more extenseve code highlighting can be very useful. John Kane Kingston ON Canada -Original Message- From: rb...@atsu.edu Sent: Wed, 29 May 2013 08:17:47 -0500 To: gibsons...@cox.net Subject: Re: [R] Rank Amateur Question You probably want from windows GUI: source(test.R) To read help to learn about this command type: ?source at the command prompt. (Similar pattern get help on other commands too - its an important R skill/habit). If your are going to do a lot of script development, I would highly recommend you take a look at RStudio, http://www.rstudio.com/ide/download/ which is a front end for R that greatly streamlines script development and use. Rob On 5/28/2013 1:07 PM, Mark Russell wrote: Greetings, I have just downloaded R onto a 64bit PC running Microsoft 7 Home Edition via Rgui. I have quite a bit of programming experience, though not as a professional programmer. I am a Measurement and Assessment professional (standardized testing). I would like to be able to write R scripts, and call them from the command line in Rgui. After two attempts, I receive the following error messages R CMD BATCH test.R Error: unexpected symbol in R CMD Rscript test.R Error: unexpected symbol in Rscript test.R These commands were taken directly from the R documents found on the R-project website. Clearly, I am doing something wrong. The script test.R resides in the R directory, and includes 24 + 6 and nothing more. The path to test.R is C:\Program Files\R\test.R Any assistance would be appreciated. Mark Russell, MEd MESA Quidquid Latine dictum sit altum videtur. [[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. -- Robert W. Baer, Ph.D. Professor of Physiology Kirksille College of Osteopathic Medicine A. T. Still University of Health Sciences Kirksville, MO 63501 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. GET FREE SMILEYS FOR YOUR IM EMAIL - Learn more at http://www.inbox.com/smileys Works with AIM®, MSN® Messenger, Yahoo!® Messenger, ICQ®, Google Talk™ and most webmails __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] highlight points in lattice cloud plot
No attachment. The R-help list tendst to strip out many type of attached files though pdf and txt , among others get through. It is better to supply the example in the email itself if possible. Have a look at https://github.com/hadley/devtools/wiki/Reproducibility for suggestions. John Kane Kingston ON Canada -Original Message- From: slued...@gfz-potsdam.de Sent: Tue, 28 May 2013 15:50:33 -0700 (PDT) To: r-help@r-project.org Subject: [R] highlight points in lattice cloud plot Dear list, I am struggling with the following problem. In a 2d case I managed to highlight a subset of points through the panel.xyplot function. However, I was trying the same in 3d using panel.cloud, but now luck. I attached a minimal example, I think the first plot shows the idea. Thanks, Stefan -- View this message in context: http://r.789695.n4.nabble.com/highlight-points-in-lattice-cloud-plot-tp4668157.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. FREE ONLINE PHOTOSHARING - Share your photos online with your friends and family! Visit http://www.inbox.com/photosharing to find out more! __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] make stat.desc output an object
Inline: On Tue, May 28, 2013 at 9:22 PM, Berend Hasselman b...@xs4all.nl wrote: On 28-05-2013, at 19:31, bcrombie bcrom...@utk.edu wrote: How do I assign a variable to R output that is generated by default functions such as: stat.desc(mydata, basic=TRUE, desc=TRUE, norm=FALSE, p=0.90) summary(mydata) Another way to put it: how can I turn an R function result into an object? ?capture.output Unless I misunderstand, I don't think so. This just captures printed output as a character vector. To capture the result of a call as an object, just assign it: result - summary(mydata). However, and again if I have not misunderstood, I believe the query indicates the OP has not done his/her homework by reading a basic R tutorial, like An Introduction to R and does not understand that most R functions already return summary objects that are automatically printed by the relevant print method. -- Bert Berend __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Bert Gunter Genentech Nonclinical Biostatistics Internal Contact Info: Phone: 467-7374 Website: http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] bootstrap
library(boot) is wholly unnecessary. Hint: 1000 * 5 = 5000 ?sample -- Bert On Wed, May 29, 2013 at 6:15 AM, arun smartpink...@yahoo.com wrote: Hi, You might need to check library(boot). I have never used that before. So, I can't comment much. It is better to post on R-help list. I had seen your postings on Nabble in the past. Unfortunately those postings were not accepted in R-help. You have to directly post at r-help@r-project.org after registering at: https://stat.ethz.ch/mailman/listinfo/r-help From: Angela Fel Padecio solewolf...@yahoo.com To: arun smartpink...@yahoo.com Sent: Wednesday, May 29, 2013 9:05 AM Subject: bootstrap hi. i have these dataset: set.seed(12345) S=1000 generate - function(size) { x1 - rnorm(size, mean=0, sd=1) x2 - rnorm(size, mean=0, sd=1) x3 - rnorm(size, mean=0, sd=1) x4 - rnorm(size, mean=0, sd=1) x5 - rnorm(size, mean=0, sd=1) x6 - rnorm(size, mean=0, sd=1) x7 - rnorm(size, mean=0, sd=1) x8 - rnorm(size, mean=0, sd=1) x9 - rnorm(size, mean=0, sd=1) x10 - rnorm(size, mean=0, sd=1) e-rnorm(size, mean=0, sd=1) t_trueps - (1 + exp( -(b0 + b1*x1 + b2*x2 + b3*x3 + b4*x4 + b5*x5 + b6*x6 + b7*x7 + b2*x2*x2 + b4*x4*x4 + b7*x7*x7 + b1*0.5*x1*x3 + b2*0.7*x2*x4 +b3*0.5*x3*x5 + b4*0.7*x4*x6 + b5*0.5*x5*x7 + b1*0.5*x1*x6 + b2*0.7*x2*x3 + b3*0.5*x3*x4 + b4*0.5*x4*x5 + b5*0.5*x5*x6) ) )^-1 prob.exposure - runif(size) t - ifelse(t_trueps prob.exposure, 1, 0) y - a0 + a1*x1 + a2*x2 + a3*x3 + a4*x4 +a5*x8 + a6*x9 + a7*x10 + g1*t + e sim - as.data.frame(cbind(x1, x2, x3 ,x4, x5, x6, x7, x8, x9, x10, t, y)) return(sim) } b0 - 0.05 b1 - 0.95 b2 - -0.25 b3 - 0.6 b4 - -0.4 b5 - -0.8 b6 - -0.5 b7 - 0.7 a0 - -3.85 a1 - 0.3 a2 - -0.36 a3 - -0.73 a4 - -0.2 a5 - 0.71 a6 - -0.19 a7 - 0.26 g1 - -0.4 How can i have a bootstrap sample of 5 from size 10 with 1000 replications, i.e, data-generate(10) where entire row is chosen. for example, if i have this result: data-generate(10) data x1 x2 x3 x4 x5 x6 1 0.9374775 -2.26118020 -1.7502526 -0.04386488 0.6760577 0.5125265 2 -1.3379878 0.54495810 -1.1884175 -0.25142873 -0.7389659 -2.7850113 3 -0.5633375 -0.59191774 -1.4772120 0.74107022 -0.2862497 0.8067138 4 0.3050390 -0.40174654 0.2980965 0.19234445 1.0762513 0.1604186 5 0.6919353 -0.13762332 -0.5352159 0.69566392 1.3655018 -0.8463535 6 0.2988476 1.15431908 -0.1172911 1.38397105 0.2631057 1.7943873 7 -0.1424191 -0.06971174 -1.2759867 -1.25774074 1.2320712 1.7419884 8 1.1835778 -0.06363542 -0.4772019 -0.46848004 1.0064428 -0.6327513 9 0.1942304 -0.79500297 -1.1120049 0.60023523 0.2210129 -1.7187271 10 -2.3568380 0.34227984 -1.0006803 -0.09190608 0.1187722 -0.5756797 x7 x8x9 x10 t y 1 0.7249311 0.2420102 2.51106406 1.6699921 0 -2.019059 2 -0.5209441 0.4935232 -0.31236000 -0.7717535 1 -2.286814 3 -1.0086591 0.6120889 -0.19684965 0.3355901 0 -2.785737 4 -0.4003396 0.9890145 -2.10427706 0.5364553 1 -2.782166 5 -0.1662400 -0.1357740 0.80220396 -0.3509522 0 -2.424431 6 2.1162941 1.4961478 0.02505993 0.8154658 1 -6.140725 7 0.9965705 1.0531386 0.53474097 -0.1415918 0 -2.922637 8 -0.1959067 -0.3507144 1.15341204 0.6018451 1 -2.602453 9 1.0153402 -0.2612589 -0.70037063 0.4304613 1 -2.788079 10 0.5378466 0.8504346 1.66384979 -1.2695204 0 -3.749164 entire entries of row 1,3,5,7,9 for instance are chosen with 1000. your help is highly appreciated. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Bert Gunter Genentech Nonclinical Biostatistics Internal Contact Info: Phone: 467-7374 Website: http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] adding class attributes to strings: works in a loop, but not directly
There are two separate issues that seem to be unclear. Concerning the class assignment: You cannot assign a class to a character string. You can assign a class to an object that contains a character string: a - b # ok class(a) - AONmode # not ok class(b) - AONmode Error in class(b) - AONmode : target of assignment expands to non-language object Concerning your for-loop: for (tptmode in AONtptmodelist) creates a new object tptmode and changes this. This will in no way alter your object AONtptmodelist. If you want to have the elements of AONtptmodelist have a different class, you could for instance create a new object newAONtptmodelist as follows: newAONtptmodelist - lapply(AONtptmodelist, function(x){ class(x) - AONmode return(x) }) Best, Nello -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Franckx Laurent Sent: Mittwoch, 29. Mai 2013 13:49 To: 'r-help@r-project.org' Subject: [R] adding class attributes to strings: works in a loop, but not directly Dear all I try to assign class attributes to strings. Depending on the approach I use, it works (including method dispatch) or fails. Let me clarify with an example. Let: AONtptmodelist - c(FOOT,BICY) When I assign class attributes directly to these strings, it fails: class(BICY) - AONmode Error in class(BICY) - AONmode : target of assignment expands to non-language object However, when I assign the attributes in a loop, it does work: for(tptmode in AONtptmodelist) { + class(tptmode) - AONmode + cat(The value of is.object(tptmode) for , tptmode , is: , + is.object(tptmode) , .\n) cat(The class of , tptmode , is: , + class(tptmode) , .\n) } The value of is.object(tptmode) for FOOT is: TRUE . The class of FOOT is: AONmode . The value of is.object(tptmode) for BICY is: TRUE . The class of BICY is: AONmode . Moreover, within this loop, method dispatch works correctly. However, when I start a new loop over the same vector, I get: for(tptmode in AONtptmodelist) { + cat(The value of is.object(tptmode) for , tptmode , is: , + is.object(tptmode) , .\n) cat(The class of , tptmode , is: , + class(tptmode) , .\n) } The value of is.object(tptmode) for FOOT is: FALSE . The class of FOOT is: character . The value of is.object(tptmode) for BICY is: FALSE . The class of BICY is: character . I find this troublesome for two reasons. First, I do not understand the difference between the two approaches. Why can I assign a class attribute to a string when it is called in a loop, but not directly? And why is the class attribution not permanent? Second, the problem was concealed until now precisely because I assigned the attributes in a link. However, I would like to centralise my class definition in one single place in my code, thus outside the loop where the methods are called. Laurent Franckx, PhD VITO NV Boeretang 200, 2400 MOL, Belgium Tel. + 32 14 33 58 22 Skype: laurent.franckx laurent.fran...@vito.be Visit our website: www.vito.be/english and http://www.vito.be/transport [http://www.vito.be/e-maildisclaimer/vito.png] Ontdek hoe VITO de transitie naar een duurzame maatschappij op gang trekt: www.vito.be/duurzaamheidsverslag2012http://www.vito.be/duurzaamheidsver slag2012 VITO Disclaimer: http://www.vito.be/e-maildisclaimer __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] p values of plor
AIC is a different story. To do hypothesis tests on terms, use anova() or dropterm() (as done in the book): library(MASS) example(polr) dropterm(house.plr, test = Chisq) Single term deletions Model: Sat ~ Infl + Type + Cont DfAIC LRT Pr(Chi) none3495.1 Infl2 3599.4 108.239 2.2e-16 Type3 3545.1 55.910 4.391e-12 Cont1 3507.5 14.306 0.0001554 That is an object of class anova, so can be saved and subsetted. On 28/05/2013 22:30, David Winsemius wrote: On May 27, 2013, at 11:05 PM, Prof Brian Ripley wrote: On 28/05/2013 06:54, David Winsemius wrote: On May 27, 2013, at 7:59 PM, meng wrote: Hi all: As to the polr {MASS} function, how to find out p values of every parameter? From the example of R help: house.plr - polr(Sat ~ Infl + Type + Cont, weights = Freq, data = housing) summary(house.plr) How to find out the p values of house.plr? Getting p-values from t-statistics should be fairly straight-forward: summary(house.plr)$coefficients And what distribution are you going to use to compute the p-values? I should have responded with my first impulse: If the authors didn't provide p-values, then perhaps they don't think they are credible. Hint: there is no exact distribution theory for POLR fits and the asymptotic theory can be far enough off to be seriously misleading (just as for the two-class case, logistic regression: see MASS the book). That is why likelihood-ratio tests are recommended in MASS, not Wald tests. And so the more correct answer would be to use stepAIC? I would have thought sequential removal of terms with comparisons of deviance estimates might be informative. This is what I get with that data: house.AIC.1 - stepAIC(house.plr, list(upper=~., lower=~1) ) Start: AIC=3495.15 Sat ~ Infl + Type + Cont DfAIC none3495.1 - Cont 1 3507.5 - Type 3 3545.1 - Infl 2 3599.4 So something along those lines seems to be happening, but I am not able to extract those values programmatically, nor am I able to see how they even get displayed. class(house.AIC.1) [1] polr str(house.AIC.1$anova) Classes ‘Anova’ and 'data.frame': 1 obs. of 6 variables: $ Step : Factor w/ 1 level : 1 $ Df: num NA $ Deviance : num NA $ Resid. Df : num 1673 $ Resid. Dev: num 3479 $ AIC : num 3495 Which lead me to look at: getAnywhere(print.polr) But that was uninformative to my level of reading R code. The AIC trials seem to get printed by stepAIC() but are not saved in the returned object. --- David Winsemius Alameda, CA, USA -- Brian D. Ripley, rip...@stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] rgl crashes after one successful draw
This is really odd, and probably 100% local to me, but I'm at a loss as to a next step. After narrowing things down, here's how to reproduce: library(rgl) showSomething - function() { open3d() points3d(rnorm(10),rnorm(10),rnorm(10)) axes3d() title3d('main','sub','xlab','ylab','zlab') } showSomething() # works as expected. # Close the current rgl window showSomething() # crashes R with the following report: *** caught segfault *** address 0x0, cause 'unknown' Traceback: 1: .C(rgl_dev_open, success = FALSE) 2: rgl.open() 3: open3d() 4: showSomething() This will probably work fine for any of you, it's so simple and fundamental. If I don't close the open rgl windows, it doesn't crash, and I can execute the function over and over successfully. And the same thing happens if I just do the commands inside the function individually. SessionInfo() below. Perhaps something is corrupt with my X11 window system? Thanks, Bryan R version 3.0.1 (2013-05-16) Platform: x86_64-apple-darwin10.8.0 (64-bit) locale: [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] rgl_0.93.940 sos_1.3-5brew_1.0-6 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Quantile regression for binary choice and heckit
This is a bit like asking how should I tweak my sailboat so I can explore the ocean floor. url:www.econ.uiuc.edu/~rogerRoger Koenker emailrkoen...@uiuc.eduDepartment of Economics vox: 217-333-4558University of Illinois fax: 217-244-6678Urbana, IL 61801 On May 29, 2013, at 1:32 AM, Michal Kvasnička wrote: Hallo. Is there any package / code snippet to estimate quantile regression for a binary choice model (like probit) and selection model (like heckit)? I found that quantreg package can estimate tobit-like model, but I can't figure out how to tweak it for probit / heckit. Best wishes, Michal __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] adding class attributes to strings: works in a loop, but not directly
a) You cannot assign attributes to literal values such as BICY. You must assign them to variables, as in x - BICY class(x) - AONmode b) You cannot give the separate elements of a vector their own separate attributes unless the vector is of mode list. Ordinarily, attributes apply to the whole vector. (When the vector is of mode list then each element may be a vector on its own with its own attributes.) y - c(FOOT,BICY) class(y) - AONmode z - vector( list, 2 ) z[[1]] - FOOT class( z[[1]] ) - AONmode z[[2]] - BICY class( z[[2]] ) - AONmode --- Jeff NewmillerThe . . Go Live... DCN:jdnew...@dcn.davis.ca.usBasics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/BatteriesO.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --- Sent from my phone. Please excuse my brevity. Franckx Laurent laurent.fran...@vito.be wrote: Dear all I try to assign class attributes to strings. Depending on the approach I use, it works (including method dispatch) or fails. Let me clarify with an example. Let: AONtptmodelist - c(FOOT,BICY) When I assign class attributes directly to these strings, it fails: class(BICY) - AONmode Error in class(BICY) - AONmode : target of assignment expands to non-language object However, when I assign the attributes in a loop, it does work: for(tptmode in AONtptmodelist) { + class(tptmode) - AONmode + cat(The value of is.object(tptmode) for , tptmode , is: , is.object(tptmode) , .\n) + cat(The class of , tptmode , is: , class(tptmode) , .\n) + } The value of is.object(tptmode) for FOOT is: TRUE . The class of FOOT is: AONmode . The value of is.object(tptmode) for BICY is: TRUE . The class of BICY is: AONmode . Moreover, within this loop, method dispatch works correctly. However, when I start a new loop over the same vector, I get: for(tptmode in AONtptmodelist) { + cat(The value of is.object(tptmode) for , tptmode , is: , is.object(tptmode) , .\n) + cat(The class of , tptmode , is: , class(tptmode) , .\n) + } The value of is.object(tptmode) for FOOT is: FALSE . The class of FOOT is: character . The value of is.object(tptmode) for BICY is: FALSE . The class of BICY is: character . I find this troublesome for two reasons. First, I do not understand the difference between the two approaches. Why can I assign a class attribute to a string when it is called in a loop, but not directly? And why is the class attribution not permanent? Second, the problem was concealed until now precisely because I assigned the attributes in a link. However, I would like to centralise my class definition in one single place in my code, thus outside the loop where the methods are called. Laurent Franckx, PhD VITO NV Boeretang 200, 2400 MOL, Belgium Tel. + 32 14 33 58 22 Skype: laurent.franckx laurent.fran...@vito.be Visit our website: www.vito.be/english and http://www.vito.be/transport [http://www.vito.be/e-maildisclaimer/vito.png] Ontdek hoe VITO de transitie naar een duurzame maatschappij op gang trekt: www.vito.be/duurzaamheidsverslag2012http://www.vito.be/duurzaamheidsverslag2012 VITO Disclaimer: http://www.vito.be/e-maildisclaimer __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] RCurl and google trends
Dear R users. We are currently developing a R package (GTrendsR) that allows to retrieve data from google trends. To do so, Im using the RCurl library. At this point everything works perfectly (i.e. the data obtained from R is identical to the data obtained directly from the web site). However, after 5-10 queries I get a quota excess limit message. If I log manually on google trend web site, it still works (i.e. no quota problems). So, that let me think it must be something related to the way I connect to google with R. More specifically, I suspect it something about how I define the connection with curlSetOpt in relation with cookies. I know it might not be obvious, but if someone has an idea :) Heres my code. gConnect = function(usr, psw) { loginURL - https://accounts.google.com/accounts/ServiceLogin; authenticateURL - https://accounts.google.com/accounts/ServiceLoginAuth; ch - getCurlHandle() curlSetOpt(curl = ch, ssl.verifypeer = FALSE, useragent = Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13, followlocation = TRUE, cookiejar = ./cookies, cookiefile = ./cookies) ## Google Account login loginPage - getURL(loginURL, curl = ch) galx.match - str_extract(string = loginPage, pattern = ignore.case('name=GALX\\s*value=([^]+)')) galx - str_replace(string = galx.match, pattern = ignore.case('name=GALX\\s*value=([^]+)'), replacement = \\1) authenticatePage - postForm(authenticateURL, .params = list(Email = usr, Passwd = psw, GALX = galx), curl = ch, .opts = list(verbose = F)) return(ch) } With regards, Phil -- Philippe Massicotte, Ph. D. Stagiaire postdoctoral Postdoctoral Research Fellow Université du Québec à Trois-Rivières (UQTR) Département de Chimie-Biologie Centre de Recherche sur les Interactions Bassins Versants- Écosystèmes aquatiques (RIVE) Pavillon Léon-Provancher Local 3413 3351, boul. des Forges CP 500 Trois-Rivières (QC) G9A 5H7 CANADA Tel: (819) 376-5011 #3402 Fax: (819) 376-5084 Courriel: philippe.massico...@uqtr.ca Web site : http://anotherrblog.blogspot.ca/ http://anotherrblog.blogspot.ca/ [[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] Trouble in parallel computing with snow package
Dear all, I want to make a baysian optimisation of the parameters values of a model, written in FORTRAN. I thus need a parallel modeling procedure. I started to use the R package snow but I went through trouble and I hope that you will bring me light on this problem. Briefly, I first make a function called run which will execute the .exe of my FORTRAN code (the argument *plac*, is the ID of the plot, I want the code to run 20 plots simultaneously). * **run-function(plac) {** ** setwd(paste('L:/Joannes/CASTANEA/Casta_opti2/CASTANEA_OPTI',plac,'/projet_fortran_intel_castanea/', sep=) )** ** system('Release/projet_fortran_intel_castanea.exe')** **}** * I then use the following code to run the FORTRAN code over 20 plots in the same time. My computer has 16 processors. *cl20 - makeCluster(20, type=SOCK)** ** clusterApplyLB(cl20,1:20, run)** **stopCluster(cl20)** * But I finally realized that this code did not run all the 20 plots but only part of them. The code return a 0 for the plots which has been simulated and a 127 if nothing is done. If I run my R code several time, the number of simulated plots is different (but20) and the plots which are simulated are not always the same. I need all the 20 plots to be run simulaneously and I cannot find out what is the problem with my code. Any idea about how to solve my problem? Thank you very much, Joannès Guillemot joannes.guille...@u-psud.fr [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] highlight points in lattice cloud plot
Sorry forthat and thanks for the hint. At marked the appended text as rawtext, maybe that is the reason why it was cut. Here we go again. ## x=runif(100, 1, 2) y=runif(100, 2, 4) z=runif(100, 1, 4) ### 2d example data_xy=as.data.frame(cbind(x, y, a=rep(c(1:10), 10), b=rep(c(1:2), each=50))) custom.panel = function(x, y, subscripts, ...) { highlight=(data_xy$a == 1) highlight.panel = highlight[subscripts] panel.xyplot(x[highlight.panel], y[!highlight.panel], type='p', pch=18) panel.xyplot(x[highlight.panel], y[highlight.panel], type='b', col=tomato3) } xyplot(x~y|b, data=data_xy, groups=a, panel=custom.panel) ### 3d example data_xyz=as.data.frame(cbind(x, y, z, a=rep(c(1:10), 10), b=rep(c(1:2), each=50))) custom.panel = function(x, y, z, subscripts, ...) { highlight=(data_xyz$a == 1) highlight.panel = highlight[subscripts] panel.cloud(x[highlight.panel], y[!highlight.panel], z[!highlight.panel], type='p', pch=18) panel.cloud(x[highlight.panel], y[highlight.panel], z[highlight.panel], type='b', col=tomato3) } #that works of course cloud(z~x*y|b, data=data_xyz) #that not cloud(z~x*y|b, data=data_xyz, groups=TRUE, panel=custom.panel) ## On 05/29/2013 03:36 PM, John Kane wrote: No attachment. The R-help list tendst to strip out many type of attached files though pdf and txt , among others get through. It is better to supply the example in the email itself if possible. Have a look at https://github.com/hadley/devtools/wiki/Reproducibility for suggestions. John Kane Kingston ON Canada -Original Message- From: slued...@gfz-potsdam.de Sent: Tue, 28 May 2013 15:50:33 -0700 (PDT) To: r-help@r-project.org Subject: [R] highlight points in lattice cloud plot Dear list, I am struggling with the following problem. In a 2d case I managed to highlight a subset of points through the panel.xyplot function. However, I was trying the same in 3d using panel.cloud, but now luck. I attached a minimal example, I think the first plot shows the idea. Thanks, Stefan -- View this message in context: http://r.789695.n4.nabble.com/highlight-points-in-lattice-cloud-plot-tp4668157.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. FREE ONLINE PHOTOSHARING - Share your photos online with your friends and family! Visit http://www.inbox.com/photosharing to find out 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] Download data
Thank you, I will have to wait until I get home form work to test the XML. But I'm looking to do something more along the lines of an automated process over copy and pasting. James From: Adams, Jean jvad...@usgs.gov To: jcrosbie ja...@crosb.ie Cc: R help r-help@r-project.org Sent: Wednesday, May 29, 2013 6:50 AM Subject: Re: [R] Download data I tried reading in the data using the XML package, but I can't figure out how to read either ALL of the tables or a particular table. The code below just reads the first table. Maybe someone else will know how. Jean library(XML) look - readHTMLTable(http://www.ngx.com/settlehistory.html;) head(look[[1]]) V1 V2 V3 V4 V5 V6 V7 V8 V9 V10 1 Crude Firm Phys AHS, ID, WTI, Edm-Enbridge 2013-05-01 2013-05-31 0 -16. 2 Crude Firm Phys AHS, ID, WTI, Edm-Enbridge 2013-06-01 2013-06-30 0 -18.2500 3 Crude Firm Phys AHS, ID, WTI, Edm-Enbridge 2013-07-01 2013-07-31 0 -19.7500 4 Crude Firm Phys AHS, ID, WTI, Edm-Enbridge 2013-08-01 2013-08-31 0 -21.2500 5 Crude Firm Phys AHS, ID, WTI, Edm-Enbridge 2013-09-01 2013-09-30 0 -22.7500 6 Crude Firm Phys AHS, ID, WTI, Edm-Enbridge 2013-10-01 2013-10-31 0 -23. On Tue, May 28, 2013 at 11:02 AM, jcrosbie ja...@crosb.ie wrote: Hi, I'm trying to download data from: http://www.ngx.com/settlehistory.html Is it possible to fetch the data with R? Thank you -- View this message in context: http://r.789695.n4.nabble.com/Download-data-tp4668138.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] bootstrap
Hi, Don't know if this helps: set.seed(244) data1- generate(10) data1 x1 x2 x3 x4 x5 x6 1 -0.89558948 -0.5609722069 -1.0782688 -1.2461548 -0.58857050 1.5708187 2 -0.82379187 -0.9056306209 -1.5700755 -0.6045090 -0.19683863 -0.8969354 3 -1.04303377 -0.2379109244 -0.6589381 -0.7521561 1.37492952 -2.7515409 4 0.00783492 0.4249100106 -0.8221292 -0.6220925 0.91199682 0.6365096 5 0.72986110 0.5355575043 1.7584239 1.4474157 -0.46647958 -0.3799255 6 -1.83691611 1.4025663889 -1.0857996 1.3311993 -2.32091759 0.5866616 7 0.10720511 0.6393573943 -0.2811223 2.2800918 0.09360948 0.9441684 8 -0.36297232 0.6974249024 0.9024777 2.0952564 0.22731336 0.7809357 9 -1.28146538 0.0002775273 1.5413933 -3.2237494 -1.31165562 0.6511996 10 -0.65215069 1.8909461951 -0.7355757 0.3532028 0.05926608 1.6003263 x7 x8 x9 x10 t y 1 -1.24153055 0.1660665 -0.1791897 0.9132159 0 -1.437598 2 0.76953162 0.6579521 -0.2985585 -0.4716139 0 -2.474706 3 -0.70071814 1.4526669 0.4641041 -1.7046221 1 -0.182020 4 0.70752895 -0.1725368 0.8811518 -0.8023556 0 -3.658734 5 -0.02086093 2.1676000 1.8696969 0.4655824 0 -5.059184 6 -0.39706026 1.4280016 0.6295243 -2.2591846 1 -3.229792 7 -0.47859335 1.9391822 1.1545306 -0.3825239 0 -3.989109 8 -0.96075661 2.4411561 -1.9833116 -0.2589653 0 -1.998027 9 -2.82823504 0.1234223 1.1404231 1.3262285 0 -5.323757 10 0.37175204 -1.4488875 -0.2680561 -2.2540178 0 -5.818188 res1-as.data.frame(t(sample(as.data.frame(t(data1)),20,replace=TRUE))) row.names(res1)-1:nrow(res1) head(res1,2) # x1 x2 x3 x4 x5 x6 x7 #1 0.00783492 0.424910 -0.8221292 -0.6220925 0.91199682 0.6365096 0.707529 #2 -0.65215069 1.890946 -0.7355757 0.3532028 0.05926608 1.6003263 0.371752 # x8 x9 x10 t y #1 -0.1725368 0.8811518 -0.8023556 0 -3.658734 #2 -1.4488875 -0.2680561 -2.2540178 0 -5.818188 A.K. From: Angela Fel Padecio solewolf...@yahoo.com To: arun smartpink...@yahoo.com Sent: Wednesday, May 29, 2013 10:33 AM Subject: Re: bootstrap hi. thanks for the reply. generally, the command for bootstrapping in R is sample(x, size, replace=T) however, i want my x to be the vectors x1 to x10, t and y. i can't do it because i this is what i get: for instance, simdata-sample(data, 20, replace=T) simdata x6 x7 x8 x10 x9 x8.1 1 -1.53816891 1.2408110 0.06074567 0.98045523 1.86121959 0.06074567 2 1.33138543 -1.7287688 0.21719209 -0.03431542 0.69361696 0.21719209 3 0.50121104 -2.1667913 0.29435635 2.75808453 -0.07115435 0.29435635 4 -0.87952116 0.8968212 -1.10899986 0.02983622 0.57830958 -1.10899986 5 -0.03325816 -0.2172203 -1.23341708 -0.71446145 0.91041824 -1.23341708 x2 x3 t x3.1 x1 x1.1 t.1 x7.1 1 1.97154 0.7930340 1 0.7930340 1.4209575 1.4209575 1 1.2408110 2 -0.513132396 2.3926484 0 2.3926484 -0.7346689 -0.7346689 0 -1.7287688 3 0.408742759 1.2250794 0 1.2250794 -1.0200933 -1.0200933 0 -2.1667913 4 -0.048902349 1.2637351 1 1.2637351 -2.3791083 -2.3791083 1 0.8968212 5 0.008808758 0.2171343 1 0.2171343 1.8278435 1.8278435 1 -0.2172203 x10.1 x5 x5.1 x2.1 x10.2 x3.2 1 0.98045523 0.8283620 0.8283620 1.97154 0.98045523 0.7930340 2 -0.03431542 -0.3461855 -0.3461855 -0.513132396 -0.03431542 2.3926484 3 2.75808453 -0.4661471 -0.4661471 0.408742759 2.75808453 1.2250794 4 0.02983622 0.4343037 0.4343037 -0.048902349 0.02983622 1.2637351 5 -0.71446145 0.9696091 0.9696091 0.008808758 -0.71446145 0.2171343 From: arun smartpink...@yahoo.com To: Angela Fel Padecio solewolf...@yahoo.com Cc: R help r-help@r-project.org Sent: Wednesday, May 29, 2013 9:15 PM Subject: Re: bootstrap Hi, You might need to check library(boot). I have never used that before. So, I can't comment much. It is better to post on R-help list. I had seen your postings on Nabble in the past. Unfortunately those postings were not accepted in R-help. You have to directly post at r-help@r-project.org after registering at: https://stat.ethz.ch/mailman/listinfo/r-help From: Angela Fel Padecio solewolf...@yahoo.com To: arun smartpink...@yahoo.com Sent: Wednesday, May 29, 2013 9:05 AM Subject: bootstrap hi. i have these dataset: set.seed(12345) S=1000 generate - function(size) { x1 - rnorm(size, mean=0, sd=1) x2 - rnorm(size, mean=0, sd=1) x3 - rnorm(size, mean=0, sd=1) x4 - rnorm(size, mean=0, sd=1) x5 - rnorm(size, mean=0, sd=1) x6 - rnorm(size, mean=0, sd=1) x7 - rnorm(size, mean=0, sd=1)
Re: [R] rgl crashes after one successful draw
This is most relevant to R-sig-mac. There are two different rgl devices on OS X, depending how you are running this. One based on X11 and one on Apple's GL. In particular, are you using command-line R or R.app? I seem to be able to reproduce it using R.app, in which case it is most definitely for R-sig-mac, and a workaround is to use command-line R. On 29/05/2013 15:11, Bryan Hanson wrote: This is really odd, and probably 100% local to me, but I'm at a loss as to a next step. After narrowing things down, here's how to reproduce: library(rgl) showSomething - function() { open3d() points3d(rnorm(10),rnorm(10),rnorm(10)) axes3d() title3d('main','sub','xlab','ylab','zlab') } showSomething() # works as expected. # Close the current rgl window showSomething() # crashes R with the following report: *** caught segfault *** address 0x0, cause 'unknown' Traceback: 1: .C(rgl_dev_open, success = FALSE) 2: rgl.open() 3: open3d() 4: showSomething() This will probably work fine for any of you, it's so simple and fundamental. If I don't close the open rgl windows, it doesn't crash, and I can execute the function over and over successfully. And the same thing happens if I just do the commands inside the function individually. SessionInfo() below. Perhaps something is corrupt with my X11 window system? Thanks, Bryan R version 3.0.1 (2013-05-16) Platform: x86_64-apple-darwin10.8.0 (64-bit) locale: [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] rgl_0.93.940 sos_1.3-5brew_1.0-6 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Brian D. Ripley, rip...@stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] rgl crashes after one successful draw
Thank you Brian. Yes, problem is on R.app I will send to R-sig-mac. Thanks, Bryan On May 29, 2013, at 11:07 AM, Prof Brian Ripley rip...@stats.ox.ac.uk wrote: This is most relevant to R-sig-mac. There are two different rgl devices on OS X, depending how you are running this. One based on X11 and one on Apple's GL. In particular, are you using command-line R or R.app? I seem to be able to reproduce it using R.app, in which case it is most definitely for R-sig-mac, and a workaround is to use command-line R. On 29/05/2013 15:11, Bryan Hanson wrote: This is really odd, and probably 100% local to me, but I'm at a loss as to a next step. After narrowing things down, here's how to reproduce: library(rgl) showSomething - function() { open3d() points3d(rnorm(10),rnorm(10),rnorm(10)) axes3d() title3d('main','sub','xlab','ylab','zlab') } showSomething() # works as expected. # Close the current rgl window showSomething() # crashes R with the following report: *** caught segfault *** address 0x0, cause 'unknown' Traceback: 1: .C(rgl_dev_open, success = FALSE) 2: rgl.open() 3: open3d() 4: showSomething() This will probably work fine for any of you, it's so simple and fundamental. If I don't close the open rgl windows, it doesn't crash, and I can execute the function over and over successfully. And the same thing happens if I just do the commands inside the function individually. SessionInfo() below. Perhaps something is corrupt with my X11 window system? Thanks, Bryan R version 3.0.1 (2013-05-16) Platform: x86_64-apple-darwin10.8.0 (64-bit) locale: [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] rgl_0.93.940 sos_1.3-5brew_1.0-6 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Brian D. Ripley, rip...@stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Equivalence between lm and glm
Dear R-users, in case of linear model, lm(Y ~ X) is equivalent to glm(Y ~ X, family=gaussian(link=identity)) In case of the exponential model lm(log(Y) ~ X) why glm(Y ~ X, family=gaussian(link=log)) is not equivalent? Is there an equivalent glm to lm(log(Y) ~ X)? Thank you for your help Stefano Sofia AVVISO IMPORTANTE: Questo messaggio di posta elettronica può contenere informazioni confidenziali, pertanto è destinato solo a persone autorizzate alla ricezione. I messaggi di posta elettronica per i client di Regione Marche possono contenere informazioni confidenziali e con privilegi legali. Se non si è il destinatario specificato, non leggere, copiare, inoltrare o archiviare questo messaggio. Se si è ricevuto questo messaggio per errore, inoltrarlo al mittente ed eliminarlo completamente dal sistema del proprio computer. Ai sensi dell'art. 6 della DGR n. 1394/2008 si segnala che, in caso di necessità ed urgenza, la risposta al presente messaggio di posta elettronica può essere visionata da persone estranee al destinatario. IMPORTANT NOTICE: This e-mail message is intended to be received only by persons entitled to receive the confidential information it may contain. E-mail messages to clients of Regione Marche may contain information that is confidential and legally privileged. Please do not read, copy, forward, or store this message unless you are an intended recipient of it. If you have received this message in error, please forward it to the sender and delete it completely from your computer system. [[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] adding class attributes to strings: works in a loop, but not directly
Dear Nello Thanks for the clarification. It was of course an elementary mistake to assume that the for loop would modify the original AONtptmodelist. I also understand now that the issues was that I cannot attribute a class to a literal. Your proposed alternative seems to work now, including the method dispatch. Regards Laurent -Original Message- From: Blaser Nello [mailto:nbla...@ispm.unibe.ch] Sent: woensdag 29 mei 2013 15:56 To: Franckx Laurent; r-help@r-project.org Subject: RE: [R] adding class attributes to strings: works in a loop, but not directly There are two separate issues that seem to be unclear. Concerning the class assignment: You cannot assign a class to a character string. You can assign a class to an object that contains a character string: a - b # ok class(a) - AONmode # not ok class(b) - AONmode Error in class(b) - AONmode : target of assignment expands to non-language object Concerning your for-loop: for (tptmode in AONtptmodelist) creates a new object tptmode and changes this. This will in no way alter your object AONtptmodelist. If you want to have the elements of AONtptmodelist have a different class, you could for instance create a new object newAONtptmodelist as follows: newAONtptmodelist - lapply(AONtptmodelist, function(x){ class(x) - AONmode return(x) }) Best, Nello -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Franckx Laurent Sent: Mittwoch, 29. Mai 2013 13:49 To: 'r-help@r-project.org' Subject: [R] adding class attributes to strings: works in a loop, but not directly Dear all I try to assign class attributes to strings. Depending on the approach I use, it works (including method dispatch) or fails. Let me clarify with an example. Let: AONtptmodelist - c(FOOT,BICY) When I assign class attributes directly to these strings, it fails: class(BICY) - AONmode Error in class(BICY) - AONmode : target of assignment expands to non-language object However, when I assign the attributes in a loop, it does work: for(tptmode in AONtptmodelist) { + class(tptmode) - AONmode + cat(The value of is.object(tptmode) for , tptmode , is: , + is.object(tptmode) , .\n) cat(The class of , tptmode , is: , + class(tptmode) , .\n) } The value of is.object(tptmode) for FOOT is: TRUE . The class of FOOT is: AONmode . The value of is.object(tptmode) for BICY is: TRUE . The class of BICY is: AONmode . Moreover, within this loop, method dispatch works correctly. However, when I start a new loop over the same vector, I get: for(tptmode in AONtptmodelist) { + cat(The value of is.object(tptmode) for , tptmode , is: , + is.object(tptmode) , .\n) cat(The class of , tptmode , is: , + class(tptmode) , .\n) } The value of is.object(tptmode) for FOOT is: FALSE . The class of FOOT is: character . The value of is.object(tptmode) for BICY is: FALSE . The class of BICY is: character . I find this troublesome for two reasons. First, I do not understand the difference between the two approaches. Why can I assign a class attribute to a string when it is called in a loop, but not directly? And why is the class attribution not permanent? Second, the problem was concealed until now precisely because I assigned the attributes in a link. However, I would like to centralise my class definition in one single place in my code, thus outside the loop where the methods are called. Laurent Franckx, PhD VITO NV Boeretang 200, 2400 MOL, Belgium Tel. + 32 14 33 58 22 Skype: laurent.franckx laurent.fran...@vito.be Visit our website: www.vito.be/english and http://www.vito.be/transport [http://www.vito.be/e-maildisclaimer/vito.png] Ontdek hoe VITO de transitie naar een duurzame maatschappij op gang trekt: www.vito.be/duurzaamheidsverslag2012http://www.vito.be/duurzaamheidsver slag2012 VITO Disclaimer: http://www.vito.be/e-maildisclaimer __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [http://www.vito.be/e-maildisclaimer/vito.png] Ontdek hoe VITO de transitie naar een duurzame maatschappij op gang trekt: www.vito.be/duurzaamheidsverslag2012http://www.vito.be/duurzaamheidsverslag2012 VITO Disclaimer: http://www.vito.be/e-maildisclaimer __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Modelling categorical and non-categorical datasets using Artifical Neural Networks
Hi, I have to do some Radon modelling and I have categorical and non categorical datasets. I have been considering Artificial Neural Networks to do this. I was wondering has anybody done anything like this before and have you any advice before I start and where there might be some good tutorials on this type of modelling. Thanks -- Shane [[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] Modelling categorical and non-categorical datasets using Artifical Neural Networks
On Wed, 29 May 2013, Shane Carey wrote: I have to do some Radon modelling and I have categorical and non categorical datasets. I have been considering Artificial Neural Networks to do this. I was wondering has anybody done anything like this before and have you any advice before I start and where there might be some good tutorials on this type of modelling. Shane, What questions do you want to answer? Rich -- Richard B. Shepard, Ph.D. | Have knowledge, will travel. Applied Ecosystem Services, Inc. | http://www.appl-ecosys.com Voice: 503-667-4517 Fax: 503-667-8863 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] highlight points in lattice cloud plot
On Wed, May 29, 2013 at 7:57 AM, Stefan Lüdtke slued...@gfz-potsdam.dewrote: x=runif(100, 1, 2) y=runif(100, 2, 4) z=runif(100, 1, 4) data_xyz=as.data.frame(cbind(x, y, z, a=rep(c(1:10), 10), b=rep(c(1:2), each=50))) custom.panel = function(x, y, z, subscripts, ...) { highlight=(data_xyz$a == 1) highlight.panel = highlight[subscripts] panel.cloud(x[highlight.panel], y[!highlight.panel], z[!highlight.panel], type='p', pch=18) panel.cloud(x[highlight.panel], y[highlight.panel], z[highlight.panel], type='b', col=tomato3) } If you args(panel.cloud) or ?panel.cloud you'll notice the order is x , y , subscripts , z ,... *not* x,y,z, hence the error message z not found or something to that effect you should have been getting. In any case you're code is IMHO a little clunky with groups=TRUE and a panel function just to get the groups condition. Would something like this do the job? cloud(z~x*y|b, groups=factor(a==1), data=data_xyz, pch=c(1,19), type='b', par.settings=list(superpose.line=list(col=c(0,#ff00ff #that works of course cloud(z~x*y|b, data=data_xyz) #that not cloud(z~x*y|b, data=data_xyz, groups=TRUE, panel=custom.panel) ## On 05/29/2013 03:36 PM, John Kane wrote: No attachment. The R-help list tendst to strip out many type of attached files though pdf and txt , among others get through. It is better to supply the example in the email itself if possible. Have a look at https://github.com/hadley/devtools/wiki/Reproducibility for suggestions. John Kane Kingston ON Canada -Original Message- From: slued...@gfz-potsdam.de Sent: Tue, 28 May 2013 15:50:33 -0700 (PDT) To: r-help@r-project.org Subject: [R] highlight points in lattice cloud plot Dear list, I am struggling with the following problem. In a 2d case I managed to highlight a subset of points through the panel.xyplot function. However, I was trying the same in 3d using panel.cloud, but now luck. I attached a minimal example, I think the first plot shows the idea. Thanks, Stefan -- View this message in context: http://r.789695.n4.nabble.com/highlight-points-in-lattice-cloud-plot-tp4668157.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. FREE ONLINE PHOTOSHARING - Share your photos online with your friends and family! Visit http://www.inbox.com/photosharing to find out 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] RCurl: using ls instead of NLST
R-helpers: I'm trying to retrieve the contents of a directory from an ftp site (ideally, the file/folder names as a character vector): ftp://e4ftl01.cr.usgs.gov/MOTA/MCD12C1.005/; # (MODIS data) Where I get the following error via RCurl: require(RCurl) url - ftp://e4ftl01.cr.usgs.gov/MOTA/MCD12C1.005/; filenames = getURL(url,ftp.use.epsv=FALSE,ftplistonly=TRUE) Error in function (type, msg, asError = TRUE) : RETR response: 550 Through some sleuthing, it turns out the ftp site does not support NLST (which RCurl is using), but will use ls to list the directory contents -- is there any way to use ls remotely on this site? Thanks! --j -- Jonathan A. Greenberg, PhD Assistant Professor Global Environmental Analysis and Remote Sensing (GEARS) Laboratory Department of Geography and Geographic Information Science University of Illinois at Urbana-Champaign 607 South Mathews Avenue, MC 150 Urbana, IL 61801 Phone: 217-300-1924 http://www.geog.illinois.edu/~jgrn/ AIM: jgrn307, MSN: jgrn...@hotmail.com, Gchat: jgrn307, Skype: jgrn3007 [[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] Equivalence between lm and glm
On May 29, 2013, at 17:23 , Stefano Sofia wrote: Dear R-users, in case of linear model, lm(Y ~ X) is equivalent to glm(Y ~ X, family=gaussian(link=identity)) In case of the exponential model lm(log(Y) ~ X) why glm(Y ~ X, family=gaussian(link=log)) is not equivalent? Y is assumed lognormal in one case, normal in the other. Is there an equivalent glm to lm(log(Y) ~ X)? Yes, glm(log(Y) ~ X, family=gaussian(link=identity)) -- Peter Dalgaard, Professor, Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Email: pd@cbs.dk Priv: pda...@gmail.com __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] More discussion on R usage statistics
Dear R users, There has been discussion on how to collect R usage statistics before and the discussion has led to some good results such as http://neolab.stat.ucla.edu/cranstats/ and http://crantastic.org/. Recently, I tried to put together a package that allows R users to rate, comment, and ask questions on R packages within R. A working version is now available on both github and r-forge. Note that the email feature may not work out as expected because gmail, used by the package, only allows 500 messages sent per day. To install it from R forge, please use install.packages('rstats', repos=http://r-forge.r-project.org;) Using github (require the package devtools), install_github('rstats','johnnyzhz') A brief manual of it can be seen at: http://rstats.psychstat.org/rstats.pdf I'd appreciate it that if you can test this and provide feedback on how to collect and utilize R usage statistics. Best, Zhiyong Zhang [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Problems with merge
data1$A[8] #[1] 1.4 data2$A[15] #[1] 1.4 data2$A[15]==data1$A[8] #[1] FALSE You can check these links: http://r.789695.n4.nabble.com/Comparing-decimal-numbers-td3251437.html http://rwiki.sciviews.org/doku.php?id=misc:r_accuracy A.K. The FAQ says Other numbers have to be rounded to (typically) 53 binary digits accuracy. These numbers are clearly a bit less than that. Also, I've defined these numbers, they were not calculated through a multiplication or division operation. I would hate to think that R would have trouble with such a basic operation. I must be doing something wrong. - Original Message - From: arun smartpink...@yahoo.com To: R help r-help@r-project.org Cc: Sent: Wednesday, May 29, 2013 2:33 AM Subject: Re: Problems with merge HI, Possibly R FAQ: 7.31 data1New-data1 data1New$A- round(data1New$A,2) data2New- data2 data2New$A- round(data2New$A,2) merge(data1New,data2New,by=A) # A B C #1 0.0 0.9 10.0 #2 1.1 0.6 11.1 #3 1.4 0.7 11.4 #4 3.1 0.4 13.1 #5 4.4 0.8 14.4 A.K. Hello, Lets say we have these two data frames: data1-data.frame(c(1.23,1.363332,6.43209,4.230593,3.10294,5.09333,1.1,1.4,4.4,0),seq(0,by=0.1,length.out=10)) names(data1)-c(A,B) data2-data.frame(seq(0,6,by=0.1),seq(10,16,by=0.1)) names(data2)-c(A,C) And we would like to merge only the similar values from column A. merge(data1,data2,by=A,all=FALSE) we get: A B C 1 0.0 0.9 10.0 2 1.1 0.6 11.1 3 4.4 0.8 14.4 Unfortunately, it's missing the value of 1.4 in both data.frame columns A. Similarly, if we instead use: merge(data1,data2,by=A,all=TRUE) the value of 1.4 is duplicated while 0, 1.1, and 4.4 is not. All of the mathematical functions work as they should on the 1.4, yet merge seems to think that the two 1.4 in the different data frames are completely different values. I must be going crazy, because I use the merge function all the time and I've never run into this problem before. Thanks. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] 'x' must be numeric..
Hi, I have a problem that appears to be quite common - warnings that 'x' must be numeric. How can I get rid of that problem? specifically, I am trying to run an mrpp with a species-site data set plus a second file containing factors. Both files are saved as .csv and comma separated. I have tried to remove the column titles in a number of ways to not cause the problem to begin with, but r wasn't really impressed. what I've done so far is: #reading my species-site data set mzbtaxa-read.csv(MZBTaxa.csv, header=TRUE, dec=,, sep=;) mzbtaxa names(mzbtaxa) #reading my factors file mzbsites-read.csv(MZBSites.csv, header=TRUE, dec=,, sep=;) mzbsites names(mzbsites) #loading package library(vegan) ##trying to run mrpp mzbtaxa.mrpp - mrpp(mzbtaxa, mzbsites$Site, distance = bray) ##which is where I get my warning 'x' must be numeric. Any ideas how to deal with that? Many thanks in advance, Claudia Pogoreutz [[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] Goodness-of-fit tests for Complex Survey Logistic Regression
a) I've recently come across the global Goodness-of-ï¬t tests for complex survey logistic regression. Has it been implemented in R? Paper http://med.stanford.edu/medicine/ArcherLemeshowHosmer.pdf Implementation in Stata http://www.isr.umich.edu/src/smp/asda/Additional%20Analysis%20Example%20Demonstrating%20Use%20of%20Stata%20svy%20logistic%20and%20estat%20gof%20commands.pdf I'm asking because I've fitted a logistic model that's been used many times before (on random samples) to a strartified clustered one. Global fit indices were generally reported so unfortunately I need to carry out a couple of comparable tests... b) Besides the use of regTermTest (survey package) on independent variables, do you think that emulating the Chi-Square Goodness Of Fit Test on the final model in the following way makes sense? library(survey) data(api) dclus2-svydesign(id=~dnum+snum, weights=~pw, data=apiclus2) a-svyglm(sch.wide~1, design=dclus2,family=quasibinomial()) #Null model c-svyglm(sch.wide~ell*meals, design=dclus2,family=quasibinomial()) anova(a,c) Many thanks for your help Marco [[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] Egen and concat
R list members, I am trying to replicate a command script in STATA and find equivalency in R to the following Stata command: egen stratida = concat(year byregn2 group) if sample==1 egen stratidb = concat(year byregn2 group) if sample==2 egen stratidc = concat(year byregn2 group) if sample==3 Not sure if I should just try to make a for loop and use the paste operator or if there is somewhere else I should be looking. Thanks, Daniel [[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] Antw: [R-sig-Geo] RCurl: using ls instead of NLST
Dear Jonathan,in the MODIS package I use the following function to list files within a http or a ftp folder. I'm not really practical in XML stuff but I got it working somehow. The LP DAAC has changed from FTP to HTTP, I'm not sure if it is good idea to use the ftp protocol anymore. I also had a lot of problems with the ftplistonly=T option so I decided to use the saver version FALSE and split it by my own. Matteo MODIS:::filesUrl filesUrl - function(url) { require(RCurl) if (substr(url,nchar(url),nchar(url))!=/) { url - paste0(url,/) } iw - options()$warn options(warn=-1) on.exit(options(warn=iw)) try(co - getURLContent(url),silent=TRUE) if (!exists(co)) {return(FALSE)} if (substring(url,1,4)==http) { if(!require(XML)) { stop(You need to install the 'XML' package from 'Omegahat' repository) } co - htmlTreeParse(co) co - co$children[[1]][[2]][[2]] co - sapply(co$children, function(el) xmlGetAttr(el, href)) co - as.character(unlist(co)) co - co[!co %in% c(?C=N;O=D, ?C=M;O=A, ?C=S;O=A, ?C=D;O=A)] fnames - co[-1] } else { co - strsplit(co, if(.Platform$OS.type==unix){\n} else{\r\n})[[1]] co - strsplit(co, ) elim- grep(co,pattern=total) if(length(elim)==1) { co - co[-elim] } fnames - basename(sapply(co,function(x){x[length(x)]})) } fnames - gsub(fnames,pattern=/,replacement=) return(fnames) } Jonathan Greenberg 29.05.13 18.25 Uhr R-helpers: I'm trying to retrieve the contents of a directory from an ftp site (ideally, the file/folder names as a character vector): ftp://e4ftl01.cr.usgs.gov/MOTA/MCD12C1.005/; # (MODIS data) Where I get the following error via RCurl: require(RCurl) url - ftp://e4ftl01.cr.usgs.gov/MOTA/MCD12C1.005/; filenames = getURL(url,ftp.use.epsv=FALSE,ftplistonly=TRUE) Error in function (type, msg, asError = TRUE) : RETR response: 550 Through some sleuthing, it turns out the ftp site does not support NLST (which RCurl is using), but will use ls to list the directory contents -- is there any way to use ls remotely on this site? Thanks! --j -- Jonathan A. Greenberg, PhD Assistant Professor Global Environmental Analysis and Remote Sensing (GEARS) Laboratory Department of Geography and Geographic Information Science University of Illinois at Urbana-Champaign 607 South Mathews Avenue, MC 150 Urbana, IL 61801 Phone: 217-300-1924 http://www.geog.illinois.edu/~jgrn/ AIM: jgrn307, MSN: jgrn...@hotmail.com, Gchat: jgrn307, Skype: jgrn3007 [[alternative HTML version deleted]] ___ R-sig-Geo mailing list r-sig-...@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] highlight points in lattice cloud plot
That looks good, thanks a lot! Iwill give it a try in my real problemsoon. Cheers, stefan On 05/29/2013 06:02 PM, ilai wrote: On Wed, May 29, 2013 at 7:57 AM, Stefan Lüdtke slued...@gfz-potsdam.dewrote: x=runif(100, 1, 2) y=runif(100, 2, 4) z=runif(100, 1, 4) data_xyz=as.data.frame(cbind(x, y, z, a=rep(c(1:10), 10), b=rep(c(1:2), each=50))) custom.panel = function(x, y, z, subscripts, ...) { highlight=(data_xyz$a == 1) highlight.panel = highlight[subscripts] panel.cloud(x[highlight.panel], y[!highlight.panel], z[!highlight.panel], type='p', pch=18) panel.cloud(x[highlight.panel], y[highlight.panel], z[highlight.panel], type='b', col=tomato3) } If you args(panel.cloud) or ?panel.cloud you'll notice the order is x , y , subscripts , z ,... *not* x,y,z, hence the error message z not found or something to that effect you should have been getting. In any case you're code is IMHO a little clunky with groups=TRUE and a panel function just to get the groups condition. Would something like this do the job? cloud(z~x*y|b, groups=factor(a==1), data=data_xyz, pch=c(1,19), type='b', par.settings=list(superpose.line=list(col=c(0,#ff00ff #that works of course cloud(z~x*y|b, data=data_xyz) #that not cloud(z~x*y|b, data=data_xyz, groups=TRUE, panel=custom.panel) ## On 05/29/2013 03:36 PM, John Kane wrote: No attachment. The R-help list tendst to strip out many type of attached files though pdf and txt , among others get through. It is better to supply the example in the email itself if possible. Have a look at https://github.com/hadley/devtools/wiki/Reproducibility for suggestions. John Kane Kingston ON Canada -Original Message- From: slued...@gfz-potsdam.de Sent: Tue, 28 May 2013 15:50:33 -0700 (PDT) To: r-help@r-project.org Subject: [R] highlight points in lattice cloud plot Dear list, I am struggling with the following problem. In a 2d case I managed to highlight a subset of points through the panel.xyplot function. However, I was trying the same in 3d using panel.cloud, but now luck. I attached a minimal example, I think the first plot shows the idea. Thanks, Stefan -- View this message in context: http://r.789695.n4.nabble.com/highlight-points-in-lattice-cloud-plot-tp4668157.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. FREE ONLINE PHOTOSHARING - Share your photos online with your friends and family! Visit http://www.inbox.com/photosharing to find out 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] Spatial points analysis in R
Dear users, I am new to spatial data analysis in R. I have downloaded species occurrence point from the gbif database but when i'm trying to give coordinates to these points an error message comes up saying that the rows in the dataframe are not the same with spatial points. Can anyone help?. Thanks in advance. Alexand Msc. AgriScs. [[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] Error in names(data)[ix] : only 0's may be mixed with negative subscripts
I am getting the error Error in names(data)[ix] : only 0's may be mixed with negative subscripts and cannot quite figure out how to resolve this. Any ideas? attempt - read.csv(attempt.csv) str(attempt) 'data.frame': 9424 obs. of 9 variables: $ cgPlaId : int 647 647 647 647 647 647 647 647 647 647 ... $ measureYr: int 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 ... $ pop : Factor w/ 14 levels aa,alf,btg,..: 12 12 12 12 12 12 12 12 12 12 ... $ row : int 36 36 36 36 36 36 36 36 36 36 ... $ pos : int 975 975 975 975 975 975 975 975 975 975 ... $ ld : int 1 1 1 1 1 1 0 0 0 0 ... $ fl : int 0 0 0 0 0 0 0 0 0 0 ... $ hdCt : int NA NA NA NA NA NA NA NA NA NA ... $ achCt: int NA NA NA NA NA NA NA NA NA NA ... head(attempt) cgPlaId measureYr pop row pos ld fl hdCt achCt 1 647 1997 spp 36 975 1 0 NANA 2 647 1998 spp 36 975 1 0 NANA 3 647 1999 spp 36 975 1 0 NANA 4 647 2000 spp 36 975 1 0 NANA 5 647 2001 spp 36 975 1 0 NANA 6 647 2002 spp 36 975 1 0 NANA ##to deal with NA values## table(attempt$hdCt, useNA = always) 012345679 10 12 13 NA 67 429 151 48 26 12242111 8680 attempt$hdCt[is.na(attempt$hdCt)] - 0 table(attempt$hdCt, useNA = always) 012345679 10 12 13 NA 8747 429 151 48 26 122421110 attempt$achCt[is.na(attempt$achCt)] - 0 ww - reshape(attempt, v.names = c(ld, fl, hdCt, achCt), idvar = cgPlaId, timevar = measureYr, direction = wide) head(ww) cgPlaId pop row pos ld.1997 fl.1997 hdCt.1997 achCt.1997 ld.1998 fl.1998 1 647 spp 36 975 1 0 0 0 1 0 17 648 spp 33 982 1 0 0 0 1 0 33 649 spp 14 973 1 0 0 0 1 0 49 650 spp 27 979 1 0 0 0 1 0 65 651 spp 16 971 1 0 0 0 1 0 81 652 spp 21 974 1 0 0 0 1 0 hdCt.1998 achCt.1998 ld.1999 fl.1999 hdCt.1999 achCt.1999 ld.2000 fl.2000 1 0 0 1 0 0 0 1 0 17 0 0 1 0 0 0 0 0 33 0 0 1 0 0 0 1 0 49 0 0 1 0 0 0 1 0 65 0 0 1 0 0 0 1 0 81 0 0 1 0 0 0 1 0 hdCt.2000 achCt.2000 ld.2001 fl.2001 hdCt.2001 achCt.2001 ld.2002 fl.2002 1 0 0 1 0 0 0 1 0 17 0 0 0 0 0 0 0 0 33 0 0 1 0 0 0 1 0 49 0 0 1 0 0 0 1 0 65 0 0 1 0 0 0 1 0 81 0 0 1 0 0 0 1 0 hdCt.2002 achCt.2002 ld.2003 fl.2003 hdCt.2003 achCt.2003 ld.2004 fl.2004 1 0 0 0 0 0 0 0 0 17 0 0 0 0 0 0 0 0 33 0 0 1 0 0 0 1 0 49 0 0 1 0 0 0 1 0 65 0 0 1 0 0 0 1 0 81 0 0 1 0 0 0 1 1 hdCt.2004 achCt.2004 ld.2005 fl.2005 hdCt.2005 achCt.2005 ld.2006 fl.2006 1 0 0 0 0 0 0 0 0 17 0 0 0 0 0 0 0 0 33 0 0 1 0 0 0 1 0 49 0 0 1 0 0 0 1 0 65 0 0 1 0 0 0 1 0 81 1192 1 0 0 0 1 0 hdCt.2006 achCt.2006 ld.2007 fl.2007 hdCt.2007 achCt.2007 ld.2008 fl.2008 1 0 0 0 0 0 0 0 0 17 0 0 0 0 0 0 0 0 33 0 0 1 0 0 0 1 0 49 0 0 1 0 0 0 1 0 65 0 0 1 0 0 0 1 0 81 0 0 1 0 0 0 1 0 hdCt.2008 achCt.2008 ld.2009 fl.2009 hdCt.2009 achCt.2009
Re: [R] 'x' must be numeric..
What do you get when you type in these commands? lapply(mzbtaxa, class) lapply(mzbsites, class) Do you get the same error if you use the as.is=TRUE argument in the read.csv() function? mzbtaxa-read.csv(MZBTaxa.csv, header=TRUE, dec=,, sep=;, as.is=TRUE) mzbsites-read.csv(MZBSites.csv, header=TRUE, dec=,, sep=;, as.is=TRUE ) Jean On Wed, May 29, 2013 at 11:16 AM, Wobbe Gong wobbegon...@gmail.com wrote: Hi, I have a problem that appears to be quite common - warnings that 'x' must be numeric. How can I get rid of that problem? specifically, I am trying to run an mrpp with a species-site data set plus a second file containing factors. Both files are saved as .csv and comma separated. I have tried to remove the column titles in a number of ways to not cause the problem to begin with, but r wasn't really impressed. what I've done so far is: #reading my species-site data set mzbtaxa-read.csv(MZBTaxa.csv, header=TRUE, dec=,, sep=;) mzbtaxa names(mzbtaxa) #reading my factors file mzbsites-read.csv(MZBSites.csv, header=TRUE, dec=,, sep=;) mzbsites names(mzbsites) #loading package library(vegan) ##trying to run mrpp mzbtaxa.mrpp - mrpp(mzbtaxa, mzbsites$Site, distance = bray) ##which is where I get my warning 'x' must be numeric. Any ideas how to deal with that? Many thanks in advance, Claudia Pogoreutz [[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] Egen and concat
You are limiting yourself to getting help from only those people that understand the STATA language. You may improve your chances for a helpful response if you tell us in English what the STATA commands mean. Jean On Wed, May 29, 2013 at 10:37 AM, Daniel Tucker dtuck...@u.rochester.eduwrote: R list members, I am trying to replicate a command script in STATA and find equivalency in R to the following Stata command: egen stratida = concat(year byregn2 group) if sample==1 egen stratidb = concat(year byregn2 group) if sample==2 egen stratidc = concat(year byregn2 group) if sample==3 Not sure if I should just try to make a for loop and use the paste operator or if there is somewhere else I should be looking. Thanks, Daniel [[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] bootstrap
Hi, I am not sure if this is what you wanted. set.seed(125) simdata- replicate(S,generate(500)) set.seed(125) data1- generate(500) data2- replicate(S,as.data.frame(t(sample(as.data.frame(t(data1)),100,replace=TRUE dim(data2) #[1] 12 1000 data2[1:5,1:5] # [,1] [,2] [,3] [,4] [,5] #x1 Numeric,100 Numeric,100 Numeric,100 Numeric,100 Numeric,100 #x2 Numeric,100 Numeric,100 Numeric,100 Numeric,100 Numeric,100 #x3 Numeric,100 Numeric,100 Numeric,100 Numeric,100 Numeric,100 #x4 Numeric,100 Numeric,100 Numeric,100 Numeric,100 Numeric,100 #x5 Numeric,100 Numeric,100 Numeric,100 Numeric,100 Numeric,100 A.K. From: Angela Fel Padecio solewolf...@yahoo.com To: arun smartpink...@yahoo.com Sent: Wednesday, May 29, 2013 11:05 AM Subject: Re: bootstrap thanks for the reply. i think its nearer on the desired result. the previous syntax is this: set.seed(12345) S=1000 generate - function(size) { x1 - rnorm(size, mean=0, sd=1) x2 - rnorm(size, mean=0, sd=1) x3 - rnorm(size, mean=0, sd=1) x4 - rnorm(size, mean=0, sd=1) x5 - rnorm(size, mean=0, sd=1) x6 - rnorm(size, mean=0, sd=1) x7 - rnorm(size, mean=0, sd=1) x8 - rnorm(size, mean=0, sd=1) x9 - rnorm(size, mean=0, sd=1) x10 - rnorm(size, mean=0, sd=1) e-rnorm(size, mean=0, sd=1) t_trueps - (1 + exp( -(b0 + b1*x1 + b2*x2 + b3*x3 + b4*x4 + b5*x5 + b6*x6 + b7*x7 + b2*x2*x2 + b4*x4*x4 + b7*x7*x7 + b1*0.5*x1*x3 + b2*0.7*x2*x4 +b3*0.5*x3*x5 + b4*0.7*x4*x6 + b5*0.5*x5*x7 + b1*0.5*x1*x6 + b2*0.7*x2*x3 + b3*0.5*x3*x4 + b4*0.5*x4*x5 + b5*0.5*x5*x6) ) )^-1 prob.exposure - runif(size) t - ifelse(t_trueps prob.exposure, 1, 0) y - a0 + a1*x1 + a2*x2 + a3*x3 + a4*x4 +a5*x8 + a6*x9 + a7*x10 + g1*t + e sim - as.data.frame(cbind(x1, x2, x3 ,x4, x5, x6, x7, x8, x9, x10, t, y)) return(sim) } b0 - 0.05 b1 - 0.95 b2 - -0.25 b3 - 0.6 b4 - -0.4 b5 - -0.8 b6 - -0.5 b7 - 0.7 a0 - -3.85 a1 - 0.3 a2 - -0.36 a3 - -0.73 a4 - -0.2 a5 - 0.71 a6 - -0.19 a7 - 0.26 g1 - -0.4 simdata - replicate(S, generate(500)) with a partial result of [,1] [,2] [,3] [,4] [,5] [,6] x1 Numeric,500 Numeric,500 Numeric,500 Numeric,500 Numeric,500 Numeric,500 x2 Numeric,500 Numeric,500 Numeric,500 Numeric,500 Numeric,500 Numeric,500 x3 Numeric,500 Numeric,500 Numeric,500 Numeric,500 Numeric,500 Numeric,500 x4 Numeric,500 Numeric,500 Numeric,500 Numeric,500 Numeric,500 Numeric,500 x5 Numeric,500 Numeric,500 Numeric,500 Numeric,500 Numeric,500 Numeric,500 x6 Numeric,500 Numeric,500 Numeric,500 Numeric,500 Numeric,500 Numeric,500 x7 Numeric,500 Numeric,500 Numeric,500 Numeric,500 Numeric,500 Numeric,500 x8 Numeric,500 Numeric,500 Numeric,500 Numeric,500 Numeric,500 Numeric,500 x9 Numeric,500 Numeric,500 Numeric,500 Numeric,500 Numeric,500 Numeric,500 x10 Numeric,500 Numeric,500 Numeric,500 Numeric,500 Numeric,500 Numeric,500 t Numeric,500 Numeric,500 Numeric,500 Numeric,500 Numeric,500 Numeric,500 y Numeric,500 Numeric,500 Numeric,500 Numeric,500 Numeric,500 Numeric,500 up to [,997] [,998] [,999] [,1000] x1 Numeric,500 Numeric,500 Numeric,500 Numeric,500 x2 Numeric,500 Numeric,500 Numeric,500 Numeric,500 x3 Numeric,500 Numeric,500 Numeric,500 Numeric,500 x4 Numeric,500 Numeric,500 Numeric,500 Numeric,500 x5 Numeric,500 Numeric,500 Numeric,500 Numeric,500 x6 Numeric,500 Numeric,500 Numeric,500 Numeric,500 x7 Numeric,500 Numeric,500 Numeric,500 Numeric,500 x8 Numeric,500 Numeric,500 Numeric,500 Numeric,500 x9 Numeric,500 Numeric,500 Numeric,500 Numeric,500 x10 Numeric,500 Numeric,500 Numeric,500 Numeric,500 t Numeric,500 Numeric,500 Numeric,500 Numeric,500 y Numeric,500 Numeric,500 Numeric,500 Numeric,500 i want a similar structure of this result but not usingreplicate command but bootstrapping or sample command. i simulate n=500 and from this, i get for instance n=100, with 1000 replications. how can i have this? thanks for the help. i appreciate it a lot coz i need it in school. please help. thanks! From: arun smartpink...@yahoo.com To: Angela Fel Padecio solewolf...@yahoo.com Cc: R help r-help@r-project.org; Bert Gunter gunter.ber...@gene.com Sent: Wednesday, May 29, 2013 10:47 PM Subject: Re: bootstrap Hi, Don't know if this helps: set.seed(244) data1- generate(10) data1 x1 x2 x3 x4 x5 x6 1 -0.89558948 -0.5609722069 -1.0782688 -1.2461548 -0.58857050 1.5708187 2 -0.82379187 -0.9056306209 -1.5700755 -0.6045090 -0.19683863 -0.8969354 3 -1.04303377 -0.2379109244 -0.6589381 -0.7521561 1.37492952 -2.7515409 4 0.00783492 0.4249100106 -0.8221292 -0.6220925 0.91199682 0.6365096 5 0.72986110 0.5355575043 1.7584239 1.4474157 -0.46647958 -0.3799255 6 -1.83691611 1.4025663889 -1.0857996 1.3311993 -2.32091759 0.5866616 7 0.10720511 0.6393573943 -0.2811223 2.2800918 0.09360948
[R] combine two columns into one
Hey all! I have a time series dataset like this: DateTime Var 112 1 14 1 1 5 1 2 8 1 2 8 1 2 9 213 21 4 214 I created a unique id for each row: dat$UniqueID - paste(dat$Date,dat$Time, sep = '_') then aggregate(dat$Var, list(dat$UniqueID), sum) however the final output is not in ideal order I look for (I simply this example provided above).I would like to have order like this: 1_1 1_2 2_1 Thanks for your help! [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Find longuest string in a character list
May be this helps: mymatrix- matrix (1:5, nrow=5, ncol=columnas, byrow=TRUE, dimnames=(list(myrownames, c(1,2,3,4,5 #Error in matrix(1:5, nrow = 5, ncol = columnas, byrow = TRUE, dimnames = (list(myrownames, : # object 'columnas' not found myrownames[which.max(nchar(myrownames))] #[1] Ciencias Sociales y Jurídicas nchar(myrownames)[which.max(nchar(myrownames))] #[1] 29 A.K. Hello, I want to modify margin options in a barplot into a loop. I have, for example, a matrix like this: myrownames - c(Arte y Humanidades,Ciencias Sociales y Jurídicas, Ciencias de la Salud,Ciencias, Ingenierías y arquitectura) mymatrix- matrix (1:5, nrow=5, ncol=columnas, byrow=TRUE, dimnames=(list(myrownames, c(1,2,3,4,5 my_strings_length - nchar(rownames(mymatrix)) [1] 18 29 20 8 26 I want to find automatically the highest value in my_strings_length, i.e 29. ¿how can I do it? many thanks, -- == Ramón Ovelar Campus Virtual Birtuala UPV/EHU Tel: (34) 94 601 3407 http://campusvirtual.ehu.es University of the Basque Country __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] combine two columns into one
Hi, May be I misunderstood your question: dat- read.table(text= Date Time Var 1 1 2 1 1 4 1 1 5 1 2 8 1 2 8 1 2 9 2 1 3 2 1 4 2 1 4 ,sep=,header=TRUE) dat$UniqueID - paste(dat$Date,dat$Time, sep = '_') aggregate(dat$Var,list(dat$UniqueID),sum) #isn't this the correct order # Group.1 x #1 1_1 11 #2 1_2 25 #3 2_1 11 library(plyr) ddply(dat,.(UniqueID),summarize,Var=sum(Var)) # UniqueID Var #1 1_1 11 #2 1_2 25 #3 2_1 11 A.K. - Original Message - From: Ye Lin ye...@lbl.gov To: R help r-help@r-project.org Cc: Sent: Wednesday, May 29, 2013 2:23 PM Subject: [R] combine two columns into one Hey all! I have a time series dataset like this: Date Time Var 1 1 2 1 1 4 1 1 5 1 2 8 1 2 8 1 2 9 2 1 3 2 1 4 2 1 4 I created a unique id for each row: dat$UniqueID - paste(dat$Date,dat$Time, sep = '_') then aggregate(dat$Var, list(dat$UniqueID), sum) however the final output is not in ideal order I look for (I simply this example provided above).I would like to have order like this: 1_1 1_2 2_1 Thanks for your help! [[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] combine two columns into one
The actual date col is in -mm-dd format, and when I apply this code to my actual data, it mess up the order On Wed, May 29, 2013 at 11:37 AM, arun smartpink...@yahoo.com wrote: Hi, May be I misunderstood your question: dat- read.table(text= DateTime Var 112 1 14 1 15 1 2 8 1 2 8 12 9 213 21 4 214 ,sep=,header=TRUE) dat$UniqueID - paste(dat$Date,dat$Time, sep = '_') aggregate(dat$Var,list(dat$UniqueID),sum) #isn't this the correct order # Group.1 x #1 1_1 11 #2 1_2 25 #3 2_1 11 library(plyr) ddply(dat,.(UniqueID),summarize,Var=sum(Var)) # UniqueID Var #1 1_1 11 #2 1_2 25 #3 2_1 11 A.K. - Original Message - From: Ye Lin ye...@lbl.gov To: R help r-help@r-project.org Cc: Sent: Wednesday, May 29, 2013 2:23 PM Subject: [R] combine two columns into one Hey all! I have a time series dataset like this: DateTime Var 112 1 14 1 1 5 1 2 8 1 2 8 1 2 9 213 21 4 214 I created a unique id for each row: dat$UniqueID - paste(dat$Date,dat$Time, sep = '_') then aggregate(dat$Var, list(dat$UniqueID), sum) however the final output is not in ideal order I look for (I simply this example provided above).I would like to have order like this: 1_1 1_2 2_1 Thanks for your help! [[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] Spatial points analysis in R
Hi, You're most likely to get an informative answer if you tell us exactly what you did. A reproducible example was best. You might also be better off posting to the r-sig-geo list rather than to R-help. Sarah On Wednesday, May 29, 2013, jickngea alexand wrote: Dear users, I am new to spatial data analysis in R. I have downloaded species occurrence point from the gbif database but when i'm trying to give coordinates to these points an error message comes up saying that the rows in the dataframe are not the same with spatial points. Can anyone help?. Thanks in advance. Alexand Msc. AgriScs. -- Sarah Goslee http://www.stringpage.com http://www.sarahgoslee.com http://www.functionaldiversity.org [[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] combine two columns into one
dat1- read.table(text= Date Time Var 11/1/2012 1 3 11/1/2012 1 1 11/1/2012 1 1 11/1/2012 2 3 11/1/2012 2 1 11/1/2012 2 1 11/2/2012 1 1 11/2/2012 1 3 11/2/2012 1 1 11/2/2012 2 3 ,sep=,header=TRUE,stringsAsFactors=FALSE) dat1$Date-as.Date(dat1$Date,format=%m/%d/%Y) If you need to combine Date and Time columns into one: library(plyr) res-mutate(ddply(dat1,.(Date,Time),summarize,Var=sum(Var)),DT=paste(Date,Time,sep=_))[,c(4,3)] res # DT Var #1 2012-11-01_1 5 #2 2012-11-01_2 5 #3 2012-11-02_1 5 #4 2012-11-02_2 3 A.K. From: Ye Lin ye...@lbl.gov To: arun smartpink...@yahoo.com Cc: R help r-help@r-project.org Sent: Wednesday, May 29, 2013 2:40 PM Subject: Re: [R] combine two columns into one The actual date col is in -mm-dd format, and when I apply this code to my actual data, it mess up the order On Wed, May 29, 2013 at 11:37 AM, arun smartpink...@yahoo.com wrote: Hi, May be I misunderstood your question: dat- read.table(text= Date Time Var 1 1 2 1 1 4 1 1 5 1 2 8 1 2 8 1 2 9 2 1 3 2 1 4 2 1 4 ,sep=,header=TRUE) dat$UniqueID - paste(dat$Date,dat$Time, sep = '_') aggregate(dat$Var,list(dat$UniqueID),sum) #isn't this the correct order # Group.1 x #1 1_1 11 #2 1_2 25 #3 2_1 11 library(plyr) ddply(dat,.(UniqueID),summarize,Var=sum(Var)) # UniqueID Var #1 1_1 11 #2 1_2 25 #3 2_1 11 A.K. - Original Message - From: Ye Lin ye...@lbl.gov To: R help r-help@r-project.org Cc: Sent: Wednesday, May 29, 2013 2:23 PM Subject: [R] combine two columns into one Hey all! I have a time series dataset like this: Date Time Var 1 1 2 1 1 4 1 1 5 1 2 8 1 2 8 1 2 9 2 1 3 2 1 4 2 1 4 I created a unique id for each row: dat$UniqueID - paste(dat$Date,dat$Time, sep = '_') then aggregate(dat$Var, list(dat$UniqueID), sum) however the final output is not in ideal order I look for (I simply this example provided above).I would like to have order like this: 1_1 1_2 2_1 Thanks for your help! [[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] More discussion on R usage statistics
Interesting idea but would you be willing to change the name. Twitter, Stackoverflow, and the like use rstats to refer to R itself and confusion seems probable. https://mobile.twitter.com/search?q=%23rstats Michael On May 29, 2013, at 19:21, Johnny Zhang johnny...@yahoo.com wrote: Dear R users, There has been discussion on how to collect R usage statistics before and the discussion has led to some good results such as http://neolab.stat.ucla.edu/cranstats/ and http://crantastic.org/. Recently, I tried to put together a package that allows R users to rate, comment, and ask questions on R packages within R. A working version is now available on both github and r-forge. Note that the email feature may not work out as expected because gmail, used by the package, only allows 500 messages sent per day. To install it from R forge, please use install.packages('rstats', repos=http://r-forge.r-project.org;) Using github (require the package devtools), install_github('rstats','johnnyzhz') A brief manual of it can be seen at: http://rstats.psychstat.org/rstats.pdf I'd appreciate it that if you can test this and provide feedback on how to collect and utilize R usage statistics. Best, Zhiyong Zhang [[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] Goodness-of-fit tests for Complex Survey Logistic Regression
On Thu, May 30, 2013 at 3:29 AM, Marco Pomati pt...@bristol.ac.uk wrote: a) I've recently come across the global Goodness-of-ï¬t tests for complex survey logistic regression. Has it been implemented in R? It's quite hard to definitively say that something hasn't been implemented in R, but I haven't implemented it, and I'd be a bit surprised if someone else had without asking me about it. It looks from the paper as though the 'mean residual test' could be implemented fairly easily. If I have read it correctly, then r - residuals(model, type=response) f-fitted(model) g- cut(f, c(-Inf, quantile(f, (1:9)/10, Inf)) # now create a new design object with r and g added as variables decilemodel- svyglm(r~g, design=newdesign) regTermTest(decilemodel, ~g) is the F-adjusted mean residual test from that paper. I'm asking because I've fitted a logistic model that's been used many times before (on random samples) to a strartified clustered one. Global fit indices were generally reported so unfortunately I need to carry out a couple of comparable tests... b) Besides the use of regTermTest (survey package) on independent variables, do you think that emulating the Chi-Square Goodness Of Fit Test on the final model in the following way makes sense? library(survey) data(api) dclus2-svydesign(id=~dnum+snum, weights=~pw, data=apiclus2) a-svyglm(sch.wide~1, design=dclus2,family=quasibinomial()) #Null model c-svyglm(sch.wide~ell*meals, design=dclus2,family=quasibinomial()) anova(a,c) That's not really a goodness of fit test, it's a test of whether the model is better than nothing. It should agree with regTermTest(method=LRT), because that's how it is implemented when the models are 'syntactically' nested, ie, when you can tell just from the model formula that they are nested. (examples of models that are nested but not syntactically nested would be a linear term and a spline) I'm not generally a fan of global goodness-of-fit tests, but this is straightforward enough that I might add it to the survey package (though that's not going to happen for a month or so). -thomas -- Thomas Lumley Professor of Biostatistics University of Auckland [[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] lmer (multinomial response variable ~ fixed + (1|random), family='multinomial ???)
Hello, I am trying to run glmm to test the effect of the three fixed effects [AGE (weaned vs. unweaned claf), LOCATION (zoo vs. park), MOTher's social status (matriarch vs. nonmatriarch)] and one random effect [ID (12 different calves of whom I have multiple but unbalanced observations)] on the a multinomial response variable [DIST (distance from mom at less than 2 meters,between 2-5 meters and at more than 5 meters). Is the *family = binomial* argument in my code incorrect for my data? If it is incorrect, is there a way to test this model with *multinomial response variable*? OConnell.glmm1-lmer(DIST~AGE+LOC+MOT+(1|ID),data=OConnell,family=binomial(link = logit) Thank you for reading. Maggie [[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] Subset a floating point vector using all.equal?
Hello, I have a whole bunch of data to two decimal places. I've done some arithmetic with them, so floating point becomes an issue. x - c(1, 0.15,(0.1+.05),0.4) I want to do something like this: x[x==0.15] But you'll notice that is troublesome with the well known floating point issue. So really I need to do something like this: x[all.equal(x, 0.15)] But that doesn't work because all.equal wants to compare objects and not each element. I could do: x[round(x,2) ==0.15] It seems to work in this case, but as I've been working with my data I'm concerned its unreliable. What is the most efficient way of subsetting data using a machine-tolerance equal numeric value? Thanks R-Helpers. Peter [[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] Egen and concat
Let me explain what I am planning on doing; some background is probably necessary and in hindsight the first email doesn't accurately describe what I am looking to do. I'm trying to run a conditional logit model, but I want to have a different strata depending on the value of another variable if sample==1 I want my strata to be stratida if sample==2 I want my strata to be stratidb if sample==3 I want my strata to be stratidc stratida/stratidb/stratidc are NOT variables already in the dataset. they represent a string combination of three already present numerical variables (year, byregn2, group) and differ for when the variable sample is ==1,2 or 3. They are different variables for labeling purposes. What I am looking to do is replicate these in one variable--make one variable that is the string combination of year, byregn2, and group and then use it as my strata. On Wed, May 29, 2013 at 1:53 PM, Adams, Jean jvad...@usgs.gov wrote: You are limiting yourself to getting help from only those people that understand the STATA language. You may improve your chances for a helpful response if you tell us in English what the STATA commands mean. Jean On Wed, May 29, 2013 at 10:37 AM, Daniel Tucker dtuck...@u.rochester.eduwrote: R list members, I am trying to replicate a command script in STATA and find equivalency in R to the following Stata command: egen stratida = concat(year byregn2 group) if sample==1 egen stratidb = concat(year byregn2 group) if sample==2 egen stratidc = concat(year byregn2 group) if sample==3 Not sure if I should just try to make a for loop and use the paste operator or if there is somewhere else I should be looking. Thanks, Daniel [[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] highlight points in lattice cloud plot
Hi Stefan Not a perfect solution but may get you some of the way. I can't spend any more time on it I think your groups argument is not valid so made a groups argument Try this data_xyz$gp - sapply(data_xyz$a == 1, pmatch, c(TRUE,FALSE)) cloud(z ~ x*y|b, data=data_xyz, groups= gp, panel = function(x,y, subscripts, groups, xlim,...){ pnl - panel.number() if (pnl == 1){ panel.cloud(x, y, z, subscripts = subscripts, groups=groups, type='p', xlim = xlim, ...) panel.cloud(x, y, z, type='p', pch=18,xlim = xlim, ...) } else { panel.cloud(x, y, z, subscripts = subscripts, groups=groups, type='p', xlim = xlim, ...) panel.cloud(x, y, z, type='b', col=tomato3,xlim = xlim, ...) } } ) HTH Duncan Duncan Mackay Department of Agronomy and Soil Science University of New England Armidale NSW 2351 Email: home: mac...@northnet.com.au At 23:57 29/05/2013, you wrote: Sorry forthat and thanks for the hint. At marked the appended text as rawtext, maybe that is the reason why it was cut. Here we go again. ## x=runif(100, 1, 2) y=runif(100, 2, 4) z=runif(100, 1, 4) ### 2d example data_xy=as.data.frame(cbind(x, y, a=rep(c(1:10), 10), b=rep(c(1:2), each=50))) custom.panel = function(x, y, subscripts, ...) { highlight=(data_xy$a == 1) highlight.panel = highlight[subscripts] panel.xyplot(x[highlight.panel], y[!highlight.panel], type='p', pch=18) panel.xyplot(x[highlight.panel], y[highlight.panel], type='b', col=tomato3) } xyplot(x~y|b, data=data_xy, groups=a, panel=custom.panel) ### 3d example data_xyz=as.data.frame(cbind(x, y, z, a=rep(c(1:10), 10), b=rep(c(1:2), each=50))) custom.panel = function(x, y, z, subscripts, ...) { highlight=(data_xyz$a == 1) highlight.panel = highlight[subscripts] panel.cloud(x[highlight.panel], y[!highlight.panel], z[!highlight.panel], type='p', pch=18) panel.cloud(x[highlight.panel], y[highlight.panel], z[highlight.panel], type='b', col=tomato3) } #that works of course cloud(z~x*y|b, data=data_xyz) #that not cloud(z~x*y|b, data=data_xyz, groups=TRUE, panel=custom.panel) ## On 05/29/2013 03:36 PM, John Kane wrote: No attachment. The R-help list tendst to strip out many type of attached files though pdf and txt , among others get through. It is better to supply the example in the email itself if possible. Have a look at https://github.com/hadley/devtools/wiki/Reproducibility for suggestions. John Kane Kingston ON Canada -Original Message- From: slued...@gfz-potsdam.de Sent: Tue, 28 May 2013 15:50:33 -0700 (PDT) To: r-help@r-project.org Subject: [R] highlight points in lattice cloud plot Dear list, I am struggling with the following problem. In a 2d case I managed to highlight a subset of points through the panel.xyplot function. However, I was trying the same in 3d using panel.cloud, but now luck. I attached a minimal example, I think the first plot shows the idea. Thanks, Stefan -- View this message in context: http://r.789695.n4.nabble.com/highlight-points-in-lattice-cloud-plot-tp4668157.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. FREE ONLINE PHOTOSHARING - Share your photos online with your friends and family! Visit http://www.inbox.com/photosharing to find out 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. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Egen and concat
On May 29, 2013, at 3:10 PM, Daniel Tucker wrote: Let me explain what I am planning on doing; some background is probably necessary and in hindsight the first email doesn't accurately describe what I am looking to do. I'm trying to run a conditional logit model, but I want to have a different strata depending on the value of another variable if sample==1 I want my strata to be stratida if sample==2 I want my strata to be stratidb if sample==3 I want my strata to be stratidc stratida/stratidb/stratidc are NOT variables already in the dataset. they represent a string combination of three already present numerical variables (year, byregn2, group) and differ for when the variable sample is ==1,2 or 3. They are different variables for labeling purposes. What I am looking to do is replicate these in one variable--make one variable that is the string combination of year, byregn2, and group and then use it as my strata. If dfrm is a data.frame with column names: year, byregn2, group then creating a 4th column named strata: dfrm$strata - with( dfrm, paste0(year, byregn2, group) ) If you want tested code, you need to offer actual R objects. -- David. On Wed, May 29, 2013 at 1:53 PM, Adams, Jean jvad...@usgs.gov wrote: You are limiting yourself to getting help from only those people that understand the STATA language. You may improve your chances for a helpful response if you tell us in English what the STATA commands mean. Jean On Wed, May 29, 2013 at 10:37 AM, Daniel Tucker dtuck...@u.rochester.edu wrote: R list members, I am trying to replicate a command script in STATA and find equivalency in R to the following Stata command: egen stratida = concat(year byregn2 group) if sample==1 egen stratidb = concat(year byregn2 group) if sample==2 egen stratidc = concat(year byregn2 group) if sample==3 Not sure if I should just try to make a for loop and use the paste operator or if there is somewhere else I should be looking. Thanks, Daniel David Winsemius, MD Alameda, CA, USA __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Subset a floating point vector using all.equal?
On May 29, 2013, at 6:27 PM, Peter Lomas wrote: Hello, I have a whole bunch of data to two decimal places. I've done some arithmetic with them, so floating point becomes an issue. x - c(1, 0.15,(0.1+.05),0.4) I want to do something like this: x[x==0.15] But you'll notice that is troublesome with the well known floating point issue. So really I need to do something like this: x[all.equal(x, 0.15)] x[ zapsmall(x-0.15)==0 ] But that doesn't work because all.equal wants to compare objects and not each element. I could do: x[round(x,2) ==0.15] It seems to work in this case, but as I've been working with my data I'm concerned its unreliable. What is the most efficient way of subsetting data using a machine-tolerance equal numeric value? Thanks R-Helpers. David Winsemius, MD Alameda, CA, USA __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.