Re: [R] Running GCV Optimization under Ridge Regression

2015-09-21 Thread Preetam Pal
Hi John/R-users, - I have attached the data set in the mail in .txt format, can be read using read.table(). Kindly let me know please if this is not sufficient. - Also, to specify the modeling scheme I am stuck at: 1. Have numerical regressors GDP, HPA and FX to predict the variable

Re: [R] How to coerce a parameter in nls?

2015-09-21 Thread Jianling Fan
Hello, Gabor, Thanks again for your suggestion. And now I am trying to improve the code by adding a function to replace the express "Rm1 * ref.1 + Rm2 * ref.2 + Rm3 * ref.3 + Rm4 * ref.4 + Rm5 * ref.5 + Rm6 * ref.6" because I have some other dataset need to fitted to the same model but with more g

Re: [R] R-help, please

2015-09-21 Thread MCGUIRE, Rhydwyn
Hi Kim, this sounds like a homework question which is not meant for this list, I don't believe you need a package for this, but you may find the ifelse function along with the sum()function useful. You can get more information by typing ?ifelse and ?sum into R. Regards, Rhydwyn Rhydwyn McGuir

Re: [R] Running GCV Optimization under Ridge Regression

2015-09-21 Thread John Kane
No data. Please have a look at http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example and http://adv-r.had.co.nz/Reproducibility.html John Kane Kingston ON Canada > -Original Message- > From: lordpree...@gmail.com > Sent: Tue, 22 Sep 2015 01:19:38 +0530

Re: [R] extract from data.frame (indexing)

2015-09-21 Thread John Kane
And the action is? John Kane Kingston ON Canada > -Original Message- > From: nico.gutierr...@gmail.com > Sent: Mon, 21 Sep 2015 16:48:45 +0200 > To: r-help@r-project.org > Subject: [R] extract from data.frame (indexing) > > Hi All, > > I need to do the following operation: > > > Ye

Re: [R] R-help, please

2015-09-21 Thread John Kane
It looks like you sent the e-mail in HTML. It is unreadable. You must sent e-mail to R-help in plain text not HTML John Kane Kingston ON Canada > -Original Message- > From: le4...@mweb.co.za > Sent: Mon, 21 Sep 2015 16:14:41 +0200 > To: r-help@r-project.org > Subject: Re: [R] R-help,

Re: [R] vector manipulations -- differences

2015-09-21 Thread Bert Gunter
Use ?mappy and ?rep.int > x[unlist(mapply(":",2:4,4))] - x[rep.int(1:3,3:1)] [1] 3 7 20 4 17 13 Cheers, Bert Bert Gunter "Data is not information. Information is not knowledge. And knowledge is certainly not wisdom." -- Clifford Stoll On Mon, Sep 21, 2015 at 2:17 PM, Dan D wrote: > I

Re: [R] R-help, please

2015-09-21 Thread Rolf Turner
Your question looks very much like homework and this list does not do homework for people. Talk to your instructor. cheers, Rolf Turner On 22/09/15 02:14, le4...@mweb.co.za wrote: Good day, My name is Kim Nguyen and please I need your help with: How to calculate the PASS rate of the data

[R] vector manipulations -- differences

2015-09-21 Thread Dan D
I need an efficient way to build a new n x (n-1)/2 vector from an n-vector x as: c(x[-1]-x[1], x[-(1:2)]-x[2], ... , x[-(1:(n-1)] - x[n-1]) x is increasing with x[1] = 0. The following works but is not the greatest: junk<-outer(x, x, '-') junk[junk>0] e.g., given x<-c(0, 3, 7, 20) junk<-outer

Re: [R] Extract from data.frame

2015-09-21 Thread Frank Schwidom
better ( if year is an vector of more than 1 element): df[ df$Year %in% outer(as.numeric( as.character( year)), -1:1, FUN='+'), ] Year Amount 2 2002120 3 2003175 4 2004160 On Mon, Sep 21, 2015 at 10:49:34PM +0200, Frank Schwidom wrote: > > year <- df$Year[ which.max( df$Amount)]

Re: [R] extracting a value from XML

2015-09-21 Thread Glenn Schultz
Hi Bob, Thanks, can you help me undestand why it starts with //observation and how you know that it is a node? Glenn On Sep 21, 2015, at 01:56 PM, boB Rudis wrote: This is how (one way) in both the xml2 package and XML package: library(xml2) library(XML) txt <- ' ' doc <- read_xml(txt)

Re: [R] Extract from data.frame

2015-09-21 Thread Frank Schwidom
year <- df$Year[ which.max( df$Amount)] df[ df$Year %in% (as.numeric( as.character( year)) + -1:1), ] Year Amount 2 2002120 3 2003175 4 2004160 On Mon, Sep 21, 2015 at 04:52:46PM +0200, Nico Gutierrez wrote: > Hi All, > > I need to do the following operation from data.frame: > >

Re: [R] Extract from data.frame

2015-09-21 Thread Bert Gunter
No. On Mon, Sep 21, 2015 at 10:58 AM, John McKown wrote: > On Mon, Sep 21, 2015 at 9:52 AM, Nico Gutierrez > wrote: > >> Hi All, >> >> I need to do the following operation from data.frame: >> >> df <- data.frame(Year = c("2001", "2002", "2003", "2004", "2005", "2006", >> "2007"), Amount = c(150

[R] Running GCV Optimization under Ridge Regression

2015-09-21 Thread Preetam Pal
Hi guys, I am running Ridge regression on a dataset (predicted variable = y; GDP, HPA and FX are regressors). I found that lm.ridge() can perform the ridge regression given any value of lambda (i.e. the ridge parameter). However, in order to choose the best results, I need to select the model outp

Re: [R] extracting a value from XML

2015-09-21 Thread boB Rudis
The " > observation_start="2015-09-01" observation_end="2015-09-01" > units="lin" output_type="1" file_type="xml" > order_by="observation_date" sort_order="asc" count="1" offset="0" > limit="10"> > date="2015-09-01" value="0.46"/> > ' > > doc <- read_xml(txt) > xml_attr(xml_find_all(doc, "//o

Re: [R] How to coerce a parameter in nls?

2015-09-21 Thread ProfJCNash
I've not used it for group data, and suspect that the code to generate derivatives cannot cope with the bracket syntax. If you can rewrite the equation without the brackets, you could get the derivatives and solve that way. This will probably mean having a "translation" routine to glue things t

Re: [R] How to coerce a parameter in nls?

2015-09-21 Thread ProfJCNash
Apologies for replying and overlapping Gabor's contribution, which actually did the work! Best, JN On 15-09-21 01:03 PM, Jianling Fan wrote: Thanks Gabor, That works good to rewrite the express the formula! Thanks a lot! Regards, Jianling On 21 September 2015 at 10:43, Gabor Grothendiec

Re: [R] extracting a value from XML

2015-09-21 Thread boB Rudis
This is how (one way) in both the xml2 package and XML package: library(xml2) library(XML) txt <- ' ' doc <- read_xml(txt) xml_attr(xml_find_all(doc, "//observation"), "value") doc1 <- xmlParse(txt) xpathSApply(doc1, "//observation", xmlGetAttr, "value") On Mon, Sep 21, 2015 at 2:01 PM,

[R] extracting a value from XML

2015-09-21 Thread Glenn Schultz
Hi All, I have been trying to extract a value from XML.  I have been at it for several days off and on and I can't seem to get my head around the problem.   I basically understand the examples in R help but I cannot replicate success with the below  I tried to use xmlValue(doc, "//[[value]]")

Re: [R] ggplot2 will not install after system upgrade

2015-09-21 Thread Jeff Trefftzs
On Thu, 2015-09-03 at 16:47 -0400, Ista Zahn wrote: > Hi Jeff, > Your chances of getting a useful response will increase if you > provide > some additional information. For example, which version of R? Which > version of ggplot2? What sequence of commands produces the error? > What > _exactly_ does

Re: [R] Extract from data.frame

2015-09-21 Thread Bert Gunter
Note the following problems: 1. " max_row <- (1:nrow(df))[which.max(df$Amount)]" This is a bit silly. max_row <- which.max(df$Amount) will do. See ?which.max 2. What happens if the max is the first or last row? e.g. > dat <- data.frame(a=runif(5),b=1:5) > max_row<- which.max(dat$b) > mean(d

Re: [R] Extract from data.frame

2015-09-21 Thread John McKown
On Mon, Sep 21, 2015 at 9:52 AM, Nico Gutierrez wrote: > Hi All, > > I need to do the following operation from data.frame: > > df <- data.frame(Year = c("2001", "2002", "2003", "2004", "2005", "2006", > "2007"), Amount = c(150, 120, 175, 160, 120, 105, 135)) > df[which.max(df$Amount),] #to extra

Re: [R] how to add 1 + 1 with the interface between R and C

2015-09-21 Thread Cleber Borges
I think is time to learning Rcpp! :-) thank you (Peter Dalgaard and Dirk Eddelbuettel ) by the examples! the more simples are often more informatives... cleber Em 21/09/2015 12:36, Dirk Eddelbuettel escreveu: peter dalgaard gmail.com> writes: C is call by value and k and res are pointers

Re: [R] Extract from data.frame

2015-09-21 Thread Mark Sharp
Nico, I expect there are many better ways to do this, but this does work: max_row <- (1:nrow(df))[which.max(df$Amount)] mean(df$Amount[max_row + c(-1, 0, 1)]) > max_row <- (1:nrow(df))[which.max(df$Amount)] > mean(df$Amount[max_row + c(-1, 0, 1)]) [1] 151.6667 R. Mark Sharp, Ph.D. Director of P

Re: [R] Download showing as exploit

2015-09-21 Thread Duncan Murdoch
On 21/09/2015 10:30 AM, Tim Kingston wrote: > > Hi , > > I work for the NHS, and our IT service has been unable to download as its > anti-virus software says it contains an exploit. > > Is this normal? Is there a way around this? > > Kind regards, > > Tim Kingston > You don't say what you'

[R] Extract from data.frame

2015-09-21 Thread Nico Gutierrez
Hi All, I need to do the following operation from data.frame: df <- data.frame(Year = c("2001", "2002", "2003", "2004", "2005", "2006", "2007"), Amount = c(150, 120, 175, 160, 120, 105, 135)) df[which.max(df$Amount),] #to extract row with max Amount. Now I need to do 3 years average around the

[R] extract from data.frame (indexing)

2015-09-21 Thread Nico Gutierrez
Hi All, I need to do the following operation: Year Amount Amount.1 1 2001150 150 2 2002120 120 3 2003175 175 4 2004160 160 5 2005120 120 6 2006105 105 7 2007135 135 [[alternative HTML version deleted]] ___

[R] Accounting for correlated random effects in coxme with matrix from a phylogeny rather than pedigree

2015-09-21 Thread Oyomoare Osazuwa-Peters
Hello All, I have a problem with running the mixed effects Cox regression model using a distance matrix from a phylogeny rather than a pedigree. I searched previous posts and didn't find any directly relevant previous posts. I am interested in using a mixed effects Cox regression model to determi

Re: [R] how to add 1 + 1 with the interface between R and C

2015-09-21 Thread Dirk Eddelbuettel
peter dalgaard gmail.com> writes: > C is call by value and k and res are pointers. You need a dereferencing step or nothing with happen. Try > > *res = *k + 1; Or you use Rcpp which writes the glue code. Save the following into a file: #include // [[Rcpp::export]] int adder(int x, int y) {

[R] Download showing as exploit

2015-09-21 Thread Tim Kingston
Hi , I work for the NHS, and our IT service has been unable to download as its anti-virus software says it contains an exploit. Is this normal? Is there a way around this? Kind regards, Tim Kingston Sent from my HTC [[alternative HTML version deleted]] __

Re: [R] Trees (and Forests) with packages 'party' vs. 'partykit': Different results

2015-09-21 Thread apeshifter
Achim, thank you very much for your help, this really cleared up a number of issues. As for the differences in results between the party and partykit implementations of ctree, I guess that the situation is indeed as you assumed. Four out of five variables have p-values <2.2e-16. (However, it is

Re: [R] R-help, please

2015-09-21 Thread le4...@mweb.co.za
Good day, My name is Kim Nguyen and please I need your help with: How to calculate the PASS rate of the data in the table below, with PASS in a single subject if value>=50 and PASS will be given if PASS 3 out of 4 subjectsWhich package will I need to use in this analysis ID Literacy Maths

Re: [R] How to coerce a parameter in nls?

2015-09-21 Thread Jianling Fan
Thanks Gabor, That works good to rewrite the express the formula! Thanks a lot! Regards, Jianling On 21 September 2015 at 10:43, Gabor Grothendieck wrote: > Express the formula in terms of simple operations like this: > > # add 0/1 columns ref.1, ref.2, ..., ref.6 > dproot2 <- do.call(data.f

Re: [R] How to coerce a parameter in nls?

2015-09-21 Thread Gabor Grothendieck
Express the formula in terms of simple operations like this: # add 0/1 columns ref.1, ref.2, ..., ref.6 dproot2 <- do.call(data.frame, transform(dproot, ref = outer(dproot$ref, seq(6), "==") + 0)) # now express the formula in terms of the new columns library(nlmrt) fitdp1<-nlxb(den ~ (Rm1 * ref.1

Re: [R] How to coerce a parameter in nls?

2015-09-21 Thread Jianling Fan
Thanks Prof. Nash, Sorry for late reply. I am learning and trying to use your nlmrt package since I got your email. It works good to mask a parameter in regression but seems does work for my equation. I think the problem is that the parameter I want to mask is a group-specific parameter and I have

Re: [R] R code help!

2015-09-21 Thread SH
Hi Jean, Thank you so much! Steve On Sat, Sep 19, 2015 at 1:02 PM, Adams, Jean wrote: > Here's one way to save your results, using a list of lists and a for() > loop. > > nsim <- 100 > outputs <- vector("list", nsim) > for(i in 1:nsim) { > outputs[[i]] <- sim.f(p.s=.05, N=1000, sample.size=6

Re: [R] how to add 1 + 1 with the interface between R and C

2015-09-21 Thread peter dalgaard
> On 21 Sep 2015, at 04:03 , Cleber N.Borges wrote: > > Dear useRs, > > I would like some help on how to make the sum of 1 + 1 > but using the interface between A and C. > > the function call does .call lock and close the R. > > Thank you for any help it. Either you need a basic course in C,

[R] how to add 1 + 1 with the interface between R and C

2015-09-21 Thread Cleber N.Borges
Dear useRs, I would like some help on how to make the sum of 1 + 1 but using the interface between A and C. the function call does .call lock and close the R. Thank you for any help it. Cleber ### R code text_code <-" #include #include #include void testfun

Re: [R] HELP IN GRAPHS - slip screen (URGENT)

2015-09-21 Thread Jim Lemon
Hi Rosa, I think I understand more or less what you want, but the example below uses made up data as I do not have access to your files. The following code should produce a block of eight plots with the y axes on the leftmost plots only and the x axes on the bottom row only. I think I have what you

Re: [R] How to coerce a parameter in nls?

2015-09-21 Thread ProfJCNash
I posted a suggestion to use nlmrt package (function nlxb to be precise), which has masked (fixed) parameters. Examples in my 2014 book on Nonlinear parameter optimization with R tools. However, I'm travelling just now, or would consider giving this a try. JN On 15-09-20 01:19 PM, Jianling Fa

Re: [R] ERROR - non-conformable arguments

2015-09-21 Thread PIKAL Petr
Hi Do not use attachment, copy result of dput(object) to your mail instead. This enables us to see how your data really look like. I get different error. > widesII(used, available, avknown = TRUE, alpha = 0.05) Error in widesII(used, available, avknown = TRUE, alpha = 0.05) : used and availabl

[R] Fwd: gdal_translate and gdalwarp question

2015-09-21 Thread Antonio Silva
Hello, I have some doubts on the usage of some gdal tools. After converting a hdf file to tif I want to reproject to SIRGAS2000 and clip between lats of 22 to 29 S and lats of 40 to 50 W. HDF file can be downloaded at https://app.box.com/s/16cf7qv6af6gsz1v66staori2mtneu0r Basically I'm followin

Re: [R] ERROR - non-conformable arguments

2015-09-21 Thread Alexander Moßbrucker
Hi all, I am sorry I forgot to attach the excel file and txt files with the test data I used for this example. I am almost sure the problem was caused by the way R is reading this data, Hope to get some help, best, Alex 2015-09-20 14:03 GMT+07:00 Alexander Moßbrucker : > > Hi, > > I am usi