[R] Selecting data from list object
Hello Group, Is there a simpler way to get data out of a list object? (like in data frame without using the apply functions) I have the following dataset dput(d) list(c(20110405, 092102), c(20110405, 092538), c(20110405, 093458), c(20110405, 101124), c(20110405, 102041), c(20110405, 103659)) I extracted my data like this: getDate - function(x)(unlist(x[[1]])) unlist(lapply(d, getDate)) [1] 20110405 20110405 20110405 20110405 20110405 20110405 Isn't there an easier way to do this? Thanks, Santosh __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Selecting data from list object
Hi Santosh, One way would be sapply(d, [, 1) [1] 20110405 20110405 20110405 20110405 20110405 20110405 HTH, Jorge On Thu, Apr 7, 2011 at 2:14 AM, santosh wrote: Hello Group, Is there a simpler way to get data out of a list object? (like in data frame without using the apply functions) I have the following dataset dput(d) list(c(20110405, 092102), c(20110405, 092538), c(20110405, 093458), c(20110405, 101124), c(20110405, 102041), c(20110405, 103659)) I extracted my data like this: getDate - function(x)(unlist(x[[1]])) unlist(lapply(d, getDate)) [1] 20110405 20110405 20110405 20110405 20110405 20110405 Isn't there an easier way to do this? Thanks, Santosh __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Odp: Need a more efficient way to implement this type of logic in R
Hi r-help-boun...@r-project.org napsal dne 06.04.2011 22:02:29: I have cobbled together the following logic. It works but is very slow. I'm sure that there must be a better r-specific way to implement this kind of thing, but have been unable to find/understand one. Any help would be appreciated. hh.sub - households[c(HOUSEID,HHFAMINC)] for (indx in 1:length(hh.sub$HOUSEID)) { if ((hh.sub$HHFAMINC[indx] == '01') | (hh.sub$HHFAMINC[indx] == '02') | (hh.sub$HHFAMINC[indx] == '03') | (hh.sub$HHFAMINC[indx] == '04') | (hh.sub$HHFAMINC[indx] == '05')) hh.sub$CS_FAMINC[indx] - 1 # Less than $25,000 if ((hh.sub$HHFAMINC[indx] == '06') | (hh.sub$HHFAMINC[indx] == '07') | (hh.sub$HHFAMINC[indx] == '08') | (hh.sub$HHFAMINC[indx] == '09') | (hh.sub$HHFAMINC[indx] == '10')) hh.sub$CS_FAMINC[indx] - 2 # $25,000 to $50,000 if ((hh.sub$HHFAMINC[indx] == '11') | (hh.sub$HHFAMINC[indx] == '12') | (hh.sub$HHFAMINC[indx] == '13') | (hh.sub$HHFAMINC[indx] == '14') | (hh.sub$HHFAMINC[indx] == '15')) hh.sub$CS_FAMINC[indx] - 3 # $50,000 to $75,000 if ((hh.sub$HHFAMINC[indx] == '16') | (hh.sub$HHFAMINC[indx] == '17')) hh.sub$CS_FAMINC[indx] - 4 # $75,000 to $100,000 if ((hh.sub$HHFAMINC[indx] == '18')) hh.sub$CS_FAMINC[indx] - 5 # More than $100,000 if ((hh.sub$HHFAMINC[indx] == '-7') | (hh.sub$HHFAMINC[indx] == '-8') | (hh.sub$HHFAMINC[indx] == '-9')) hh.sub$CS_FAMINC[indx] = 0 } Take advantage of factors. If hh.sub$HHFAMINC was factor you can recode it by levels(hh.sub$HHFAMINC)-appropriate vector of new levels with the same length as levels Something like x-factor(letters[1:5]) x [1] a b c d e Levels: a b c d e levels(x)-c(1,1,2,2,1) x [1] 1 1 2 2 1 Levels: 1 2 Regards Petr __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Selecting data from list object
Hi Santosh, Try this: sapply(d, `[[`, i = 1) To answer your question about without using the apply functions, I think the answer is not really. Data frames are a type of list, so if you can assume that it is reasonable to extract the same element from every element of your list, that is for j = 1, ... n list elements, and i = 1, ... , k elements in each list element j, if k is identical across all n list elements, then you can simply reshape the list into a (i, j) data frame and extract based on rows or columns. To the extent that all i may not exist in all j, attempting to extract the ith element from every j list element becomes questionable. You may know certain properties of your list (e.g., k varies across j, but k = 4, so it would always be defined for 1 = i = 4), that make what you want to do logical and reliable, but there are not the general methods as in data frames, matrices, or arrays for extracting based on a particular dimension (all of row one, etc.). For some things you can use: d[[c(1, 1)]] which is equivalent to j = 1, i = 1. There is also list method for as.data.frame so in your example, you could do: as.data.frame(d) or as.data.frame(d)[1, ] so long as your data was conformable. Cheers, Josh On Wed, Apr 6, 2011 at 11:14 PM, santosh santosh.srini...@gmail.com wrote: Hello Group, Is there a simpler way to get data out of a list object? (like in data frame without using the apply functions) I have the following dataset dput(d) list(c(20110405, 092102), c(20110405, 092538), c(20110405, 093458), c(20110405, 101124), c(20110405, 102041), c(20110405, 103659)) I extracted my data like this: getDate - function(x)(unlist(x[[1]])) unlist(lapply(d, getDate)) [1] 20110405 20110405 20110405 20110405 20110405 20110405 Isn't there an easier way to do this? Thanks, Santosh __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Joshua Wiley Ph.D. Student, Health Psychology University of California, Los Angeles http://www.joshuawiley.com/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] ROCR - best sensitivity/specificity tradeoff?
Christian, My questions concerns the ROCR package and I hope somebody here on the list can help - or point me to some better place. When evaluating a model's performane, like this: pred1- predict(model, ..., type=response) pred2- prediction(pred1, binary_classifier_vector) perf- performance(pred, sens, spec) (Where prediction and performance are ROCR-functions.) How can I then retrieve the cutoff value for the sensitivity/specificity tradeoff with regard to the data in the model (e.g. model = glm(binary_classifier_vector ~ data, family=binomial, data=some_dataset)? Perhaps I missed something in the manual? Or do I need an entirely different approach for this? Or is there an alternative solution? a) look into the performance object, you find all values there b) have a look at this thread https://stat.ethz.ch/pipermail/r-help/attachments/20100523/51ec813f/attachment.pl http://finzi.psych.upenn.edu/Rhelp10/2010-May/240021.html http://finzi.psych.upenn.edu/Rhelp10/2010-May/240043.html Claudia __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Lars package
Hello, I am a student of IIT Bombay and I am using lars for one of my projects. I wanted to enquire if lars is using C under the hood. Is it true? Can someone point me to the corresponding C function? Thank You very much. Regards, Achin Bansal __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] How can I include a new book on the Books link at R-project.org ?
I've just published a new book for R beginners in Portuguese: Conhecendo o R: uma visão estatística (something like Knowing R: an statistical approach). I'd like to include it on the list Books at R-project.org. How can I do it? More informations about the book at http://www.editoraufv.com.br/produtos/conhecendo-o-r -- Marcio Pupin Mello Survey Engineer Ph.D student in Remote Sensing National Institute for Space Research (INPE) - Brazil Laboratory of Remote Sensing in Agriculture and Forestry (LAF) www.dsr.inpe.br/~mello __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] force output dimension of table function
You can do it using factor: s0-factor(0:5) s1-sample(s0,5,re=T) s1 [1] 0 2 2 4 0 Levels: 0 1 2 3 4 5 table(s1) s1 0 1 2 3 4 5 2 0 2 0 1 0 Good luck! -- Marcio Pupin Mello Survey Engineer Ph.D student in Remote Sensing National Institute for Space Research (INPE) - Brazil Laboratory of Remote Sensing in Agriculture and Forestry (LAF) www.dsr.inpe.br/~mello Em 4/7/2011 12:37 AM, fisken escreveu: I have a small annoying problem. When I use the 'table' function on a simple vector it counts the number of occurences. So depending on the values of my input vector the function returns a class of type table with different lengths. Is there an easy way to tell the table function, the values to expect? That is # set.seed(0) s-sample(0:5,5,rep=T) s [1] 5 1 2 3 5 ts-table(s) ts s 1 2 3 5 1 1 1 2 ## And what I wanted was 0 1 2 3 4 5 0 1 1 1 0 2 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] R licence
Hi, is it possible to use some statistic computing by R in proprietary software? Our software is written in c#, and we intend to use http://rdotnet.codeplex.com/ to get R work there. Especially we want to use loess function. Thanks, Best regards, Stanislav [[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] Two questions about metacharacter in regexprs and function return
for the script, please kindly see the script below. At line 10 and line 13, my problems occurs. The first one is I try to retrieve the gene official name from a column of a table. The pattern of official name is something starting with gene_name. For detail problems, please see the according lines. Any suggestions are appreciated example of matching source (extract the Nnat, sometime it would be the character N/A): AB004048|MM8;NCBI Build 36|transcript|chr2|157251580|157253958|ExemplarFor 'AB004048'; gene_id '18111'; transcript_id 'AB004048'; gene_name 'Nnat'; alt '5730414I02Rik|AW107673|Peg5'; neuronatin|http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?db=genecmd=Retrievedopt=full_reportlist_uids=18111; #obtain the exprs matrix for cluster analysis #ask questions DEG_files - grep(bak, dir());#pay attention to the filenames exprs_files - grep(copy, dir()); protein - c(); assign_exprs - function(files, protein) { #use to find the DEGs or exprs for cmeans clustering for(i in 1:length(files)) { microarray_data - read.csv(file = files[i], header = T, sep = \t); microarray_data[, 7] - gsub(([\\s\\S]+gene_name '(\\w*)';.+), \\2, microarray_data[, 7], perl = T);#why [\\w]* cannot workable? also the [(\\w*)(N/A)] cannot be workable. assign(files[i], microarray_data, envir=.GlobalEnv); #get(dir()[i]() can obtain the data of interest.`variable_names` can also work protein - c(protein, get(files[i])[, 7]); #used for obtain all the DEGs only } #return protein; #why this line is not workable? assign(all_protein, protein, envir=.GlobalEnv); } exist_to_cluster_exprs - function(x, cluster_exprs, all) { if(exists(all, x[1])){ #exists function cluster_exprs - cbind(cluster_exprs, x); } #return cluster_exprs; } assign_exprs(dir()[DEG_files], protein); all_protein - unique(all_protein); assign_exprs(dir()[exprs_files], protein); for(i in 1:2) { apply(get(dir()[exprs_files[i]]), 1, exist_to_cluster_exprs, cluster_exprs, all); #assign(paste(exprs_files()[i], exprs_data), cluster_exprs[, c(2, 3, 5, 7)]; exprs_data - cbind(exprs_data, cluster_exprs[, 3]); } exprs_data; -- View this message in context: http://r.789695.n4.nabble.com/Two-questions-about-metacharacter-in-regexprs-and-function-return-tp3432692p3432692.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] force output dimension of table function
On Thu, Apr 07, 2011 at 05:37:08AM +0200, fisken wrote: When I use the 'table' function on a simple vector it counts the number of occurences. So depending on the values of my input vector the function returns a class of type table with different lengths. Is there an easy way to tell the table function, the values to expect? And what I wanted was 0 1 2 3 4 5 0 1 1 1 0 2 The solution using factos has already been posted. if you are really interested in integers only you could also use tabulate(): tabulate(s) [1] 1 1 1 0 2 Note that this excludes zero, though. cu Philipp -- Dr. Philipp Pagel Lehrstuhl für Genomorientierte Bioinformatik Technische Universität München Wissenschaftszentrum Weihenstephan Maximus-von-Imhof-Forum 3 85354 Freising, Germany http://webclu.bio.wzw.tum.de/~pagel/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] set locale information in R
Hi R-helpers, Is it possible to localise the error messages/warnings that comes from R.My application takes in a locale information.I used the following command to set the locale in R.But in RGui, i still get the error messages in English only.Can you please help me out with this? Sys.setlocale(LC_ALL, French) Regards, Raji -- View this message in context: http://r.789695.n4.nabble.com/set-locale-information-in-R-tp3432760p3432760.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R licence
On Thu, Apr 7, 2011 at 9:45 AM, Stanislav Bek stanislav.pavel@gmail.com wrote: Hi, is it possible to use some statistic computing by R in proprietary software? I don't know if this covers your case, but SAS and SPSS provide interfaces to R. Regards Liviu Our software is written in c#, and we intend to use http://rdotnet.codeplex.com/ to get R work there. Especially we want to use loess function. Thanks, Best regards, Stanislav [[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. -- Do you know how to read? http://www.alienetworks.com/srtest.cfm http://goodies.xfce.org/projects/applications/xfce4-dict#speed-reader Do you know how to write? http://garbl.home.comcast.net/~garbl/stylemanual/e.htm#e-mail __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] plot layout with several plots ON plot area of previous plot
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hi I would like to have a plot layout, on which line graphs are on the plot area of an underlying bar graph. How can I achieve this? I know about layout() and par() to create a layout, but as far as I know, they assign non-overlapping plot areas. Effectively, it should look as below: || || | |---| |---| | | | | | | | | | | | | | | |-L-| |-L-| | || || || || || || |-the bargraph---| L: the line graphs Any help appreciated, Rainer - -- Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany) Centre of Excellence for Invasion Biology Natural Sciences Building Office Suite 2039 Stellenbosch University Main Campus, Merriman Avenue Stellenbosch South Africa Tel:+33 - (0)9 53 10 27 44 Cell: +27 - (0)8 39 47 90 42 Fax (SA): +27 - (0)8 65 16 27 82 Fax (D) : +49 - (0)3 21 21 25 22 44 Fax (FR): +33 - (0)9 58 10 27 44 email: rai...@krugs.de Skype: RMkrug -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk2dg3UACgkQoYgNqgF2egpegwCfbqQP19qZqyof21+rA9Cbn+Vf UKcAnAgl6AoUNcygx/sSaMcYV+zoum/S =9/P0 -END PGP SIGNATURE- __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] plot layout with several plots ON plot area of previous plot
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 07/04/11 11:27, Rainer M Krug wrote: Hi I would like to have a plot layout, on which line graphs are on the plot area of an underlying bar graph. How can I achieve this? I know about layout() and par() to create a layout, but as far as I know, they assign non-overlapping plot areas. Sorry - did not do my homework and forgot to google - found the solution (http://tolstoy.newcastle.edu.au/R/help/04/11/6449.html). But an additional question - uis there a way to position the plots in relation to the co-ordinates of the first plot, i.e. the x axis of the first plot (ehich covers the whole plot area) is from 1 to 6 - can I position the second overlapping plot over the x-coordinate 3 of the first plot? Rainer Effectively, it should look as below: || || | |---| |---| | | | | | | | | | | | | | | |-L-| |-L-| | || || || || || || |-the bargraph---| L: the line graphs Any help appreciated, Rainer - -- Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany) Centre of Excellence for Invasion Biology Natural Sciences Building Office Suite 2039 Stellenbosch University Main Campus, Merriman Avenue Stellenbosch South Africa Tel:+33 - (0)9 53 10 27 44 Cell: +27 - (0)8 39 47 90 42 Fax (SA): +27 - (0)8 65 16 27 82 Fax (D) : +49 - (0)3 21 21 25 22 44 Fax (FR): +33 - (0)9 58 10 27 44 email: rai...@krugs.de Skype: RMkrug -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk2dhmMACgkQoYgNqgF2egqysACeMJ0nl81wSBlr8w4s7sM2Zo2k gvUAnjTlzoFoOnDHPzbziRAbS/8MbV0p =LYr+ -END PGP SIGNATURE- __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R licence
On Apr 7, 2011, at 09:45 , Stanislav Bek wrote: Hi, is it possible to use some statistic computing by R in proprietary software? Our software is written in c#, and we intend to use http://rdotnet.codeplex.com/ to get R work there. Especially we want to use loess function. You need to take legal advice to be certain, but offhand I would say that this kind of circumvention of the GPL is _not_ allowed. It all depends on whether the end product is a derivative work, in which case, the whole must be distributed under a GPL-compatible licence. The situation around GPL-incompatible plug-ins or plug-ins interfacing to R in GPL -incompatible software is legally murky, but using R as a subroutine library for proprietary code is clearly crossing the line, as far as I can tell. -- Peter Dalgaard 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] plot layout with several plots ON plot area of previous plot
On 04/07/2011 07:39 PM, Rainer M Krug wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 07/04/11 11:27, Rainer M Krug wrote: Hi I would like to have a plot layout, on which line graphs are on the plot area of an underlying bar graph. How can I achieve this? I know about layout() and par() to create a layout, but as far as I know, they assign non-overlapping plot areas. Sorry - did not do my homework and forgot to google - found the solution (http://tolstoy.newcastle.edu.au/R/help/04/11/6449.html). But an additional question - uis there a way to position the plots in relation to the co-ordinates of the first plot, i.e. the x axis of the first plot (ehich covers the whole plot area) is from 1 to 6 - can I position the second overlapping plot over the x-coordinate 3 of the first plot? Rainer Effectively, it should look as below: || || | |---| |---| | | | | | | | | | | | | | | |-L-| |-L-| | || || || || || || |-the bargraph---| L: the line graphs Hi Rainer, I think you want the subplot function in the TeachingDemos package. Jim __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] [R-pkgs] [R-package] PredictABEL 1.1: Assessment of risk prediction models in R
Dear R users, A new R package (PredictABEL, http://cran.at.r-project.org/web/packages/PredictABEL/ ) has been published recently that includes functions to assess the performance of (genetic) risk models. The package provides the following measures: Univariate and multivariate odds ratios (OR) of the predictors The c-statistic (or area under the receiver operating characteristic (ROC) curve (AUC)) Hosmer-Lemeshow goodness of fit test Reclassification table Net reclassification improvement (NRI) Integrated discrimination improvement (IDI) You can find more information in our paper [1] and on PredictABEL website http://www.genabel.org/packages/PredictABEL Hope you'll find it useful! Suman Kundu --- References: [1] http://www.ncbi.nlm.nih.gov/pubmed/21431839 [[alternative HTML version deleted]] ___ R-packages mailing list r-packa...@r-project.org https://stat.ethz.ch/mailman/listinfo/r-packages __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] plot layout with several plots ON plot area of previous plot
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 07/04/11 12:53, Jim Lemon wrote: On 04/07/2011 07:39 PM, Rainer M Krug wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 07/04/11 11:27, Rainer M Krug wrote: Hi I would like to have a plot layout, on which line graphs are on the plot area of an underlying bar graph. How can I achieve this? I know about layout() and par() to create a layout, but as far as I know, they assign non-overlapping plot areas. Sorry - did not do my homework and forgot to google - found the solution (http://tolstoy.newcastle.edu.au/R/help/04/11/6449.html). But an additional question - uis there a way to position the plots in relation to the co-ordinates of the first plot, i.e. the x axis of the first plot (ehich covers the whole plot area) is from 1 to 6 - can I position the second overlapping plot over the x-coordinate 3 of the first plot? Rainer Effectively, it should look as below: || || | |---| |---| | | | | | | | | | | | | | | |-L-| |-L-| | || || || || || || |-the bargraph---| L: the line graphs Hi Rainer, I think you want the subplot function in the TeachingDemos package. Exactly - why is such a gem of a function hiding in a package with Demos in the name? I would never have thought about that. Thanks a lot, Rainer Jim - -- Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany) Centre of Excellence for Invasion Biology Natural Sciences Building Office Suite 2039 Stellenbosch University Main Campus, Merriman Avenue Stellenbosch South Africa Tel:+33 - (0)9 53 10 27 44 Cell: +27 - (0)8 39 47 90 42 Fax (SA): +27 - (0)8 65 16 27 82 Fax (D) : +49 - (0)3 21 21 25 22 44 Fax (FR): +33 - (0)9 58 10 27 44 email: rai...@krugs.de Skype: RMkrug -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk2di+YACgkQoYgNqgF2egqR2ACdE8w+uvtDXtd09ml3L3DYwtas uesAn3emEYA7679U4Z7RfZO80T0p0pZ/ =iRDW -END PGP SIGNATURE- __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] understanding randomForest results
How do I read/interpret the output of varImpPlot() for a randomForest object? Regards, Divya [[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] plot layout with several plots ON plot area of previous plot
On 04/07/2011 08:03 PM, Rainer M Krug wrote: ... Exactly - why is such a gem of a function hiding in a package with Demos in the name? I would never have thought about that. Maybe Greg thought it was a package for the people. 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] predict fGarch doubt
Hello I am using the predict method in fGarch. I tried to replicate what I supposed it was doing when I estimated an ARMA(2,2)+GARCH(1,1) by doing: (temp is my ouput form garchFit) fit = temp@fit$par Nobs = length(temp@data) # Predecir media fit[mu]+sum(fit[2:(2+2-1)]*temp@data[length(temp@data):(length(temp@data )-2+1)]),0)+ sum(fit[(2+2):(2+2+o2-1)]*temp@residuals[length(temp@residuals ):(length(temp@residuals)-2+1)]),0) and I got -0.005585084 while the output from the predict method gave me -0.00752829. Does anybody know what might be going on? am I using the wrong slots in the output? Thank you Felipe Parra [[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] plot layout with several plots ON plot area of previous plot
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 07/04/11 13:09, Jim Lemon wrote: On 04/07/2011 08:03 PM, Rainer M Krug wrote: ... Exactly - why is such a gem of a function hiding in a package with Demos in the name? I would never have thought about that. Maybe Greg thought it was a package for the people. Nothing to add :-) Rainer Jim - -- Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany) Centre of Excellence for Invasion Biology Natural Sciences Building Office Suite 2039 Stellenbosch University Main Campus, Merriman Avenue Stellenbosch South Africa Tel:+33 - (0)9 53 10 27 44 Cell: +27 - (0)8 39 47 90 42 Fax (SA): +27 - (0)8 65 16 27 82 Fax (D) : +49 - (0)3 21 21 25 22 44 Fax (FR): +33 - (0)9 58 10 27 44 email: rai...@krugs.de Skype: RMkrug -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk2dkTQACgkQoYgNqgF2egoDlQCeLqIYerpiuIdsACLwq/PwpTkX v6gAn3ELKBe5StvYvL6/Iq9JpMumPyu8 =HNIS -END PGP SIGNATURE- __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to speed up grouping time series, help please
I found a faster implementation (by an order of magnitude from my tests) than the one using xts, split, merge (from Joshua). I report the two fastest solution below with code to generate a test case; some work still to be done for columns order and naming, Test case has grown from my previous post to get a more realistic timing. Any comment or idea to further speed up multivariate time series creation with classes xts or timeSeries starting from a data.frame like the one reported here is welcome. Best regards, Den a data.frame example (code below to generate it) IDDATE VALUE 14 3 2000-01-01 00:00:03 0.5726334 4 1 2000-01-01 00:00:03 0.8830174 1 1 2000-01-01 00:00:00 0.2875775 15 3 2000-01-01 00:00:04 0.1029247 11 3 2000-01-01 00:00:00 0.9568333 9 2 2000-01-01 00:00:03 0.5514350 7 2 2000-01-01 00:00:01 0.5281055 6 2 2000-01-01 00:00:00 0.0455565 12 3 2000-01-01 00:00:01 0.4533342 8 2 2000-01-01 00:00:02 0.8924190 3 1 2000-01-01 00:00:02 0.4089769 13 3 2000-01-01 00:00:02 0.6775706 And I want to get a timeSeries object or xts object like this: 1 2 3 2000-01-01 00:00:00 0.2875775 0.0455565 0.9568333 2000-01-01 00:00:01NA 0.5281055 0.4533342 2000-01-01 00:00:02 0.4089769 0.8924190 0.6775706 2000-01-01 00:00:03 0.8830174 0.5514350 0.5726334 2000-01-01 00:00:04NANA 0.1029247 # CODE: set.seed(123) # set N to 5 to reproduce above data.frame N - 1000 # set K to 3 to reproduce above data.frame K - 10 X - data.frame( ID = rep(1:K, each = N), DATE = as.character(rep(as.POSIXct(2000-01-01, tz = GMT)+ 0:(N-1), K)), VALUE = runif(N*K), stringsAsFactors = FALSE) X - X[sample(1:(N*K), N*K),] X - X[-(sample(1:nrow(X), floor(nrow(X)*0.2))),] str(X) xtsSplit - function(x) { library(xts) x - xts(x[,c(ID,VALUE)], as.POSIXct(x[,DATE])) return(do.call(merge, split(x$VALUE,x$ID))) } xtsSplitTime - replicate(50, system.time(xtsSplit(X))[[1]]) median(xtsSplitTime) xtsReshape - function(x) { library(xts) x - reshape(x, idvar = DATE, timevar = ID, direction = wide) x - xts(x[,-1], as.POSIXct(x[,1])) return(x) } xtsReshapeTime - replicate(50, system.time(xtsReshape(X))[[1]]) median(xtsReshapeTime) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Hypercluster Finder Function in R
Dear R Users I am looking at carrying out Multivariate Supervised Discretization on a set of continuous attributes to determine cut off values on each attribute which would allow best explanation of a binary outcome variable. I understand that there is an algorithm for doing this (The HyperCluster Finder Algorithm from the paper -Muhlenbach F., Rakotomalala R. (2002). Multivariate Supervised Discretization, a Neighborhood Graph Approach. Proceedings of the 1st IEEE International Conference on Data Mining (ICDM-2002), 314-321.) I donot know if this implementation is available in R already Does someone know if there is any package that exists for running this algorithm? or does anybody have a function developed on this basis? Thanks Regards Vijayan Padmanabhan What is expressed without proof can be denied without proof - Euclide. Please visit us at www.itcportal.com ** This Communication is for the exclusive use of the intended recipient (s) and shall not attach any liability on the originator or ITC Ltd./its Subsidiaries/its Group Companies. If you are the addressee, the contents of this email are intended for your use only and it shall not be forwarded to any third party, without first obtaining written authorisation from the originator or ITC Ltd./its Subsidiaries/its Group Companies. It may contain information which is confidential and legally privileged and the same shall not be used or dealt with by any third party in any manner whatsoever without the specific consent of ITC Ltd./its Subsidiaries/its Group Companies. [[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] extract variance for random effects from mer object
I get an output from a glmer package, but would like to extract the variance of the Random effects, in this case called trtpair and the value is 0. Can I extract it directly or do I need to do some further calculations on the mer object to get it? Thanks Jim class(fednmaout) [1] mer attr(,package) [1] lme4 fednmaout Generalized linear mixed model fit by the Laplace approximation Formula: cbind(fednmadat$events, fednmadat$patnums - fednmadat$events) ~ treat + tn + (1 | trtpair) AIC BIC logLik deviance 84.01 153.1 -9.00618.01 Random effects: Groups NameVariance Std.Dev. trtpair (Intercept) 00 Number of obs: 60, groups: trtpair, 3 === Dr. Jim Maas University of East Anglia __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Time series of spatial data
Hi guys, I'm really new in R. Trying to analyze series of spatial datasets (365 satellite images) in order to find the best model that fit the data. Any suggestion which package that could help me? Thanks in advance. Cheers -- View this message in context: http://r.789695.n4.nabble.com/Time-series-of-spatial-data-tp3432979p3432979.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Ports for communicating with R-mirros sites?
On 11-04-06 10:55 PM, Debraj GuhaThakurta wrote: Hi, I have been having an error since past couple of days to connect to several of the mirror sites. I wonder if anyone knows the port/s for communicating with the R-mirror sites for downloading packages. If we know this we may be able to figure the problem at our end. Just the standard http port 80, unless they advertise something else like ftp, etc. Duncan Murdoch Debraj Debraj GuhaThakurta Email: d_guhathaku...@hotmail.com [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] set locale information in R
Hi Rhelpers, Do we need to install some font packages in R for the locale information to take effect. Alternatively, i found that we can use the following command for the messages Sys.setlocale(LC_MESSAGES,French) Should this be done for getting error messages in French? The help for setLocale says that the LC_MESSAGES cannot be set for Windows. Can you please let me know how i can get the error messages in the locale set? Please do apologize if i am missing something obvious here. Thanks, Raji -- View this message in context: http://r.789695.n4.nabble.com/set-locale-information-in-R-tp3432760p3432952.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] extract variance for random effects from mer object
Maas James Dr (MED J.Maas at uea.ac.uk writes: I get an output from a glmer package, but would like to extract the variance of the Random effects, in this case called trtpair and the value is 0. [snip] fednmaout Generalized linear mixed model fit by the Laplace approximation Formula: cbind(fednmadat$events, fednmadat$patnums - fednmadat$events) ~ treat + tn + (1 | trtpair) AIC BIC logLik deviance 84.01 153.1 -9.00618.01 Random effects: Groups NameVariance Std.Dev. trtpair (Intercept) 00 Number of obs: 60, groups: trtpair, 3 VarCorr(fednmaout)[[1]] (the [[1]] means to extract the variance for the first (and only in this case) random effect.) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] comparing ARIMA model to data
hi, i am trying to teach myself about ARIMA models. i have followed examples from a number of sources and have more or less got the hang of how it works. i would like to compare the output from the fitted model to the original data. is this possible? or even a meaningful thing to do? to be clear, for example, having generated a fit to some data using fit - arima(LakeHuron, order = c(1, 0, 1)) and then plotting the data with plot(LakeHuron) is it possible to overlay the output of the model on the original data to compare how well it captures the variations in the data? i know that predict can be used to extrapolate beyond the end of the data series, but i want to evaluate the model within (not beyond) the original data. best regards, andrew. -- Andrew B. Collier Physicist Waves and Space Plasmas Group Hermanus Magnetic Observatory Honorary Senior Lecturer tel: +27 31 2601157 Space Physics Research Institute fax: +27 31 2607795 University of KwaZulu-Natal, Durban, South Africagsm: +27 83 3813655 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How can I include a new book on the
Marcio Pupin Mello mello at ieee.org writes: I've just published a new book for R beginners in Portuguese: Conhecendo o R: uma visão estatística (something like Knowing R: an statistical approach). I'd like to include it on the list Books at R-project.org. How can I do it? More informations about the book at http://www.editoraufv.com.br/produtos/conhecendo-o-r I think you should try contacting Kurt Hornik at r-project.org __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Two functions as parametrs of a function.
Hi R users: I'm trying to make a function where two of the parameters are functions, but I don't know how to put each set of parameters for each function. What am I missing? I try this code: f2-function(n=2,nsim=100,fun1=rnorm,par1=list(),fun2=rnorm,par2=list()){ force(fun1) force(fun2) force(n) p1-unlist(par1) p2-unlist(par2) force(p1) force(p2) localfun1 - function() fun1(n, p1) localfun2 - function() fun2(n, p2) vp-replicate(nsim,t.test(localfun1(), localfun2())$p.value) return(vp) } f2(fun1=rbeta,par1=list(shape1=2,shape2=2),fun2=rbeta,par2=list(shape1=1,shape2=2)) Thank you for your help. Kenneth __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Scrap java scripts and styles from an html document
Hi , I am working on developing a web crawler. Removing javascripts and styles is a part of the cleaning of the html document. What I want is a cleaned html document with only the html tags and textual information, so that i can figure out the pattern of the web page. This is being done to extract relevant information from the webpage like comments for a particular product. For e.g the amazon.com has all such comments within the and tags, with regular occuring for breaks. So tags which appear the most help us in locating the required information. Different websites have different patterns, but its more likely that tags that will occur the most will have the relevant information enclosed in them. So, once the html page is cleaned, it would be easy to role up the tags and knowing their frequency of occurrence, we can target the information. Should there be any suggestions to help, please let me know. I would be more than pleased. Regards, Antuj -- View this message in context: http://r.789695.n4.nabble.com/Scrap-java-scripts-and-styles-from-an-html-document-tp3413894p3433052.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Quasipoisson with geeglm
Dear all, I am trying to use the GEE methodology to fit a trend for the number of butterflies observed at several sites. In total, there are 66 sites, and 19 years for which observations might be available. However, only 326 observations are available (instead of 1254). For the time being, I ignore the large number of missing values, and the fact that GEE is only valid under MCAR. When I run the following code geeglm(SumOfButterflies ~ RES_YEAR, family = poisson, data = ManijurtNoNA, id = RES_ROTE_ID, corstr = ar1) I obtain normal output. Not surprisingly, overdispersion is present (Estimated Scale Parameters: [1] 185.8571), so changing to quasipoisson is needed. However, the code below geeglm(SumOfButterflies ~ RES_YEAR, family = quasipoisson, data = ManijurtNoNA, id = RES_ROTE_ID, corstr = ar1) produces the following error Error in geese.fit(xx, yy, id, offset, soffset, w, waves = waves, zsca, : variance invalid. Other correlation structures encounter the same problem. I also tried adding waves = RES_YEAR (although I am not sure how waves should be used correctly), but it does not change anything. Any suggestions what might be wrong? Regards, Ivy [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R licence
Peter, If the proprietary part of REvolution's product is ok, then surely Stanislav's suggestion is too. No? Matthew peter dalgaard pda...@gmail.com wrote in message news:be157cf5-9b4b-45a0-a7d4-363b774f1...@gmail.com... On Apr 7, 2011, at 09:45 , Stanislav Bek wrote: Hi, is it possible to use some statistic computing by R in proprietary software? Our software is written in c#, and we intend to use http://rdotnet.codeplex.com/ to get R work there. Especially we want to use loess function. You need to take legal advice to be certain, but offhand I would say that this kind of circumvention of the GPL is _not_ allowed. It all depends on whether the end product is a derivative work, in which case, the whole must be distributed under a GPL-compatible licence. The situation around GPL-incompatible plug-ins or plug-ins interfacing to R in GPL -incompatible software is legally murky, but using R as a subroutine library for proprietary code is clearly crossing the line, as far as I can tell. -- Peter Dalgaard 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] Two functions as parametrs of a function.
On 07/04/2011 7:45 AM, Kenneth Roy Cabrera Torres wrote: Hi R users: I'm trying to make a function where two of the parameters are functions, but I don't know how to put each set of parameters for each function. What am I missing? I try this code: f2-function(n=2,nsim=100,fun1=rnorm,par1=list(),fun2=rnorm,par2=list()){ force(fun1) force(fun2) force(n) p1-unlist(par1) p2-unlist(par2) You don't want to unlist those. Leave them as lists, and use the do.call() function for the calls. For example, localfun1 - function() do.call(fun1, c(list(n), par1)) force(p1) force(p2) Calling force() is only useful for arguments to your function: it kicks the evaluator, so it's not so lazy. Since p1 and p2 were calculated earlier, there's no need to force them. You might need to force n, since it is only used in the localfun1 and localfun2 calls, and if the argument to f2 changes before you make those calls, the wrong value will be used. That's pretty unlikely with your code, but since fun1 and fun2 can do anything, it's safest to fix the value of n before you call them. The same argument applies to fun1 and fun2 themselves. Duncan Murdoch localfun1- function() fun1(n, p1) localfun2- function() fun2(n, p2) vp-replicate(nsim,t.test(localfun1(), localfun2())$p.value) return(vp) } f2(fun1=rbeta,par1=list(shape1=2,shape2=2),fun2=rbeta,par2=list(shape1=1,shape2=2)) Thank you for your help. Kenneth __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Two functions as parametrs of a function.
Try this: f2 - function(n, nsim, fun1, fun2) { vp - replicate(nsim, do.call(fun1$name, c(n, fun1$args)), do.call(fun1$name, c(n, fun1$args))) vp } f2(2, 100, fun1 = list(name = rbeta, args = list(shape1 = 2, shape2 = 2), fun1 = list(name = rbeta, args = list(shape1 = 2, shape2 = 2 On Thu, Apr 7, 2011 at 8:45 AM, Kenneth Roy Cabrera Torres krcab...@une.net.co wrote: Hi R users: I'm trying to make a function where two of the parameters are functions, but I don't know how to put each set of parameters for each function. What am I missing? I try this code: f2-function(n=2,nsim=100,fun1=rnorm,par1=list(),fun2=rnorm,par2=list()){ force(fun1) force(fun2) force(n) p1-unlist(par1) p2-unlist(par2) force(p1) force(p2) localfun1 - function() fun1(n, p1) localfun2 - function() fun2(n, p2) vp-replicate(nsim,t.test(localfun1(), localfun2())$p.value) return(vp) } f2(fun1=rbeta,par1=list(shape1=2,shape2=2),fun2=rbeta,par2=list(shape1=1,shape2=2)) Thank you for your help. Kenneth __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40 S 49° 16' 22 O __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R licence
The licences are available on the web site and you really should have yor lawyers look at them and give you professional advise. The GPL2+ is probably the relevant one for your purposes and essentially require you to provide the source for the parts of R that you distribute. However, the R licencing is a mess with core packages not on a GPL licence. We looked into it and it is a nightmare and I don't even think the UK CRAN mirrors are strictly speaking legal. So look carefully at what you use and get advice from somewhere other than a mailing list. happy to discuss the UK side of things offline if you want, but I never looked at other jurisdictions. Allan - Original message - Hi, is it possible to use some statistic computing by R in proprietary software? Our software is written in c#, and we intend to use http://rdotnet.codeplex.com/ to get R work there. Especially we want to use loess function. Thanks, Best regards, Stanislav    [[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] Lars package
On Apr 7, 2011, at 3:43 AM, ac...@cse.iitb.ac.in wrote: Hello, I am a student of IIT Bombay and I am using lars for one of my projects. I wanted to enquire if lars is using C under the hood. Is it true? Can someone point me to the corresponding C function? Thank You very much. If you just type lars at the console (after loading the package) , you will see the uncommented code. Most of R has C (or Fortran) under the hood, so there may be a semantic problem in answering that direct question. You can get the full source on any CRAN mirror. -- David Winsemius, MD West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R licence
On 07/04/2011 7:47 AM, Matthew Dowle wrote: Peter, If the proprietary part of REvolution's product is ok, then surely Stanislav's suggestion is too. No? Revolution has said that they believe they follow the GPL, and they haven't been challenged on that. If you think that they don't, you could let an R copyright holder know what they're doing that's a license violation. My opinion of Stanislav's question is that he doesn't give enough information to answer. If he is planning to distribute R as part of his product, he needs to follow the GPL. If not, I don't think any R copyright holder has anything to complain about. Duncan Murdoch Matthew peter dalgaardpda...@gmail.com wrote in message news:be157cf5-9b4b-45a0-a7d4-363b774f1...@gmail.com... On Apr 7, 2011, at 09:45 , Stanislav Bek wrote: Hi, is it possible to use some statistic computing by R in proprietary software? Our software is written in c#, and we intend to use http://rdotnet.codeplex.com/ to get R work there. Especially we want to use loess function. You need to take legal advice to be certain, but offhand I would say that this kind of circumvention of the GPL is _not_ allowed. It all depends on whether the end product is a derivative work, in which case, the whole must be distributed under a GPL-compatible licence. The situation around GPL-incompatible plug-ins or plug-ins interfacing to R in GPL -incompatible software is legally murky, but using R as a subroutine library for proprietary code is clearly crossing the line, as far as I can tell. -- Peter Dalgaard 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-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] comparing ARIMA model to data
Hello Andrew, There are some parameters associated with the o/p of arima(), In your case fit. If one search for help(arima) , Values like sigma2,var.coef,loglik, aic will give you some information regarding how good the model is. If you want to overlay the output, you have to produce the output and you already know predict(). regards. On 7 April 2011 17:04, Andrew Collier collie...@gmail.com wrote: hi, i am trying to teach myself about ARIMA models. i have followed examples from a number of sources and have more or less got the hang of how it works. i would like to compare the output from the fitted model to the original data. is this possible? or even a meaningful thing to do? to be clear, for example, having generated a fit to some data using fit - arima(LakeHuron, order = c(1, 0, 1)) and then plotting the data with plot(LakeHuron) is it possible to overlay the output of the model on the original data to compare how well it captures the variations in the data? i know that predict can be used to extrapolate beyond the end of the data series, but i want to evaluate the model within (not beyond) the original data. best regards, andrew. -- Andrew B. Collier Physicist Waves and Space Plasmas Group Hermanus Magnetic Observatory Honorary Senior Lecturer tel: +27 31 2601157 Space Physics Research Institute fax: +27 31 2607795 University of KwaZulu-Natal, Durban, South Africagsm: +27 83 3813655 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Amar Kumar Nandan Karnataka, India, 560100 http://aknandan.co.nr [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R licence
On 07/04/2011 8:07 AM, Allan Engelhardt wrote: The licences are available on the web site and you really should have yor lawyers look at them and give you professional advise. The GPL2+ is probably the relevant one for your purposes and essentially require you to provide the source for the parts of R that you distribute. I think it's stronger than that (requiring the source for everything if you include any GPL'd bits), but your first paragraph is good advice. Duncan Murdoch However, the R licencing is a mess with core packages not on a GPL licence. We looked into it and it is a nightmare and I don't even think the UK CRAN mirrors are strictly speaking legal. So look carefully at what you use and get advice from somewhere other than a mailing list. happy to discuss the UK side of things offline if you want, but I never looked at other jurisdictions. Allan - Original message - Hi, is it possible to use some statistic computing by R in proprietary software? Our software is written in c#, and we intend to use http://rdotnet.codeplex.com/ to get R work there. Especially we want to use loess function. Thanks, Best regards, Stanislav    [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Automated Fixed Order Stepwise Regression Function
Greetings, I am interested in creating a stepwise fixed order regression function. There's a function for this already called add1( ). The F statistics are calculated using type 2 anova (the SS and the F changes don't match SPSS's). You can see my use of this at the very end of the email. What I want: a function to make an anova table with f changes and delt R^2. I ran into 10 snags to making this a fully automated function using the full linear model (order matters here). Each snag is marked with a Comment #. Some snags are repeated because I couldn't do the first time and certainly couldn't do it after that. Help with any/all snags would be very appreciated. I'm a 2 1/2 month [R] user who's reading everything online (incl. manuals) ordering every book I can (looking at Dalgaard, Crawly's and Teetor's very helpful books right now). Loops and their usage is a foreign thing to me, despite studying them, and unfortunately I think that my function may call for them. I also realize that beyond 10 predictors may make this function way to bulky. I'm running the latest version of R (2.12.2)on a windows 7 machine. DATASET mtcars full.model-lm(mpg~cyl+disp+hp+drat, data=mtcars) CODE stepFO-function(model) { m-data.frame(model.frame(model)) num.of.var-length(colnames(m)) mod1-lm(m[,1]~m[,2]) mod2-lm(m[,1]~m[,2]+m[,3]) mod3-lm(m[,1]~m[,2]+m[,3]+m[,4]) mod4-lm(m[,1]~m[,2]+m[,3]+m[,4]+m[,5]) #Comment 1--I don't know how to automated this process(above) of adding #...additional variables. Probably a loop is needed but I don't understand #...how to apply it here. Maybe update.model [1:num.ofvar]? a1-anova(mod1) a2-anova(mod2) a3-anova(mod3) a4-anova(mod4) #Comment 2--SAME AS COMMENT 1 except applied to the anova tables. How do I make #...[R] add a5, a6...an as necessary? rb-rbind(a1,a2,a3,a4) #Comment 3--again I can't automate this to make the addition of a's automated anova1-rbind(rb[1,],rb[4,],rb[8,],rb[13,],rb[14,]) #Comment 4--the rb's follow a pattern of 1+3+4+5...+n variables #then I row bind these starting with 1 and rowbind one more after the last #...rb to include the bottom piece of the anova table that tells #...about residuals (how do I aoutomate this?) anova-anova1[,1:num.of.var] anova.table-data.frame(anova) #Comment 5--Something that bugs me here is that I have to turn it into a dataframe to #...add the totals row and the delta R^2 (tried playing w/ tkinsert to no avail) #...I miss the stuff that's at the bottom of the anova table (sig values) #Comment 6--I'd love to turn the place value to round to 2 after the decimal. #...I've worked this many ways including changing my options but this does #...not seem to apply to a data frame Total-c(sum(anova[,1]),sum(anova[,2]), , , ) anova.table-rbind(anova.table,Total) R1-summary(mod1)[[8]][[1]] R2-summary(mod2)[[8]][[1]] R3-summary(mod3)[[8]][[1]] R4-summary(mod4)[[8]][[1]] #Comment 7--SAME AS COMMENT 2. How do I make #...[R] add R5, R6...Rn as necessary? deltaR.1-R1 deltaR.2-R2-R1 deltaR.3-R3-R2 deltaR.4-R4-R3 #Comment 8--SAME AS COMMENT 7. How would I aoutomate this process? Delta.R.Squared-c(deltaR.1,deltaR.2,deltaR.3,deltaR.4, ,) #Comment 9--I need a way to add as many deltaR's as #...necessary(n of R = n of predictors) anova.table-cbind(anova.table, Delta.R.Squared) colnames(anova.table)-c(df,Sum Sq,Mean Sq,F-change, P-value,Delta.R.Squared) rownames(anova.table)-c(X1, X2 elminating for X1, X3 eliminating for X2 X3, X4 eliminating for X1,X2, X3,Residuals, Total) anova.table } #Comment 10--Again I would need [R] to automate the list for row names as we #...add more predictors. #See the final product below I'm after (with two places after the decimal) anova.table df Sum Sq Mean Sq F-changeP-value Delta.R.Squared X1 1 817.712952354614 817.712952354614 79.5610275293349 6.112687142581e-10 0.726180005093805 X2 elminating for X1 1 37.5939529324851 37.5939529324851 4.0268283172755 0.0541857201845285 0.0333857704630917 X3 eliminating for X2 X3 1 9.37092926438942 9.37092926438942 1.00388976918267 0.324951851250774 0.00832196853596723 X4 eliminating for X1,Xx2, X3 1 16.4674349222492 16.4674349222492 1.81550535203668 0.189048514740917 0.0146241073243205 Residuals 27 244.901918026262 9.07044140838007 NA NA Total 31 1126.0471875 USING THE ADD1() FUNCTION NOT WHAT I WANT mod1-lm(mpg~cyl, data=mtcars) add1(mod1,~cyl+disp+hp+drat, data=mtcars, test=F) Model: mpg ~ cyl Df Sum of SqRSSAIC F value Pr(F) none 308.33 76.494 disp137.594 270.74 74.334 4.0268 0.05419 . hp 116.360 291.98 76.750 1.6249 0.21253 drat115.841 292.49 76.807 1.5706 0.22012 --- Signif. codes: 0 *** 0.001 **
Re: [R] Getting number of students with zeroes in long format
Hi Jorge, I want to make sure this does what I want. So I want to get a count of students that never get a suspension. Once a student has a non-zero I don't want to count that student. Each id_r is may be associated with multiple sus. Are these commands doing this? Because ... suslm[175953:nrow(suslm),c(id_r,sus)] id_r sus 999881.5 999881 1 999881.6 999881 7 999881.7 999881 0 999881.8 999881 0 999886.5 999886 0 999886.6 999886 0 999886.7 999886 0 999886.8 999886 0 999890.5 999890 0 999890.6 999890 0 999890.7 999890 0 999890.8 999890 0 999892.5 999892 0 999892.6 999892 0 999892.7 999892 0 999892.8 999892 0 999896.5 999896 0 999896.6 999896 4 999896.7 999896 3 999896.8 999896 0 999897.5 999897 0 999897.6 999897 0 999897.7 999897 0 tail(with(suslm,tapply(sus,id_r,function(x) any(x==0 999881 999886 999890 999892 999896 999897 TRUE TRUE TRUE TRUE TRUE TRUE r - with(suslm, tapply(sus, id_r, function(x) any(x 0)) tail(with(suslm, tapply(sus, id_r, function(x) any(x 0 999881 999886 999890 999892 999896 999897 TRUE FALSE FALSE FALSE TRUE FALSE Based on this 999881 and 999896 should be FALSE not TRUE I would expect if they were true for the first command they should be false for the second command right? tail(names(r[ r == TRUE ])) [1] 999752 999767 999806 999807 999881 999896 tail(names(r[ r == FALSE ])) [1] 999869 999870 999886 999890 999892 999897 This command seems to do the right thing. Is that right? On Wed, Apr 6, 2011 at 10:25 PM, Jorge Ivan Velez jorgeivanve...@gmail.comwrote: Hi Chris, Sorry I did not see your email before ;-) Here is one option: r - with(d, tapply(sus, id_r, function(x) any(x 0))) r 111516181920212224252630 3132 FALSE TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE TRUE FALSE FALSE FALSE FALSE 33 FALSE names(r[ r == TRUE ]) [1] 15 25 Regards, Jorge On Wed, Apr 6, 2011 at 5:03 PM, Christopher Desjardins wrote: Thanks. And how many could I find that have greater than 0? Chris On Wed, Apr 6, 2011 at 3:58 PM, Jorge Ivan Velez wrote: Hi Chris, Is this what you have in mind? sum(with(yourdata, tapply(sus, id_r, function(x) any(x==0 [1] 13 HTH, Jorge On Wed, Apr 6, 2011 at 4:44 PM, Christopher Desjardins wrote: Hi, I have longitudinal school suspension data on students. I would like to figure out how many students (id_r) have no suspensions (sus), i.e. have a code of '0'. My data is in long format and the first 20 records look like the following: suslm[1:20,c(1,7)] id_r sus 11 0 15 10 16 0 18 0 19 0 19 0 20 0 21 0 21 0 22 0 24 0 24 0 25 3 26 0 26 0 30 0 30 0 31 0 32 0 33 0 Each id_r is unique and I'd like to know the number of id_r that have a 0 for sus not the total number of 0. Does that make sense? Thanks! Chris [[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] Getting number of students with zeroes in long format
On Thu, Apr 7, 2011 at 8:07 AM, Christopher Desjardins cddesjard...@gmail.com wrote: Hi Jorge, I want to make sure this does what I want. So I want to get a count of students that never get a suspension. Once a student has a non-zero I don't want to count that student. Each id_r is may be associated with multiple sus. Are these commands doing this? Because ... Also sus = suspension suslm[175953:nrow(suslm),c(id_r,sus)] id_r sus 999881.5 999881 1 999881.6 999881 7 999881.7 999881 0 999881.8 999881 0 999886.5 999886 0 999886.6 999886 0 999886.7 999886 0 999886.8 999886 0 999890.5 999890 0 999890.6 999890 0 999890.7 999890 0 999890.8 999890 0 999892.5 999892 0 999892.6 999892 0 999892.7 999892 0 999892.8 999892 0 999896.5 999896 0 999896.6 999896 4 999896.7 999896 3 999896.8 999896 0 999897.5 999897 0 999897.6 999897 0 999897.7 999897 0 tail(with(suslm,tapply(sus,id_r,function(x) any(x==0 999881 999886 999890 999892 999896 999897 TRUE TRUE TRUE TRUE TRUE TRUE r - with(suslm, tapply(sus, id_r, function(x) any(x 0)) tail(with(suslm, tapply(sus, id_r, function(x) any(x 0 999881 999886 999890 999892 999896 999897 TRUE FALSE FALSE FALSE TRUE FALSE Based on this 999881 and 999896 should be FALSE not TRUE for tail(with(suslm,tapply(sus,id_r,function(x) any(x==0 I would expect if they were true for the first command they should be false for the second command right? tail(names(r[ r == TRUE ])) [1] 999752 999767 999806 999807 999881 999896 tail(names(r[ r == FALSE ])) [1] 999869 999870 999886 999890 999892 999897 This command seems to do the right thing. Is that right? On Wed, Apr 6, 2011 at 10:25 PM, Jorge Ivan Velez jorgeivanve...@gmail.com wrote: Hi Chris, Sorry I did not see your email before ;-) Here is one option: r - with(d, tapply(sus, id_r, function(x) any(x 0))) r 111516181920212224252630 3132 FALSE TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE TRUE FALSE FALSE FALSE FALSE 33 FALSE names(r[ r == TRUE ]) [1] 15 25 Regards, Jorge On Wed, Apr 6, 2011 at 5:03 PM, Christopher Desjardins wrote: Thanks. And how many could I find that have greater than 0? Chris On Wed, Apr 6, 2011 at 3:58 PM, Jorge Ivan Velez wrote: Hi Chris, Is this what you have in mind? sum(with(yourdata, tapply(sus, id_r, function(x) any(x==0 [1] 13 HTH, Jorge On Wed, Apr 6, 2011 at 4:44 PM, Christopher Desjardins wrote: Hi, I have longitudinal school suspension data on students. I would like to figure out how many students (id_r) have no suspensions (sus), i.e. have a code of '0'. My data is in long format and the first 20 records look like the following: suslm[1:20,c(1,7)] id_r sus 11 0 15 10 16 0 18 0 19 0 19 0 20 0 21 0 21 0 22 0 24 0 24 0 25 3 26 0 26 0 30 0 30 0 31 0 32 0 33 0 Each id_r is unique and I'd like to know the number of id_r that have a 0 for sus not the total number of 0. Does that make sense? Thanks! Chris [[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] How to speed up grouping time series, help please
I found a faster implementation (by an order of magnitude from my tests) than the one using xts, split, merge (from Joshua). I report the two fastest solution below with code to generate a test case; some work still to be done for columns order and naming, Test case has grown from my previous post to get a more realistic timing. Any comment or idea to further speed up multivariate time series creation with classes xts or timeSeries starting from a data.frame like the one reported here is welcome. Best regards, Den a data.frame example (code below to generate it) ID DATE VALUE 14 3 2000-01-01 00:00:03 0.5726334 4 1 2000-01-01 00:00:03 0.8830174 1 1 2000-01-01 00:00:00 0.2875775 15 3 2000-01-01 00:00:04 0.1029247 11 3 2000-01-01 00:00:00 0.9568333 9 2 2000-01-01 00:00:03 0.5514350 7 2 2000-01-01 00:00:01 0.5281055 6 2 2000-01-01 00:00:00 0.0455565 12 3 2000-01-01 00:00:01 0.4533342 8 2 2000-01-01 00:00:02 0.8924190 3 1 2000-01-01 00:00:02 0.4089769 13 3 2000-01-01 00:00:02 0.6775706 And I want to get a timeSeries object or xts object like this: 1 2 3 2000-01-01 00:00:00 0.2875775 0.0455565 0.9568333 2000-01-01 00:00:01 NA 0.5281055 0.4533342 2000-01-01 00:00:02 0.4089769 0.8924190 0.6775706 2000-01-01 00:00:03 0.8830174 0.5514350 0.5726334 2000-01-01 00:00:04 NA NA 0.1029247 # CODE: set.seed(123) # set N to 5 to reproduce above data.frame N - 1000 # set K to 3 to reproduce above data.frame K - 10 X - data.frame( ID = rep(1:K, each = N), DATE = as.character(rep(as.POSIXct(2000-01-01, tz = GMT)+ 0:(N-1), K)), VALUE = runif(N*K), stringsAsFactors = FALSE) X - X[sample(1:(N*K), N*K),] X - X[-(sample(1:nrow(X), floor(nrow(X)*0.2))),] str(X) xtsSplit - function(x) { library(xts) x - xts(x[,c(ID,VALUE)], as.POSIXct(x[,DATE])) return(do.call(merge, split(x$VALUE,x$ID))) } xtsSplitTime - replicate(50, system.time(xtsSplit(X))[[1]]) median(xtsSplitTime) xtsReshape - function(x) { library(xts) x - reshape(x, idvar = DATE, timevar = ID, direction = wide) x - xts(x[,-1], as.POSIXct(x[,1])) return(x) } xtsReshapeTime - replicate(50, system.time(xtsReshape(X))[[1]]) median(xtsReshapeTime) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] unexpected sort order with merge
B77S bps0...@auburn.edu writes: That is odd, I noticed some weird sorting with merge() a while back too and always am careful with it now. Fortunately, sort=FALSE seems to work the way one would think most of the time. Thanks for checking. Is this on a more recent version of R than 2.10.1? (I'm half-hoping this is something fixed in a newer R, so I can use it as an excuse to demand an upgrade.) Although, the following results seem weird too! (adding by=date makes it not sort oddly, regardless of sort=TRUE or FALSE) [...] merge(d1, d2, by=date, sort=T) date icpn.x foo icpn.y bar 1 Jan 2000500 1500 10 2 Feb 2000500 2500 20 3 Mar 2000500 3500 30 4 Apr 2000500 4500 40 5 May 2000500 5500 50 6 Jun 2000500 6500 60 I think this is equivalent to the single column version. For yearmon objects, when `merge` only has one column to sort by, it seems to do the right thing. It only uses alphabetical order when there are more than one column. For ordered factors, though, even the single-column merge was giving me strange sorts. -Johann P.S. Just in case people have bad threading on their mail/news reader, here's the bad sort example: merge(d1, d2) date icpn foo bar 1 Apr 2000 500 4 40 2 Feb 2000 500 2 20 3 Jan 2000 500 1 10 4 Jun 2000 500 6 60 5 Mar 2000 500 3 30 6 May 2000 500 5 50 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] help on pspline in coxph
Hi there, I have a question on how to extract the linear term in the penalized spline in coxph. Here is a sample code: Here is a slightly more general example: fit - coxph(Surv(time, status) ~ ph.ecog + pspline(age) + sex, lung) (The lung data set is part of the survival package.) There are 14 coefficients, of which 2-13 are the for the spline. The slope logic is subtle. Luckily I left comments on this in the source code for pspline, because I remember it taking a long time for me to figure it out. slope = (X'VX)^{-1} X'V c A weighted regression on the coefficients where c= spline coefficients = fit$coef[2:13] in this case, V= fit$var[2:13,2:13], and X is a two column matrix with column 1=1 (intercept) and column 2 = centers of the pspline basis functions. These centers are saved away in the print function: get(cbase, environment(fit$printfun[[1]])) If there were multiple psline terms in the fit use [[2]], [[3]] etc as appropriate. No, you won't find this without reading the source code. Note that this is the linear slope from a fit with only a linear term, i.e., what would have resulted from a fit with age instead of pspline(age). I thought it quite interesting that this quantity could be derived at all. I leave the details as a homework exercise for the reader. Terry Therneau __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R licence
If all you need is loess, I suspect it would be cheaper to re-write it in C# than to get a considered legal opinion on the matter. Hadley On Thu, Apr 7, 2011 at 2:45 AM, Stanislav Bek stanislav.pavel@gmail.com wrote: Hi, is it possible to use some statistic computing by R in proprietary software? Our software is written in c#, and we intend to use http://rdotnet.codeplex.com/ to get R work there. Especially we want to use loess function. Thanks, Best regards, Stanislav [[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. -- Assistant Professor / Dobelman Family Junior Chair Department of Statistics / Rice University http://had.co.nz/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] transform() on selective names. Is it possible?
Hi all, I am whitening my data: # code begins N - 300 M - 2 x - matrix(data=rnorm(N*M, 0, 3)-10, ncol=M, nrow=N) y - matrix(c(1,-2,-2,1), ncol=M, nrow=M) z - data.frame(x %*% y) colnames(z) - c('x','y') par(mfrow=c(1,3)) plot(z, pch=5, col=blue) whiten - function(x) { (x-mean(x))/sd(x) } zz - transform(z, x=whiten(x), y=whiten(y)) plot(zz, pch=3, col=red) #code ends And everything looks fine enough. But now I want to withen just one of the columns and I won't know which one until my script is running, hence I can't hard code it in the script. Then I though, well maybe if I define some convenient f... #begin code f - function(a) { paste(a,=withen(,a,), sep='') } a - 'x' # or a - 'y' depending on user input. f(a) [1] x=withen(x) # so I could try zzz - transform(z, eval(f('x'))) # which of course doesn't work plot(zz, pch=3, col=green) head(z, n=2) x y 1 17.167380 6.884402 2 8.234507 13.940932 head(zzz, n=2) x y 1 17.167380 6.884402 2 8.234507 13.940932 #end code Could someone provide me with some hint on whether the attempted trick above is possible and how to proceed further? Thanks in advance. jcb! __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] package
I'd like to get the package about Potts and, Swenson-Wang models. Haw can I do that? There is a package about Wolff model, too? If yes, how to get it? Thanks. Nelson Doki. [[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] metaplot
Many thanks for your reply! the Package ggplot was removed from the CRAN repository. Formerly available versions can be obtained from the archivehttp://cran.r-project.org/src/contrib/Archive/ggplot(Unfortunately, I am a windows user). The metafor and meta.summaries() still need the (a,b,c,d) or standard errors for the effect estimates! I have the following data rr - c(0.61, 0.35, 1.16, 0.94, 1.16, 0.46, 0.99, 1.05, 1.15, 0.27) lci - c(-1.69, -1.27, -0.24, -0.54, -1.01, -1.8,-0.89, -1.38, -1.05,-2.04) uci - c(0.70, -0.82,0.54,0.41,1.30,0.24,0.87,1.48,1.33,-0.57) rrdata - data.frame(rr,lci,uci) I can compute standard errors from my data? but the results show different confidence interval? Many thanks in advance, Cheba 2011/4/6 Scott Chamberlain scttchamberla...@gmail.com What about the metafor package? Or just create your own plot. For example, using ggplot2 package: limits - aes(ymax = OR + (OR - 95%LCI), ymin = OR - (OR - 95%LCI)) ggplot(dataframe, aes(x = Study.Name, y = OR)) + geom_point() + geom_errobar(limits) Best, Scott On Wednesday, April 6, 2011 at 11:53 AM, cheba meier wrote: Dear all, I have a four variable: Stuy.Name, OR, 95%LCI and 95%UCI and I would like to create a meta analysis plot. I can't use meta.MH function in metaplot because I do not have n.trt, n.ctrl, col.trt, col.ctrl are not available! Is there an alternative way to do it? Many thanks in advance, Cheba [[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] transform() on selective names. Is it possible?
On Apr 7, 2011, at 9:56 AM, Juan Carlos Borrás wrote: Hi all, I am whitening my data: # code begins N - 300 M - 2 x - matrix(data=rnorm(N*M, 0, 3)-10, ncol=M, nrow=N) y - matrix(c(1,-2,-2,1), ncol=M, nrow=M) z - data.frame(x %*% y) colnames(z) - c('x','y') par(mfrow=c(1,3)) plot(z, pch=5, col=blue) whiten - function(x) { (x-mean(x))/sd(x) } Consider: whiten - scale # no need to re-invent the wheel fc - function(dfrm, coln) transform(dfrm, coln=whiten(dfrm[coln])) colxy - x z - fc(z, colxy) # the [ function will interpret colxy z zz - transform(z, x=whiten(x), y=whiten(y)) plot(zz, pch=3, col=red) #code ends And everything looks fine enough. But now I want to withen just one of the columns and I won't know which one until my script is running, hence I can't hard code it in the script. Then I though, well maybe if I define some convenient f... #begin code f - function(a) { paste(a,=withen(,a,), sep='') } a - 'x' # or a - 'y' depending on user input. f(a) [1] x=withen(x) # so I could try zzz - transform(z, eval(f('x'))) # which of course doesn't work plot(zz, pch=3, col=green) head(z, n=2) x y 1 17.167380 6.884402 2 8.234507 13.940932 head(zzz, n=2) x y 1 17.167380 6.884402 2 8.234507 13.940932 #end code Could someone provide me with some hint on whether the attempted trick above is possible and how to proceed further? Thanks in advance. jcb! __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. David Winsemius, MD West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] [SOLVED] Two functions as parametrs of a function.
Dr Dallazuanna: Thank you for your help. It works very good! - Mensaje original - De: Henrique Dallazuanna www...@gmail.com Fecha: Jueves, 7 de Abril de 2011, 7:05 am Asunto: Re: [R] Two functions as parametrs of a function. A: Kenneth Roy Cabrera Torres krcab...@une.net.co CC: r-help r-help@r-project.org Try this: f2 - function(n, nsim, fun1, fun2) { vp - replicate(nsim, do.call(fun1$name, c(n, fun1$args)), do.call(fun1$name, c(n, fun1$args))) vp } f2(2, 100, fun1 = list(name = rbeta, args = list(shape1 = 2, shape2 = 2), fun1 = list(name = rbeta, args = list(shape1 = 2, shape2 = 2 On Thu, Apr 7, 2011 at 8:45 AM, Kenneth Roy Cabrera Torres krcab...@une.net.co wrote: Hi R users: I'm trying to make a function where two of the parameters are functions, but I don't know how to put each set of parameters for each function. What am I missing? I try this code: f2- function(n=2,nsim=100,fun1=rnorm,par1=list(),fun2=rnorm,par2=list()){ force(fun1) force(fun2) force(n) p1-unlist(par1) p2-unlist(par2) force(p1) force(p2) localfun1 - function() fun1(n, p1) localfun2 - function() fun2(n, p2) vp-replicate(nsim,t.test(localfun1(), localfun2())$p.value) return(vp) } f2(fun1=rbeta,par1=list(shape1=2,shape2=2),fun2=rbeta,par2=list(shape1=1,shape2=2)) Thank you for your help. Kenneth __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R- project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40 S 49° 16' 22 O [[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] [SOLVED] Two functions as parametrs of a function.
Dr. Murdoch: Thank you very much for your help. Where can I find a more systematic documentation about these topics? I mean, examples of do.call, environments, as.function, the scoping and the way understand when to use force, etc. Again, thank you. Kenneth - Mensaje original - De: Duncan Murdoch murdoch.dun...@gmail.com Fecha: Jueves, 7 de Abril de 2011, 7:04 am Asunto: Re: [R] Two functions as parametrs of a function. A: Kenneth Roy Cabrera Torres krcab...@une.net.co CC: r-help r-help@r-project.org On 07/04/2011 7:45 AM, Kenneth Roy Cabrera Torres wrote: Hi R users: I'm trying to make a function where two of the parameters are functions, but I don't know how to put each set of parameters for each function. What am I missing? I try this code: f2- function(n=2,nsim=100,fun1=rnorm,par1=list(),fun2=rnorm,par2=list()){ force(fun1) force(fun2) force(n) p1-unlist(par1) p2-unlist(par2) You don't want to unlist those. Leave them as lists, and use the do.call() function for the calls. For example, localfun1 - function() do.call(fun1, c(list(n), par1)) force(p1) force(p2) Calling force() is only useful for arguments to your function: it kicks the evaluator, so it's not so lazy. Since p1 and p2 were calculated earlier, there's no need to force them. You might need to force n, since it is only used in the localfun1 and localfun2 calls, and if the argument to f2 changes before you make those calls, the wrong value will be used. That's pretty unlikely with your code, but since fun1 and fun2 can do anything, it's safest to fix the value of n before you call them. The same argument applies to fun1 and fun2 themselves. Duncan Murdoch localfun1- function() fun1(n, p1) localfun2- function() fun2(n, p2) vp- replicate(nsim,t.test(localfun1(), localfun2())$p.value) return(vp) } f2(fun1=rbeta,par1=list(shape1=2,shape2=2),fun2=rbeta,par2=list(shape1=1,shape2=2)) Thank you for your help. Kenneth __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] transform() on selective names. Is it possible?
Wonderful, or the closest to heaven I've been the whole afternoon, but not quite there: # begin code N - 300 M - 2 x - matrix(data=rnorm(N*M, 0, 3)-10, ncol=M, nrow=N) y - matrix(c(1,-2,-2,1), ncol=M, nrow=M) z - data.frame(x %*% y) colnames(z) - c('x','y') par(mfrow=c(1,3)) plot(z, pch=5, col=blue) whiten - scale # no need to re-invent the wheel, I agree fc - function(dfrm, coln) transform(dfrm, coln=whiten(dfrm[coln])) colxy - x z1 - fc(z, colxy) # the [ function will interpret colxy colnames(z1) [1] x y x.1 fc - function(dfrm, coln) transform(dfrm, coln=whiten(dfrm[,coln])) colxy - x z2 - fc(z, colxy) # the [ function will interpret colxy colnames(z2) [1] xycoln #end code What I want is to know whether I can customize the column name of the result of the transform() call. Your hint is fantastic, thanks there, but I keep getting into that particular pattern of computation over and over and I wonder if it's possible to skip a column clean-up after applying your trick. 2011/4/7 David Winsemius dwinsem...@comcast.net: On Apr 7, 2011, at 9:56 AM, Juan Carlos Borrás wrote: Hi all, I am whitening my data: # code begins N - 300 M - 2 x - matrix(data=rnorm(N*M, 0, 3)-10, ncol=M, nrow=N) y - matrix(c(1,-2,-2,1), ncol=M, nrow=M) z - data.frame(x %*% y) colnames(z) - c('x','y') par(mfrow=c(1,3)) plot(z, pch=5, col=blue) whiten - function(x) { (x-mean(x))/sd(x) } Consider: whiten - scale # no need to re-invent the wheel fc - function(dfrm, coln) transform(dfrm, coln=whiten(dfrm[coln])) colxy - x z - fc(z, colxy) # the [ function will interpret colxy z zz - transform(z, x=whiten(x), y=whiten(y)) plot(zz, pch=3, col=red) #code ends And everything looks fine enough. But now I want to withen just one of the columns and I won't know which one until my script is running, hence I can't hard code it in the script. Then I though, well maybe if I define some convenient f... #begin code f - function(a) { paste(a,=withen(,a,), sep='') } a - 'x' # or a - 'y' depending on user input. f(a) [1] x=withen(x) # so I could try zzz - transform(z, eval(f('x'))) # which of course doesn't work plot(zz, pch=3, col=green) head(z, n=2) x y 1 17.167380 6.884402 2 8.234507 13.940932 head(zzz, n=2) x y 1 17.167380 6.884402 2 8.234507 13.940932 #end code Could someone provide me with some hint on whether the attempted trick above is possible and how to proceed further? Thanks in advance. jcb! __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. David Winsemius, MD West Hartford, CT Cheers, jcb! __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R licence
Duncan, Letting you know then that I just don't see how the first paragraph here : http://www.revolutionanalytics.com/downloads/gpl-sources.php is compatible with clause 2(b) here : http://www.gnu.org/licenses/gpl-2.0.html Perhaps somebody could explain why it is? Matthew Duncan Murdoch murdoch.dun...@gmail.com wrote in message news:4d9da9ff.9020...@gmail.com... On 07/04/2011 7:47 AM, Matthew Dowle wrote: Peter, If the proprietary part of REvolution's product is ok, then surely Stanislav's suggestion is too. No? Revolution has said that they believe they follow the GPL, and they haven't been challenged on that. If you think that they don't, you could let an R copyright holder know what they're doing that's a license violation. My opinion of Stanislav's question is that he doesn't give enough information to answer. If he is planning to distribute R as part of his product, he needs to follow the GPL. If not, I don't think any R copyright holder has anything to complain about. Duncan Murdoch Matthew peter dalgaardpda...@gmail.com wrote in message news:be157cf5-9b4b-45a0-a7d4-363b774f1...@gmail.com... On Apr 7, 2011, at 09:45 , Stanislav Bek wrote: Hi, is it possible to use some statistic computing by R in proprietary software? Our software is written in c#, and we intend to use http://rdotnet.codeplex.com/ to get R work there. Especially we want to use loess function. You need to take legal advice to be certain, but offhand I would say that this kind of circumvention of the GPL is _not_ allowed. It all depends on whether the end product is a derivative work, in which case, the whole must be distributed under a GPL-compatible licence. The situation around GPL-incompatible plug-ins or plug-ins interfacing to R in GPL -incompatible software is legally murky, but using R as a subroutine library for proprietary code is clearly crossing the line, as far as I can tell. -- Peter Dalgaard 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-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R licence
I don't think R-help is the appropriate place for this question. Probably you will have more luck at http://www.theattorneysforum.com/ or some such. Best, Ista On Thu, Apr 7, 2011 at 10:36 AM, Matthew Dowle mdo...@mdowle.plus.com wrote: Duncan, Letting you know then that I just don't see how the first paragraph here : http://www.revolutionanalytics.com/downloads/gpl-sources.php is compatible with clause 2(b) here : http://www.gnu.org/licenses/gpl-2.0.html Perhaps somebody could explain why it is? Matthew Duncan Murdoch murdoch.dun...@gmail.com wrote in message news:4d9da9ff.9020...@gmail.com... On 07/04/2011 7:47 AM, Matthew Dowle wrote: Peter, If the proprietary part of REvolution's product is ok, then surely Stanislav's suggestion is too. No? Revolution has said that they believe they follow the GPL, and they haven't been challenged on that. If you think that they don't, you could let an R copyright holder know what they're doing that's a license violation. My opinion of Stanislav's question is that he doesn't give enough information to answer. If he is planning to distribute R as part of his product, he needs to follow the GPL. If not, I don't think any R copyright holder has anything to complain about. Duncan Murdoch Matthew peter dalgaardpda...@gmail.com wrote in message news:be157cf5-9b4b-45a0-a7d4-363b774f1...@gmail.com... On Apr 7, 2011, at 09:45 , Stanislav Bek wrote: Hi, is it possible to use some statistic computing by R in proprietary software? Our software is written in c#, and we intend to use http://rdotnet.codeplex.com/ to get R work there. Especially we want to use loess function. You need to take legal advice to be certain, but offhand I would say that this kind of circumvention of the GPL is _not_ allowed. It all depends on whether the end product is a derivative work, in which case, the whole must be distributed under a GPL-compatible licence. The situation around GPL-incompatible plug-ins or plug-ins interfacing to R in GPL -incompatible software is legally murky, but using R as a subroutine library for proprietary code is clearly crossing the line, as far as I can tell. -- Peter Dalgaard 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-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Ista Zahn Graduate student University of Rochester Department of Clinical and Social Psychology http://yourpsyche.org __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] [SOLVED] Two functions as parametrs of a function.
On 07/04/2011 10:12 AM, KENNETH R CABRERA wrote: Dr. Murdoch: Thank you very much for your help. Where can I find a more systematic documentation about these topics? I mean, examples of do.call, environments, as.function, the scoping and the way understand when to use force, etc. For details of the concepts, you should look in the R Language Definition manual (and perhaps An Introduction to R for some more examples). For individual functions, the help page for each usually includes some examples. And then there's the source code, but if the manuals are unclear, it may be no clearer. Duncan Murdoch Again, thank you. Kenneth - Mensaje original - De: Duncan Murdochmurdoch.dun...@gmail.com Fecha: Jueves, 7 de Abril de 2011, 7:04 am Asunto: Re: [R] Two functions as parametrs of a function. A: Kenneth Roy Cabrera Torreskrcab...@une.net.co CC: r-helpr-help@r-project.org On 07/04/2011 7:45 AM, Kenneth Roy Cabrera Torres wrote: Hi R users: I'm trying to make a function where two of the parameters are functions, but I don't know how to put each set of parameters for each function. What am I missing? I try this code: f2- function(n=2,nsim=100,fun1=rnorm,par1=list(),fun2=rnorm,par2=list()){ force(fun1) force(fun2) force(n) p1-unlist(par1) p2-unlist(par2) You don't want to unlist those. Leave them as lists, and use the do.call() function for the calls. For example, localfun1- function() do.call(fun1, c(list(n), par1)) force(p1) force(p2) Calling force() is only useful for arguments to your function: it kicks the evaluator, so it's not so lazy. Since p1 and p2 were calculated earlier, there's no need to force them. You might need to force n, since it is only used in the localfun1 and localfun2 calls, and if the argument to f2 changes before you make those calls, the wrong value will be used. That's pretty unlikely with your code, but since fun1 and fun2 can do anything, it's safest to fix the value of n before you call them. The same argument applies to fun1 and fun2 themselves. Duncan Murdoch localfun1- function() fun1(n, p1) localfun2- function() fun2(n, p2) vp- replicate(nsim,t.test(localfun1(), localfun2())$p.value) return(vp) } f2(fun1=rbeta,par1=list(shape1=2,shape2=2),fun2=rbeta,par2=list(shape1=1,shape2=2)) Thank you for your help. Kenneth __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R- project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R licence
On 07/04/2011 10:36 AM, Matthew Dowle wrote: Duncan, Letting you know then that I just don't see how the first paragraph here : http://www.revolutionanalytics.com/downloads/gpl-sources.php is compatible with clause 2(b) here : http://www.gnu.org/licenses/gpl-2.0.html Perhaps somebody could explain why it is? No, I certainly wouldn't attempt that, but thanks for the information. Duncan Murdoch Matthew Duncan Murdochmurdoch.dun...@gmail.com wrote in message news:4d9da9ff.9020...@gmail.com... On 07/04/2011 7:47 AM, Matthew Dowle wrote: Peter, If the proprietary part of REvolution's product is ok, then surely Stanislav's suggestion is too. No? Revolution has said that they believe they follow the GPL, and they haven't been challenged on that. If you think that they don't, you could let an R copyright holder know what they're doing that's a license violation. My opinion of Stanislav's question is that he doesn't give enough information to answer. If he is planning to distribute R as part of his product, he needs to follow the GPL. If not, I don't think any R copyright holder has anything to complain about. Duncan Murdoch Matthew peter dalgaardpda...@gmail.com wrote in message news:be157cf5-9b4b-45a0-a7d4-363b774f1...@gmail.com... On Apr 7, 2011, at 09:45 , Stanislav Bek wrote: Hi, is it possible to use some statistic computing by R in proprietary software? Our software is written in c#, and we intend to use http://rdotnet.codeplex.com/ to get R work there. Especially we want to use loess function. You need to take legal advice to be certain, but offhand I would say that this kind of circumvention of the GPL is _not_ allowed. It all depends on whether the end product is a derivative work, in which case, the whole must be distributed under a GPL-compatible licence. The situation around GPL-incompatible plug-ins or plug-ins interfacing to R in GPL -incompatible software is legally murky, but using R as a subroutine library for proprietary code is clearly crossing the line, as far as I can tell. -- Peter Dalgaard 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-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R licence
On Apr 7, 2011, at 16:36 , Matthew Dowle wrote: Duncan, Letting you know then that I just don't see how the first paragraph here : http://www.revolutionanalytics.com/downloads/gpl-sources.php is compatible with clause 2(b) here : http://www.gnu.org/licenses/gpl-2.0.html Perhaps somebody could explain why it is? As I understand it, they believe that it falls under the mere aggregation exception at the end of sec.2, and they believe that their plugins are not derived works, but add-ons. The legal hair-splitting is rather painful... -- Peter Dalgaard 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] Quasipoisson with geeglm
Dear Ivy, In gee there is no quasipossion, because gee is in a way already quasi. With GEE we do not fit a poisson glm, but use in the construction of the sandwich covariance matrix the variance function of the poisson family. In Gee always an 'overdispersion' is estimated. Regards Søren Fra: r-help-boun...@r-project.org [r-help-boun...@r-project.org] P#229; vegne af JANSEN, Ivy [ivy.jan...@inbo.be] Sendt: 7. april 2011 13:32 Til: r-help@r-project.org Emne: [R] Quasipoisson with geeglm Dear all, I am trying to use the GEE methodology to fit a trend for the number of butterflies observed at several sites. In total, there are 66 sites, and 19 years for which observations might be available. However, only 326 observations are available (instead of 1254). For the time being, I ignore the large number of missing values, and the fact that GEE is only valid under MCAR. When I run the following code geeglm(SumOfButterflies ~ RES_YEAR, family = poisson, data = ManijurtNoNA, id = RES_ROTE_ID, corstr = ar1) I obtain normal output. Not surprisingly, overdispersion is present (Estimated Scale Parameters: [1] 185.8571), so changing to quasipoisson is needed. However, the code below geeglm(SumOfButterflies ~ RES_YEAR, family = quasipoisson, data = ManijurtNoNA, id = RES_ROTE_ID, corstr = ar1) produces the following error Error in geese.fit(xx, yy, id, offset, soffset, w, waves = waves, zsca, : variance invalid. Other correlation structures encounter the same problem. I also tried adding waves = RES_YEAR (although I am not sure how waves should be used correctly), but it does not change anything. Any suggestions what might be wrong? Regards, Ivy [[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] transform() on selective names. Is it possible?
On Apr 7, 2011, at 10:27 AM, Juan Carlos Borrás wrote: Wonderful, or the closest to heaven I've been the whole afternoon, but not quite there: # begin code N - 300 M - 2 x - matrix(data=rnorm(N*M, 0, 3)-10, ncol=M, nrow=N) y - matrix(c(1,-2,-2,1), ncol=M, nrow=M) z - data.frame(x %*% y) colnames(z) - c('x','y') par(mfrow=c(1,3)) plot(z, pch=5, col=blue) whiten - scale # no need to re-invent the wheel, I agree fc - function(dfrm, coln) transform(dfrm, coln=whiten(dfrm[coln])) colxy - x z1 - fc(z, colxy) # the [ function will interpret colxy colnames(z1) [1] x y x.1 fc - function(dfrm, coln) transform(dfrm, coln=whiten(dfrm[,coln])) colxy - x z2 - fc(z, colxy) # the [ function will interpret colxy colnames(z2) [1] xycoln #end code What I want is to know whether I can customize the column name of the result of the transform() call. I haven't stumbled on a solution to that task. I am wondering if you could use something like: inpnames - names(dfrm) # before the transform step outdfrm - transform(...) names(outdfrm) - c(inpnames, paste(colxy, new, sep=_) ) kludgy to be sure. Your hint is fantastic, thanks there, but I keep getting into that particular pattern of computation over and over and I wonder if it's possible to skip a column clean-up after applying your trick. 2011/4/7 David Winsemius dwinsem...@comcast.net: On Apr 7, 2011, at 9:56 AM, Juan Carlos Borrás wrote: Hi all, I am whitening my data: # code begins N - 300 M - 2 x - matrix(data=rnorm(N*M, 0, 3)-10, ncol=M, nrow=N) y - matrix(c(1,-2,-2,1), ncol=M, nrow=M) z - data.frame(x %*% y) colnames(z) - c('x','y') par(mfrow=c(1,3)) plot(z, pch=5, col=blue) whiten - function(x) { (x-mean(x))/sd(x) } Consider: whiten - scale # no need to re-invent the wheel fc - function(dfrm, coln) transform(dfrm, coln=whiten(dfrm[coln])) colxy - x z - fc(z, colxy) # the [ function will interpret colxy z zz - transform(z, x=whiten(x), y=whiten(y)) plot(zz, pch=3, col=red) #code ends And everything looks fine enough. But now I want to withen just one of the columns and I won't know which one until my script is running, hence I can't hard code it in the script. Then I though, well maybe if I define some convenient f... #begin code f - function(a) { paste(a,=withen(,a,), sep='') } a - 'x' # or a - 'y' depending on user input. f(a) [1] x=withen(x) # so I could try zzz - transform(z, eval(f('x'))) # which of course doesn't work plot(zz, pch=3, col=green) head(z, n=2) x y 1 17.167380 6.884402 2 8.234507 13.940932 head(zzz, n=2) x y 1 17.167380 6.884402 2 8.234507 13.940932 #end code Could someone provide me with some hint on whether the attempted trick above is possible and how to proceed further? Thanks in advance. jcb! __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. David Winsemius, MD West Hartford, CT Cheers, jcb! David Winsemius, MD West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] dotplot as a background for multiple barchart plots (with Lattice)
Hi R users, I'm kind stuck in my R experience... I want to have a multiple barchart with n windows, but with the same background for each window, and I want that background to be a recorded dotplot. First, is it possible ? If so, I guess I have to call a record plot in the panel function but how ? As there is no panel.plot and I can't use the recorded plot as an argument for the panel.dotplot() call, I'm stuck. I think I close but I need some help. Many thanks and regards, Christian ### dummy data building test - data.frame(Subject=rep(c(A, B, C, D), each=6), Type=rep(c(EEE, FFF, GGG, HHH, III, JJJ), times=4), MeanX=abs(rnorm(24)), MeanZ=abs(rnorm(24))) ### data for regrouping all means all - data.frame(Type=levels(factor(test$Type)), MeanX = c(0), MeanZ = c(0)) ### building means... for(s in levels(factor(test$Subject))) { tmp - data.frame(Type = all$Type) for(t in tmp$Type) { tmp$MeanX[tmp$Type == t] - mean(test$MeanX[test$Type==t test$Subject==s]) tmp$MeanZ[tmp$Type == t] - mean(test$MeanZ[test$Type==t test$Subject==s]) } all$MeanX = all$MeanX + tmp$MeanX all$MeanZ = all$MeanZ + tmp$MeanZ } l - length(levels(factor(test$Subject))) all$MeanX = all$MeanX/l all$MeanX = all$MeanZ/l ### plot for means meanplot - dotplot(MeanX+MeanZ ~ Type, data=all, cex = 1.2, xlab=, ylab=, panel = panel.superpose, panel.groups = function(x, ..., group.number){ panel.dotplot(x + (group.number - 1.5)/3, ... ) }) ### test plot in order to see if there is something wrong. plot(meanplot) ### final plot barchart(MeanX + MeanZ ~ Type|Subject, data=test , scales = list(x = list(rot = 60)), layout=c(1, l), panel = function(...) { panel.superpose #panel.dotplot(meanplot) # so this is want I want, my recorded dotplot as a background... panel.abline(h=0) panel.grid(v = -length(levels(factor(test$Type))), h=0) panel.barchart(...) }) BTW, this R code might not be perfect and surely, there are better ways to build my data frames, but that's my newbie way to do it. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] K means algorithm C code
Dear R user, How can I get the C or C++ source code of the R_kmeans_MacQueen or R_kmeans_Lloyd subroutines implemented in the R kmeans function of the R stats-package {stats}? Would these be available as a C header file (*.h) somewhere from the R installation??? Any help to get a C or C++ implementation of these clustering algorithms would be very welcome. Thanks for your help. Johnny ~~~ Jean-Eudes DAZARD, PhD. Assistant Professor Bioinformatics Division Center for Proteomics and Bioinformatics School Of Medicine, BRB 936 Case Western Reserve University 10900 Euclid Avenue CLEVELAND, OHIO 44106 - 4988 Tel : 1-216-368-3157 Fax : 1-216-368-6846 e-mail : jxd...@case.edu ~~~ [[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] Scrap java scripts and styles from an html document
Date: Thu, 7 Apr 2011 04:15:50 -0700 From: antuj...@gmail.com To: r-help@r-project.org Subject: Re: [R] Scrap java scripts and styles from an html document Hi , I am working on developing a web crawler. Comments like this come up on the list every few weeks or so and I keep suggesting that someone ( other than me of course LOL) investigates an R interface to webkit for any efforts that require mimic of large parts of a browser function. Perhaps just make a debug build or custom build of webkit to dump whatever it is you want into a structured text file ( I've actually done this for what would amount to a crawler, I modified maybe one or two classes to output the links being fetched to stdout but I think there are ways to dump a DOM or other stuff in a format usable by R). For valid pages, you can just parse html as xml and get what you want in this case but usually people are looking for information only apparent after large pieces of js are executed. If you want comments only, these may be easy to isolate yourself.If you google CRAN HTML parser some hits do come up, for example http://cran.r-project.org/web/packages/scrapeR/scrapeR.pdf http://r.789695.n4.nabble.com/How-to-import-HTML-and-SQL-files-td879480.html Removing javascripts and styles is a part of the cleaning of the html document. What I want is a cleaned html document with only the html tags and textual information, so that i can figure out the pattern of the web page. This is being done to extract relevant information from the webpage like comments for a particular product. For e.g the amazon.com has all such comments within the and tags, with regular occuring for breaks. So tags which appear the most help us in locating the required information. Different websites have different patterns, but its more likely that tags that will occur the most will have the relevant information enclosed in them. So, once the html page is cleaned, it would be easy to role up the tags and knowing their frequency of occurrence, we can target the information. Should there be any suggestions to help, please let me know. I would be more than pleased. Regards, Antuj -- View this message in context: http://r.789695.n4.nabble.com/Scrap-java-scripts-and-styles-from-an-html-document-tp3413894p3433052.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How can I include a new book on the
Thanks Ben! I will! Em 4/7/2011 8:32 AM, Ben Bolker escreveu: Marcio Pupin Mellomelloat ieee.org writes: I've just published a new book for R beginners in Portuguese: Conhecendo o R: uma visão estatística (something like Knowing R: an statistical approach). I'd like to include it on the list Books at R-project.org. How can I do it? More informations about the book at http://www.editoraufv.com.br/produtos/conhecendo-o-r I think you should try contacting Kurt Hornik at r-project.org __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Marcio Pupin Mello Survey Engineer Ph.D student in Remote Sensing National Institute for Space Research (INPE) - Brazil Laboratory of Remote Sensing in Agriculture and Forestry (LAF) www.dsr.inpe.br/~mello __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Two questions about metacharacter in regexprs and function return
for the script, please kindly see the script below. At line 10 and line 13, my problems occurs. The first one is I try to retrieve the gene official name from a column of a table. The pattern of official name is something starting with gene_name. For detail problems, please see the according lines. Any suggestions are appreciated example of matching source (extract the Nnat, sometime it would be the character N/A): AB004048|MM8;NCBI Build 36|transcript|chr2|157251580|157253958|ExemplarFor 'AB004048'; gene_id '18111'; transcript_id 'AB004048'; gene_name 'Nnat'; alt '5730414I02Rik|AW107673|Peg5'; neuronatin|http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?db=genecmd=Retrievedopt=full_reportlist_uids=18111; #obtain the exprs matrix for cluster analysis #ask questions DEG_files - grep(bak, dir());#pay attention to the filenames exprs_files - grep(copy, dir()); protein - c(); assign_exprs - function(files, protein) { #use to find the DEGs or exprs for cmeans clustering for(i in 1:length(files)) { microarray_data - read.csv(file = files[i], header = T, sep = \t); microarray_data[, 7] - gsub(([\\s\\S]+gene_name '(\\w*)';.+), \\2, microarray_data[, 7], perl = T);#why [\\w]* cannot workable? also the [(\\w*)(N/A)] cannot be workable. assign(files[i], microarray_data, envir=.GlobalEnv); #get(dir()[i]() can obtain the data of interest.`variable_names` can also work protein - c(protein, get(files[i])[, 7]); #used for obtain all the DEGs only } #return protein; #why this line is not workable? assign(all_protein, protein, envir=.GlobalEnv); } exist_to_cluster_exprs - function(x, cluster_exprs, all) { if(exists(all, x[1])){ #exists function cluster_exprs - cbind(cluster_exprs, x); } #return cluster_exprs; } assign_exprs(dir()[DEG_files], protein); all_protein - unique(all_protein); assign_exprs(dir()[exprs_files], protein); for(i in 1:2) { apply(get(dir()[exprs_files[i]]), 1, exist_to_cluster_exprs, cluster_exprs, all); #assign(paste(exprs_files()[i], exprs_data), cluster_exprs[, c(2, 3, 5, 7)]; exprs_data - cbind(exprs_data, cluster_exprs[, 3]); } exprs_data; -- View this message in context: http://r.789695.n4.nabble.com/Two-questions-about-metacharacter-in-regexprs-and-function-return-tp3433342p3433342.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Time series of spatial data
Hi idham, Welcome to the R! It will depend on what you want to do with your data. But you can take a look at the packages sp, spdep. And I also recomend the book: R.S. Bivand, E.J. Pebesma, and V. Gómez-Rubio, Applied spatial data analysis with R, New York, USA: Springer, 2008. Good luck! -- Marcio Pupin Mello Survey Engineer Ph.D student in Remote Sensing National Institute for Space Research (INPE) - Brazil Laboratory of Remote Sensing in Agriculture and Forestry (LAF) www.dsr.inpe.br/~mello Em 4/7/2011 7:38 AM, idham escreveu: Hi guys, I'm really new in R. Trying to analyze series of spatial datasets (365 satellite images) in order to find the best model that fit the data. Any suggestion which package that could help me? Thanks in advance. Cheers -- View this message in context: http://r.789695.n4.nabble.com/Time-series-of-spatial-data-tp3432979p3432979.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Problem Installing rJava on MS Win 7 Platform
I'm a new R user and, frankly, this problem has got me stumped. I'm using the 64 bit version of RGui and followed the installation instructions on http://www.rforge.net/rJava/ Here is the result: package 'rJava' successfully unpacked and MD5 sums checked library(rJava) Error in utils::readRegistry(key, HLM, 2) : Registry key 'Software\JavaSoft\Java Runtime Environment' not found Error in utils::readRegistry(key, HLM, 2) : Registry key 'Software\JavaSoft\Java Development Kit' not found Error : .onLoad failed in loadNamespace() for 'rJava', details: call: fun(...) error: JAVA_HOME cannot be found from the Registry Error: package/namespace load failed for 'rJava' I don't Have the faintest idea as t what I've done, or failed to do. Assistance will be greatly appreciated. Thanks in advance. Stephen P. Molnar, Ph.D. Life is a fuzzy set Foundation for Chemistry Stochastic and multivriate http://www.FoundationForChemistry.com [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] package
See http://cran.opensourceresources.org/web/packages/index.html -- Marcio Pupin Mello Survey Engineer Ph.D student in Remote Sensing National Institute for Space Research (INPE) - Brazil Laboratory of Remote Sensing in Agriculture and Forestry (LAF) www.dsr.inpe.br/~mello Em 4/7/2011 10:59 AM, Nelson Doki escreveu: I'd like to get the package about Potts and, Swenson-Wang models. Haw can I do that? There is a package about Wolff model, too? If yes, how to get it? Thanks. Nelson Doki. [[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] Regrouping data
Dear R forum I have just started my venture with R. While I am trying to learn R through the tutorials, I think the current problem I need to address to is beyond my knowledge about R. I have a dataframe as defined below - rat_dat = data.frame(name = c(A, A, A, B, B, B, C, C, C, D, D, D), period = c(31-Mar-11, 30-Mar-11, 29-Mar-11, 31-Mar-11, 30-Mar-11, 29-Mar-11, 31-Mar-11, 30-Mar-11, 29-Mar-11, 31-Mar-11, 30-Mar-11, 29-Mar-11), cy_date = c(31-May-11,31-May-11, 31-May-11, 31-May-11, 31-May-11, 31-May-11, 31-May-11, 31-May-11, 31-May-11, 31-May-11, 31-May-11, 31-May-11), values = c(10.42, 10.46, 10.37, 12.62, 12.65, 12.61, 14.10, 14.12, 14.08, 11.11, 11.15, 11.17)) rat_dat name period cy_date values 1 A 31-Mar-11 31-May-11 10.42 2 A 30-Mar-11 31-May-11 10.46 3 A 29-Mar-11 31-May-11 10.37 4 B 31-Mar-11 31-May-11 12.62 5 B 30-Mar-11 31-May-11 12.65 6 B 29-Mar-11 31-May-11 12.61 7 C 31-Mar-11 31-May-11 14.10 8 C 30-Mar-11 31-May-11 14.12 9 C 29-Mar-11 31-May-11 14.08 10 D 31-Mar-11 31-May-11 11.11 11 D 30-Mar-11 31-May-11 11.15 12 D 29-Mar-11 31-May-11 11.17 My actual data is too large. I need to (1) rearrange this input as period cy_date A B C D 31-Mar-11 31-May-11 10.42 12.62 14.10 11.11 30-Mar-11 31-May-11 10.46 12.65 14.12 11.15 29-Mar-11 31-May-11 10.37 12.61 14.08 11.17 (2) Also, I need to find the difference between (rat_dat$cy_date) - (rat_dat$period) I hope I am able to put forward my requirement properly. If not, please forgive me. Sandeepa [[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] Problem Installing rJava on MS Win 7 Platform
You failed to install an appropriate Java version. Best, Uwe Ligges On 07.04.2011 16:30, Stephen P Molnar wrote: I'm a new R user and, frankly, this problem has got me stumped. I'm using the 64 bit version of RGui and followed the installation instructions on http://www.rforge.net/rJava/ Here is the result: package 'rJava' successfully unpacked and MD5 sums checked library(rJava) Error in utils::readRegistry(key, HLM, 2) : Registry key 'Software\JavaSoft\Java Runtime Environment' not found Error in utils::readRegistry(key, HLM, 2) : Registry key 'Software\JavaSoft\Java Development Kit' not found Error : .onLoad failed in loadNamespace() for 'rJava', details: call: fun(...) error: JAVA_HOME cannot be found from the Registry Error: package/namespace load failed for 'rJava' I don't Have the faintest idea as t what I've done, or failed to do. Assistance will be greatly appreciated. Thanks in advance. Stephen P. Molnar, Ph.D. Life is a fuzzy set Foundation for Chemistry Stochastic and multivriate http://www.FoundationForChemistry.com [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] [SOLVED] Two functions as parametrs of a function.
On Apr 7, 2011, at 10:47 AM, Duncan Murdoch wrote: And then there's the source code, but if the manuals are unclear, it may be no clearer. -- Duncan Murdoch ... after citing the the usual suspects. R-help (April 2011) Fortune candidate? -- David Winsemius, MD West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] K means algorithm C code
See Ligges, U. (2006): R Help Desk: Accessing the Sources. R News 6 (4), 43-45. Best, Uwe Ligges On 07.04.2011 16:05, Jean-Eudes Dazard wrote: Dear R user, How can I get the C or C++ source code of the R_kmeans_MacQueen or R_kmeans_Lloyd subroutines implemented in the R kmeans function of the R stats-package {stats}? Would these be available as a C header file (*.h) somewhere from the R installation??? Any help to get a C or C++ implementation of these clustering algorithms would be very welcome. Thanks for your help. Johnny ~~~ Jean-Eudes DAZARD, PhD. Assistant Professor Bioinformatics Division Center for Proteomics and Bioinformatics School Of Medicine, BRB 936 Case Western Reserve University 10900 Euclid Avenue CLEVELAND, OHIO 44106 - 4988 Tel : 1-216-368-3157 Fax : 1-216-368-6846 e-mail : jxd...@case.edu ~~~ [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Assigning a larger number of levels to a factor that has fewer levels
Hello! I have larger and a smaller data frame with 1 factor in each - it's the same factor: large.frame-data.frame(myfactor=LETTERS[1:10]) small.frame-data.frame(myfactor=LETTERS[c(9,7,5,3,1)]) levels(large.frame$myfactor) levels(small.frame$myfactor) table(large.frame$myfactor) table(small.frame$myfactor) myfactor has 10 levels in large.frame and 5 levels in small.frame. All 5 levels in small.frame are present in large.frame. How could I make levels(small.frame$myfactor) contain all the same levels as levels(large.frame$myfactor)? In other words, I want table(small.frame$myfactor) to have the same number of entries as table(small.frame$myfactor) but with 5 zeros in it: A B C D E F G J I J 1 0 1 0 1 0 1 0 1 0 Thank you very much for your suggestions! -- Dimitri Liakhovitski Ninah Consulting www.ninah.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] Assigning a larger number of levels to a factor that has fewer levels
Hi Dimitri, The factor() function allows you to specify the levels. So small.frame$myfactor - factor(small.frame$myfactor, levels = levels(large.frame$myfactor)) should do it. Best, Ista On Thu, Apr 7, 2011 at 11:47 AM, Dimitri Liakhovitski dimitri.liakhovit...@gmail.com wrote: Hello! I have larger and a smaller data frame with 1 factor in each - it's the same factor: large.frame-data.frame(myfactor=LETTERS[1:10]) small.frame-data.frame(myfactor=LETTERS[c(9,7,5,3,1)]) levels(large.frame$myfactor) levels(small.frame$myfactor) table(large.frame$myfactor) table(small.frame$myfactor) myfactor has 10 levels in large.frame and 5 levels in small.frame. All 5 levels in small.frame are present in large.frame. How could I make levels(small.frame$myfactor) contain all the same levels as levels(large.frame$myfactor)? In other words, I want table(small.frame$myfactor) to have the same number of entries as table(small.frame$myfactor) but with 5 zeros in it: A B C D E F G J I J 1 0 1 0 1 0 1 0 1 0 Thank you very much for your suggestions! -- Dimitri Liakhovitski Ninah Consulting www.ninah.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. -- Ista Zahn Graduate student University of Rochester Department of Clinical and Social Psychology http://yourpsyche.org __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R licence
If the discussion on the GPL Wikipedia page (http://en.wikipedia.org/wiki/GNU_General_Public_License ) is representative, you are not alone but nevertheless it is not clear-cut either. The debate revolves around the definition of derived work for software. If you fall into the camp that believes any call to a Linux-specific system call makes the calling program a derivative of Linux, then your example is clearly a violation. I think the majority view is that there are categories of linkage that remove the derived work designation even when the caller is useless without the callee. The GPLv3 implicitly acknowledges this as it addresses situations where the proprietary elements of a mixed system of proprietary and GPLed software impose constraints on substituting modified versions of the free software components (tivoization). Short answer: the proprietary parts are asserted not to be derived works. You are free to disagree, but only the judges' opinions count. --- Jeff Newmiller The . . Go Live... DCN:jdnew...@dcn.davis.ca.us Basics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/Batteries O.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --- Sent from my phone. Please excuse my brevity. Matthew Dowle mdo...@mdowle.plus.com wrote: Duncan, Letting you know then that I just don't see how the first paragraph here : http://www.revolutionanalytics.com/downloads/gpl-sources.php is compatible with clause 2(b) here : http://www.gnu.org/licenses/gpl-2.0.html Perhaps somebody could explain why it is? Matthew Duncan Murdoch murdoch.dun...@gmail.com wrote in message news:4d9da9ff.9020...@gmail.com... On 07/04/2011 7:47 AM, Matthew Dowle wrote: Peter, If the proprietary part of REvolution's product is ok, then surely Stanislav's suggestion is too. No? Revolution has said that they believe they follow the GPL, and they haven't been challenged on that. If you think that they don't, you could let an R copyright holder know what they're doing that's a license violation. My opinion of Stanislav's question is that he doesn't give enough information to answer. If he is planning to distribute R as part of his product, he needs to follow the GPL. If not, I don't think any R copyright ho lder has anything to complain about. Duncan Murdoch Matthewpeter dalgaardpda...@gmail.com wrote in message news:be157cf5-9b4b-45a0-a7d4-363b774f1...@gmail.com... On Apr 7, 2011, at 09:45 , Stanislav Bek wrote: Hi, is it possible to use some statistic computing by R in proprietary software? Our software is written in c#, and we intend to use http://rdotnet.codeplex.com/ to get R work there. Especially we want to use loess function. You need to take legal advice to be certain, but offhand I would say that this kind of circumvention of the GPL is _not_ allowed. It all depends on whether the end product is a derivative work, in which case, the whole must be distributed under a GPL-compatible licence. The situation around GPL-incompatible plug-ins or plug-ins interfacing to R in GPL -incompatible software is legally murky, but using R as a subroutine library for proprietary code is clearly crossing the line, as far as I can tell. -- Peter Dalgaard 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-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Adding text to page margin with lattice graphics
R: 2.12.1 OS X Colleagues I am working with lattice graphics for the first time and I am confused by some aspects of controlling these graphics. The most pressing issue is the following: I can print the graphics without problems with the command: print(MYFUNCTION(SOMEOBJECT) However, I would like to add margin text (this terminology might not apply in this setting). I am able to do so with the following command: print(MYFUNCTION(SOMEOBJECT, page=function(page) grid.text(SOMETEXT, x=0.5, y=0.01))) Two issues: 1. The added text overlaps text in SOMEOBJECT. How do I reserve space at the margins of the page in which I can print the added text? (the equivalent of par(mar=c(1,1,1,1))) 2. I was able to construct the command with some assistance from a colleague. But, I remain at a loss to understand the syntax: page=function(page), i.e., page is a function of itself? Any help in interpreting the function would be appreciated. Dennis Dennis Fisher MD P (The P Less Than Company) Phone: 1-866-PLessThan (1-866-753-7784) Fax: 1-866-PLessThan (1-866-753-7784) www.PLessThan.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] plyr workaround to converting by() to a data frame
Dear all Is there a clean plyr version of the following by() and do.call(rbind, ...) construct: df-data.frame(a=1:10,b=11:20,c=21:30,grp1=c(x,y),grp2=c(x,y),grp3=c(x,y)) dfsum-by(df[c(a,b,c)], df[c(grp1,grp2,grp3)], range) as.data.frame(dfsum) Error in as.data.frame.default(dfsum) : cannot coerce class 'by' into a data.frame do.call(rbind, dfsum) [,1] [,2] [1,]1 29 [2,]2 30 Thank you Liviu -- Do you know how to read? http://www.alienetworks.com/srtest.cfm http://goodies.xfce.org/projects/applications/xfce4-dict#speed-reader Do you know how to write? http://garbl.home.comcast.net/~garbl/stylemanual/e.htm#e-mail __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Assigning a larger number of levels to a factor that has fewer levels
Thanks a lot, Ista! On Thu, Apr 7, 2011 at 11:52 AM, Ista Zahn iz...@psych.rochester.edu wrote: Hi Dimitri, The factor() function allows you to specify the levels. So small.frame$myfactor - factor(small.frame$myfactor, levels = levels(large.frame$myfactor)) should do it. Best, Ista On Thu, Apr 7, 2011 at 11:47 AM, Dimitri Liakhovitski dimitri.liakhovit...@gmail.com wrote: Hello! I have larger and a smaller data frame with 1 factor in each - it's the same factor: large.frame-data.frame(myfactor=LETTERS[1:10]) small.frame-data.frame(myfactor=LETTERS[c(9,7,5,3,1)]) levels(large.frame$myfactor) levels(small.frame$myfactor) table(large.frame$myfactor) table(small.frame$myfactor) myfactor has 10 levels in large.frame and 5 levels in small.frame. All 5 levels in small.frame are present in large.frame. How could I make levels(small.frame$myfactor) contain all the same levels as levels(large.frame$myfactor)? In other words, I want table(small.frame$myfactor) to have the same number of entries as table(small.frame$myfactor) but with 5 zeros in it: A B C D E F G J I J 1 0 1 0 1 0 1 0 1 0 Thank you very much for your suggestions! -- Dimitri Liakhovitski Ninah Consulting www.ninah.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. -- Ista Zahn Graduate student University of Rochester Department of Clinical and Social Psychology http://yourpsyche.org -- Dimitri Liakhovitski Ninah Consulting www.ninah.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] Regrouping data
Try this: 1) xtabs(values ~ name + period + cy_date, rat_dat) 2) as.Date(rat_dat$cy_date, '%d-%b-%y') - as.Date(rat_dat$period, '%d-%b-%y') On Thu, Apr 7, 2011 at 9:03 AM, Sandeepa Ramakrishnan sandeepa_ramakrish...@yahoo.com wrote: Dear R forum I have just started my venture with R. While I am trying to learn R through the tutorials, I think the current problem I need to address to is beyond my knowledge about R. I have a dataframe as defined below - rat_dat = data.frame(name = c(A, A, A, B, B, B, C, C, C, D, D, D), period = c(31-Mar-11, 30-Mar-11, 29-Mar-11, 31-Mar-11, 30-Mar-11, 29-Mar-11, 31-Mar-11, 30-Mar-11, 29-Mar-11, 31-Mar-11, 30-Mar-11, 29-Mar-11), cy_date = c(31-May-11,31-May-11, 31-May-11, 31-May-11, 31-May-11, 31-May-11, 31-May-11, 31-May-11, 31-May-11, 31-May-11, 31-May-11, 31-May-11), values = c(10.42, 10.46, 10.37, 12.62, 12.65, 12.61, 14.10, 14.12, 14.08, 11.11, 11.15, 11.17)) rat_dat name period cy_date values 1 A 31-Mar-11 31-May-11 10.42 2 A 30-Mar-11 31-May-11 10.46 3 A 29-Mar-11 31-May-11 10.37 4 B 31-Mar-11 31-May-11 12.62 5 B 30-Mar-11 31-May-11 12.65 6 B 29-Mar-11 31-May-11 12.61 7 C 31-Mar-11 31-May-11 14.10 8 C 30-Mar-11 31-May-11 14.12 9 C 29-Mar-11 31-May-11 14.08 10 D 31-Mar-11 31-May-11 11.11 11 D 30-Mar-11 31-May-11 11.15 12 D 29-Mar-11 31-May-11 11.17 My actual data is too large. I need to (1) rearrange this input as period cy_date A B C D 31-Mar-11 31-May-11 10.42 12.62 14.10 11.11 30-Mar-11 31-May-11 10.46 12.65 14.12 11.15 29-Mar-11 31-May-11 10.37 12.61 14.08 11.17 (2) Also, I need to find the difference between (rat_dat$cy_date) - (rat_dat$period) I hope I am able to put forward my requirement properly. If not, please forgive me. Sandeepa [[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. -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40 S 49° 16' 22 O __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] plyr workaround to converting by() to a data frame
Is this what you are looking for? ddply ( .variables = c(grp1, grp2, grp3 ), .data = df, .fun = plyr::summarize, abmin = min(c(a, b, c) ), abmax = max ( c ( a, b, c) ) ) - Original message - From: Liviu Andronic landronim...@gmail.com To: r-help@r-project.org Help r-help@r-project.org Date: Thu, 7 Apr 2011 18:39:30 +0200 Subject: [R] plyr workaround to converting by() to a data frame Dear all Is there a clean plyr version of the following by() and do.call(rbind, ...) construct: df-data.frame(a=1:10,b=11:20,c=21:30,grp1=c(x,y),grp2=c(x,y),grp3=c(x,y)) dfsum-by(df[c(a,b,c)], df[c(grp1,grp2,grp3)], range) as.data.frame(dfsum) Error in as.data.frame.default(dfsum) : cannot coerce class 'by' into a data.frame do.call(rbind, dfsum) [,1] [,2] [1,]1 29 [2,]2 30 Thank you Liviu -- Do you know how to read? http://www.alienetworks.com/srtest.cfm http://goodies.xfce.org/projects/applications/xfce4-dict#speed-reader Do you know how to write? http://garbl.home.comcast.net/~garbl/stylemanual/e.htm#e-mail __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Randomisation tests
Hi, I want to ue a randomisation test, to compare two sample means, for a small set of data, I've looked at towt.permutation, perm.test and permtest, as well as permTS(), which is the best one to use for such a simple purpose? I know perm.test package isn't used anymore and coins recommended, but reading the manual I couldnt find the function most like it, ore more likely I didn't understand the lingo used to know it's what I wanted. Thanks, Ben. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] An extention of outer() ?
Dear all, as per my understanding, outer() function is to facilitate 2-dimensional function evaluation, like to evaluate f(x,y) for different values of x and y. However I have slightly modified version of that, where x is a matrix with, say, 5 rows and 2 columns and y is a vector. Let take following example: fn1 - function(x1, x2, y) return (x1+x2+y) x - matrix(1:10, nc = 2) y - 1:5 with this input, I want to construct a 5x5 matrix whose (1,1)th element will be : fn1(x[1,1], x[1,2], y[1]), (1,2)th element will be : fn1(x[1,1], x[1,2], y[2]). (1,5)th element will be : fn1(x[1,1], x[1,2], y[5]).similarly (2,1)th element will be : fn1(x[2,1], x[2,2], y[1])etc If my 'x' object is a vector then I can easily use outer() function effectively. However for my present case, I am looking for some ***outer() like function*** to get the result effectively. Can somebody help me on how can I do that without using any for loop? Thanks and regards, [[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] An extention of outer() ?
Try this: aperm(outer(x, y, fn1, y), c(3, 1, 2))[,,2] On Thu, Apr 7, 2011 at 3:21 PM, Bogaso Christofer bogaso.christo...@gmail.com wrote: Dear all, as per my understanding, outer() function is to facilitate 2-dimensional function evaluation, like to evaluate f(x,y) for different values of x and y. However I have slightly modified version of that, where x is a matrix with, say, 5 rows and 2 columns and y is a vector. Let take following example: fn1 - function(x1, x2, y) return (x1+x2+y) x - matrix(1:10, nc = 2) y - 1:5 with this input, I want to construct a 5x5 matrix whose (1,1)th element will be : fn1(x[1,1], x[1,2], y[1]), (1,2)th element will be : fn1(x[1,1], x[1,2], y[2]). (1,5)th element will be : fn1(x[1,1], x[1,2], y[5]).similarly (2,1)th element will be : fn1(x[2,1], x[2,2], y[1])etc If my 'x' object is a vector then I can easily use outer() function effectively. However for my present case, I am looking for some ***outer() like function*** to get the result effectively. Can somebody help me on how can I do that without using any for loop? Thanks and regards, [[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. -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40 S 49° 16' 22 O __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Grid on Map
Hi, I tried it using abline but it is not showing any o/p(i.e no grids are formed on map). I did following : map('state','new york',proj='azequalarea',orient=c(42.5,-74.56,0)) abline(h=seq(41, 44, length=3)) abline(v=seq(-79, -76, length=3)) I also tried using map.grid() but in some cases it is dividing into exact 4 quadrants. On Wed, Apr 6, 2011 at 2:49 PM, MacQueen, Don macque...@llnl.gov wrote: Possibly something similar to abline(v=seq(long.min, long.max, length=3) abline(h=seq(lat.min, lat.max, length=3) ? The above will add vertical and horizontal lines to an existing plot, and assumes that the plot is in long/lat coordinates. Of course, this ignores the fact that long/lat is not a cartesian coordinate system. (can't provide more detail without more information) -Don -- Don MacQueen Lawrence Livermore National Laboratory 7000 East Ave., L-627 Livermore, CA 94550 925-423-1062 -Original Message- From: Jaimin Dave davejaim...@gmail.com Date: Mon, 4 Apr 2011 18:39:45 -0700 To: r-help@r-project.org r-help@r-project.org Subject: [R] Grid on Map I am new to R.I want to draw grid from a csv file which contains latitude minimum ,latitude maximum ,longitude minimum ,longitude maximum.The grid should be divided into exactly 4 quadrants. The map is of NY state of USA. I want to know how can I do it. Help would be appreciated. Thanks Jaimin [[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] classification
Dear all, this is not a pure R question, but really about how to set up a multinomial logistic regression model to do a multi-class classification. I would really appreciate if any of you would give me some of your thoughts and recommendation. Let's say we have 3-class classification problem: A, B and C. I have certain number of samples, with each sample, I have 3 variables (Xa, Xb and Xc). The trick here is that these 3 variables measures the extent of the likelihood of the samples being class A, B and C, i.e., Xa for class A, Xb for class B and Xc for class C. For a given sample i, we can simply make a rough prediction based on the values of Xa, Xb and Xc. For example: for sample 1, Xa=10, Xb=50, Xc=15, then most likely I would predict sample 1 as class B. Then I have another set of variables Ya, Yb and Yc doing similar things. I can construct a dataset as below: Xa XbXc Ya Yb Yc class sample 1 10 50150.2 0.8 0.1 B sample 2 84 6 0.7 0.5 0.3 A : : and then make a model fit-multinom(class~Xa+Xb+Xc+Ya+Yb+Yc) But my understanding is that this model is not working in a way of by simply looking at each row of the data and pick the class that has the best Xs and/or Ys. In leave-one-out, sometimes it picks up a class that apparently is not a winner if I compare across Xs and Ys. Greatly appreciate if anyone can suggest a more sensible way to construct the data and/or a different way of thinking of the problem at all. John [[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] Panel data - replicating Stata's xtpcse in R
Dear list, I am trying to replicate an econometrics study that was orginally done in Stata. (Blanton and Blanton. 2009. A Sectoral Analysis of Human Rights and FDI: Does Industry Type Matter? International Studies Quarterley 53 (2):469 - 493.) The model I try to replicate is in Stata given as xtpcse total_FDI lag_total ciri human_cap worker_rts polity_4 market income econ_growth log_trade fix_dollar fixed_xr xr_fluct lab_growth english, pairwise corr(ar1) According to the paper, this is an OLS regression with panel corrected standard errors including a lagged dependent variable (lag_total is total_FDI t-1) and controlling first order correlations within each panel (corr(ar1)). The BIG QUESTION is how to replicate this line in R. Econometrics is a new field to me, but a bit of searching showed that packages like plm, nlme, pcse should be able to handle this kind of problem. In particular, function gls() uses auto-correlation structure and pcse() corrects the standard errors of the fitted model. Below is some code to show what I have done, and some problems I ran into. ## setup and load data from web library(foreign) library(nlme) library(pcse) D - read.dta(http://umdrive.memphis.edu/rblanton/public/ISQ_data/blanton_isq08_data.dta;) D[544,year] - 2005 ## fixing an unexpected NA in the year column ## Model formula form - total_FDI ~ lag_total + ciri + human_cap + worker_rts + polity_4 + market_size + income + econ_growth + log_trade + fixed_xr + fix_dollar + xr_fluct + english + lab_growth ## Model 1: no auto-correlation res1 - gls(model=form, data=D,correlation=NULL,na.action=na.omit) coefficients(res1) ## Model 2: with auto-correlation corr - corAR1(.1,~1|c_name) res2 - gls(model=form, data=D,correlation=corr,na.action=na.omit) coefficients(res2) Now, I know from the paper how the Stata coefficients looked like. For example, for log_total it should be .852 and for market_size .21 (these were the two significant ones). The result of Model1 is closer to this than the result of Model 2, but there is still quite a gap. The goal is to do OLS on panel data with AR(1) and PCSE - am I on the right track here? More specifically: Question 1: Auto-correlation - how to specify the parameter 'value' in corAR1 (the .1 above is completely arbitrary) - Any other ideas how to translate Stata's corr(AR1) into R? (I'm not even completely sure what Stata does there and didn't find any details in the online manuals) Question 2: PCSE - the pcse function seems to work on objects of class 'lm' only. Any way to use it for gls-objects? Any help is greatly appreciated! Florian -- Florian Markowetz Cancer Research UK Cambridge Research Institute Li Ka Shing Centre Robinson Way, Cambridge, CB2 0RE, UK phone: +44 (0) 1223 40 4315 email: florian.markow...@cancer.org.uk web : http://www.markowetzlab.org skype: florian.markowetz This communication is from Cancer Research UK. Our website is at www.cancerresearchuk.org. We are a registered charity in England and Wales (1089464) and in Scotland (SC041666) and a company limited by guarantee registered in England and Wales under number 4325234. Our registered address is Angel Building, 407 St John Street, London, EC1V 4AD. Our central telephone number is 020 7242 0200. This communication and any attachments contain information which is confidential and may also be privileged. It is for the exclusive use of the intended recipient(s). If you are not the intended recipient(s) please note that any form of disclosure, distribution, copying or use of this communication or the information in it or in any attachments is strictly prohibited and may be unlawful. If you have received this communication in error, please notify the sender and delete the email and destroy any copies of it. E-mail communications cannot be guaranteed to be secure or error free, as information could be intercepted, corrupted, amended, lost, destroyed, arrive late or incomplete, or contain viruses. We do not accept liability for any such matters or their consequences. Anyone who communicates with us by e-mail is taken to accept the risks in doing so. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Problem Installing rJava on MS Win 7 Platform
Thanks for the reply. Yes, you are quite correct, but: install.packages('rJava') Warning in install.packages(rJava) : argument 'lib' is missing: using 'C:\Users\Stephen\Documents/R/win64-library/2.11' --- Please select a CRAN mirror for use in this session --- Warning: unable to access index for repository http://www.stats.ox.ac.uk/pub/RWin/bin/windows64/contrib/2.11 trying URL 'http://cran.case.edu/bin/windows64/contrib/2.11/rJava_0.8-5.zip' Content type 'application/zip' length 658913 bytes (643 Kb) opened URL downloaded 643 Kb package 'rJava' successfully unpacked and MD5 sums checked The downloaded packages are in C:\Users\Stephen\AppData\Local\Temp\Rtmpcy0hAb\downloaded_packages install.packages('C;\Users\Stephen\AppData\Local/Temp/Rtmpcy0hAb\downloaded_ $ Error: '\U' used without hex digits in character string starting C;\U So, obviously, at this point I am attempting something that R does not like. Stephen P. Molnar, Ph.D. Life is a fuzzy set Foundation for Chemistry Stochastic and multivriate http://www.FoundationForChemistry.com -Original Message- From: Uwe Ligges [mailto:lig...@statistik.tu-dortmund.de] Sent: Thursday, April 07, 2011 11:34 AM To: Stephen P Molnar Cc: r-help@r-project.org Subject: Re: [R] Problem Installing rJava on MS Win 7 Platform You failed to install an appropriate Java version. Best, Uwe Ligges On 07.04.2011 16:30, Stephen P Molnar wrote: I'm a new R user and, frankly, this problem has got me stumped. I'm using the 64 bit version of RGui and followed the installation instructions on http://www.rforge.net/rJava/ Here is the result: package 'rJava' successfully unpacked and MD5 sums checked library(rJava) Error in utils::readRegistry(key, HLM, 2) : Registry key 'Software\JavaSoft\Java Runtime Environment' not found Error in utils::readRegistry(key, HLM, 2) : Registry key 'Software\JavaSoft\Java Development Kit' not found Error : .onLoad failed in loadNamespace() for 'rJava', details: call: fun(...) error: JAVA_HOME cannot be found from the Registry Error: package/namespace load failed for 'rJava' I don't Have the faintest idea as t what I've done, or failed to do. Assistance will be greatly appreciated. Thanks in advance. Stephen P. Molnar, Ph.D. Life is a fuzzy set Foundation for Chemistry Stochastic and multivriate http://www.FoundationForChemistry.com [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 reading data help please
Dear Readers, Sorry to bother you. Have been try to read my data into R (something I have done in the past) but having an error message with this one. Any possible help please? Thanks. Oz This is the error I am getting (please see bold): setwd(D:/Replication/) library(gmp) dataFrame2=read.table(data.txt,header=T) Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings, : line 1 did not have 58 elements [[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] df with max function applied to 6 lags of a variable?!?
Hello everyone! I have a data frame of 136 variables with 270 observations. I would like to create a new data frame such that each element of that data frame contains the maximum value of the 6 prior lags of the initial data frame. So for example, if my original data frame, A, were A1=c(7.72, 7.94, 7.56, 7.54, 0.93, 0.59, 7.21, 8.00, 7.19, 7.57)A2=c(4.27, 3.70, 3.80, 3.67, 3.83, 3.95, 4.02, 2.06, 3.28, 2.17)A3=c(4.16, 2.91, 3.89, 3.73, 4.00, 3.81, 3.86, 1.88, 3.74, 3.75)A4=c(3.56, 3.27, 3.42, 3.32, 3.48, 3.54, 3.60, 2.04, 3.38, 3.37)A5=c(8.24, 8.67, 8.49, 0.00, 9.39, 0.00, 8.49, 8.94, 0.00, 0.00)A6=c(4.28, 4.18, 4.20, 4.14, 4.40, 4.20, 4.20, 4.15, 4.17, 4.16) A - cbind(A1, A2, A3, A4, A5, A6) My new data frame, Amax, where each element is amax(i,j)=max[a(i-1,j), a(i-2,j), a(i-3,j), a(i-4,j), a(1-5,j), a(i-6,j)] would be:NA NA NA NA NANA NA NA NA NA NANA NA NA NA NA NANA NA NA NA NA NANA NA NA NA NA NANA NA NA NA NA NANA 7.94 4.27 4.16 3.56 9.39 4.40 7.94 4.02 4.00 3.60 9.39 4.40 8.00 4.02 4.00 3.60 9.39 4.40 8.00 4.02 4.00 3.60 9.39 4.40 8.00 4.02 4.00 3.60 9.39 4.40 So the question is: what is the most efficient way of doing this in R? Thanks!Rita If you think education is expensive, try ignorance--Derek Bok [[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] error reading data help please
Hi Oz, On Thu, Apr 7, 2011 at 10:47 AM, Ouattara b.ouatt...@swansea.ac.uk wrote: Dear Readers, Sorry to bother you. Have been try to read my data into R (something I have done in the past) but having an error message with this one. Any possible help please? Thanks. Oz This is the error I am getting (please see bold): This listserv only uses plain text emails (which is how the posting guide respectfully requests you submit all queries). HTML emails are converted to plain text, so bold does not come through to us. setwd(D:/Replication/) library(gmp) dataFrame2=read.table(data.txt,header=T) Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings, : line 1 did not have 58 elements Assuming the data file is not malformed, try using a different delimitter. read.table() defaults to using space (sep = ) I think, but your data may be tab delimitted (sep = \t), or comma (sep = ,), or ... If you are not certain, open your data in a regular text editor, and see what sort of stuff is in between each cell (i.e., how can you tell where one cell stops and another starts). I think space, commas, and tabs, are the most common, but there are many others. More generally, look through the documentation for ?read.table to get ideas for what different arguments you might try to properly read in your data. Hope this helps, Josh [[alternative HTML version deleted]] ^^ This is the part I mentioned where the list deletes HTML and only sends us the plain text. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html ^^ This is where you could have read that the list only sends plain text. and provide commented, minimal, self-contained, reproducible code. -- Joshua Wiley Ph.D. Student, Health Psychology University of California, Los Angeles http://www.joshuawiley.com/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Problem Installing rJava on MS Win 7 Platform
He said Java, not rJava. On Apr 7, 2011, at 11:51 AM, Stephen P Molnar wrote: Thanks for the reply. Yes, you are quite correct, but: install.packages('rJava') Warning in install.packages(rJava) : argument 'lib' is missing: using 'C:\Users\Stephen\Documents/R/win64-library/2.11' --- Please select a CRAN mirror for use in this session --- Warning: unable to access index for repository http://www.stats.ox.ac.uk/pub/RWin/bin/windows64/contrib/2.11 trying URL 'http://cran.case.edu/bin/windows64/contrib/2.11/rJava_0.8-5.zip' Content type 'application/zip' length 658913 bytes (643 Kb) opened URL downloaded 643 Kb package 'rJava' successfully unpacked and MD5 sums checked The downloaded packages are in C:\Users\Stephen\AppData\Local\Temp\Rtmpcy0hAb \downloaded_packages install.packages('C;\Users\Stephen\AppData\Local/Temp/Rtmpcy0hAb \downloaded_ There is a semi-colon in that path above that looks wrong. You might first want to check that all your PATH entries are recorded properly. -- David. $ Error: '\U' used without hex digits in character string starting C; \U So, obviously, at this point I am attempting something that R does not like. Stephen P. Molnar, Ph.D. Life is a fuzzy set Foundation for Chemistry Stochastic and multivriate http://www.FoundationForChemistry.com -Original Message- From: Uwe Ligges [mailto:lig...@statistik.tu-dortmund.de] Sent: Thursday, April 07, 2011 11:34 AM To: Stephen P Molnar Cc: r-help@r-project.org Subject: Re: [R] Problem Installing rJava on MS Win 7 Platform You failed to install an appropriate Java version. Best, Uwe Ligges On 07.04.2011 16:30, Stephen P Molnar wrote: I'm a new R user and, frankly, this problem has got me stumped. I'm using the 64 bit version of RGui and followed the installation instructions on http://www.rforge.net/rJava/ Here is the result: package 'rJava' successfully unpacked and MD5 sums checked library(rJava) Error in utils::readRegistry(key, HLM, 2) : Registry key 'Software\JavaSoft\Java Runtime Environment' not found Error in utils::readRegistry(key, HLM, 2) : Registry key 'Software\JavaSoft\Java Development Kit' not found Error : .onLoad failed in loadNamespace() for 'rJava', details: call: fun(...) error: JAVA_HOME cannot be found from the Registry Error: package/namespace load failed for 'rJava' I don't Have the faintest idea as t what I've done, or failed to do. Assistance will be greatly appreciated. Thanks in advance. Stephen P. Molnar, Ph.D. Life is a fuzzy set Foundation for Chemistry Stochastic and multivriate http://www.FoundationForChemistry.com [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. David Winsemius, MD West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] metaplot
Actually, Scott suggested ggplot2, which is available on CRAN: http://cran.r-project.org/web/packages/ggplot2/index.html Moreover, for the metafor package, you do not need (a,b,c,d) or standard errors for the effect estimates. rr - c(0.61, 0.35, 1.16, 0.94, 1.16, 0.46, 0.99, 1.05, 1.15, 0.27) lci - c(-1.69, -1.27, -0.24, -0.54, -1.01, -1.8,-0.89, -1.38, -1.05,-2.04) uci - c(0.70, -0.82,0.54,0.41,1.30,0.24,0.87,1.48,1.33,-0.57) The lci and uci values are obviously the log-transformed values of the upper and lower CI bounds for the RR. So, you could do: library(metafor) forest(log(rr), ci.lb=lci, ci.ub=uci, xlab=Log Relative Risk) or: forest(log(rr), ci.lb=lci, ci.ub=uci, xlab=Relative Risk, atransf=exp) help(forest.default) will tell you more about using the forest() function. Best, -- Wolfgang Viechtbauer Department of Psychiatry and Neuropsychology School for Mental Health and Neuroscience Maastricht University, P.O. Box 616 6200 MD Maastricht, The Netherlands Tel: +31 (43) 368-5248 Fax: +31 (43) 368-8689 Web: http://www.wvbauer.com From: r-help-boun...@r-project.org [r-help-boun...@r-project.org] On Behalf Of cheba meier [cheba.me...@googlemail.com] Sent: Thursday, April 07, 2011 4:11 PM To: Scott Chamberlain Cc: R-help@r-project.org; tlum...@uw.edu Subject: Re: [R] metaplot Many thanks for your reply! the Package ‘ggplot’ was removed from the CRAN repository. Formerly available versions can be obtained from the archivehttp://cran.r-project.org/src/contrib/Archive/ggplot(Unfortunately, I am a windows user). The metafor and meta.summaries() still need the (a,b,c,d) or standard errors for the effect estimates! I have the following data rr - c(0.61, 0.35, 1.16, 0.94, 1.16, 0.46, 0.99, 1.05, 1.15, 0.27) lci - c(-1.69, -1.27, -0.24, -0.54, -1.01, -1.8,-0.89, -1.38, -1.05,-2.04) uci - c(0.70, -0.82,0.54,0.41,1.30,0.24,0.87,1.48,1.33,-0.57) rrdata - data.frame(rr,lci,uci) I can compute standard errors from my data? but the results show different confidence interval? Many thanks in advance, Cheba 2011/4/6 Scott Chamberlain scttchamberla...@gmail.com What about the metafor package? Or just create your own plot. For example, using ggplot2 package: limits - aes(ymax = OR + (OR - 95%LCI), ymin = OR - (OR - 95%LCI)) ggplot(dataframe, aes(x = Study.Name, y = OR)) + geom_point() + geom_errobar(limits) Best, Scott On Wednesday, April 6, 2011 at 11:53 AM, cheba meier wrote: Dear all, I have a four variable: Stuy.Name, OR, 95%LCI and 95%UCI and I would like to create a meta analysis plot. I can't use meta.MH function in metaplot because I do not have n.trt, n.ctrl, col.trt, col.ctrl are not available! Is there an alternative way to do it? Many thanks in advance, Cheba [[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] An extention of outer() ?
Hi Henrique, thanks for your help. To be frank, I really could not understand the process going on there. I was trying with following code: x - matrix(1:10, nc = 2) y - 20:22 fn1 - function(x1, x2, y) return (x1-x2+y) outer(x, y, fn1, 1) , , 1 [,1] [,2] [1,] -18 -13 [2,] -17 -12 [3,] -16 -11 [4,] -15 -10 [5,] -14 -9 , , 2 [,1] [,2] [1,] -19 -14 [2,] -18 -13 [3,] -17 -12 [4,] -16 -11 [5,] -15 -10 , , 3 [,1] [,2] [1,] -20 -15 [2,] -19 -14 [3,] -18 -13 [4,] -17 -12 [5,] -16 -11 But could not really understand how I am getting those values. Would you please help on how those numbers are coming? Thanks and regards, -Original Message- From: Henrique Dallazuanna [mailto:www...@gmail.com] Sent: 07 April 2011 23:36 To: Bogaso Christofer Cc: r-help@r-project.org Subject: Re: [R] An extention of outer() ? Try this: aperm(outer(x, y, fn1, y), c(3, 1, 2))[,,2] On Thu, Apr 7, 2011 at 3:21 PM, Bogaso Christofer bogaso.christo...@gmail.com wrote: Dear all, as per my understanding, outer() function is to facilitate 2-dimensional function evaluation, like to evaluate f(x,y) for different values of x and y. However I have slightly modified version of that, where x is a matrix with, say, 5 rows and 2 columns and y is a vector. Let take following example: fn1 - function(x1, x2, y) return (x1+x2+y) x - matrix(1:10, nc = 2) y - 1:5 with this input, I want to construct a 5x5 matrix whose (1,1)th element will be : fn1(x[1,1], x[1,2], y[1]), (1,2)th element will be : fn1(x[1,1], x[1,2], y[2]). (1,5)th element will be : fn1(x[1,1], x[1,2], y[5]).similarly (2,1)th element will be : fn1(x[2,1], x[2,2], y[1])etc If my 'x' object is a vector then I can easily use outer() function effectively. However for my present case, I am looking for some ***outer() like function*** to get the result effectively. Can somebody help me on how can I do that without using any for loop? Thanks and regards, [[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. -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40 S 49° 16' 22 O __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Correlation Matrix
Listers, I have a question regarding correlation matrices. It is fairly straight forward to build a correlation matrix of an entire data frame. I simply use the command cor(MyDataFrame). However, what I would like to do is construct a smaller correlation matrix using just three of the variable out of my data set. When I run this: cor(MyDataFrame$variable1, MyDataFrame$variable2,MyDataFrame$variable3) I get an error. Is there a way to do this through a built in function or is this something I have to construct manually? Thanks [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Grid on Map
Have a look at ?mapproject When you use a projection with map(), you subsequently have to transform your lat/long coordinates to conform to the projection. HTH Ray Brownrigg On 8/04/2011 6:11 a.m., Jaimin Dave wrote: Hi, I tried it using abline but it is not showing any o/p(i.e no grids are formed on map). I did following : map('state','new york',proj='azequalarea',orient=c(42.5,-74.56,0)) abline(h=seq(41, 44, length=3)) abline(v=seq(-79, -76, length=3)) I also tried using map.grid() but in some cases it is dividing into exact 4 quadrants. On Wed, Apr 6, 2011 at 2:49 PM, MacQueen, Donmacque...@llnl.gov wrote: Possibly something similar to abline(v=seq(long.min, long.max, length=3) abline(h=seq(lat.min, lat.max, length=3) ? The above will add vertical and horizontal lines to an existing plot, and assumes that the plot is in long/lat coordinates. Of course, this ignores the fact that long/lat is not a cartesian coordinate system. (can't provide more detail without more information) -Don -- Don MacQueen Lawrence Livermore National Laboratory 7000 East Ave., L-627 Livermore, CA 94550 925-423-1062 -Original Message- From: Jaimin Davedavejaim...@gmail.com Date: Mon, 4 Apr 2011 18:39:45 -0700 To: r-help@r-project.orgr-help@r-project.org Subject: [R] Grid on Map I am new to R.I want to draw grid from a csv file which contains latitude minimum ,latitude maximum ,longitude minimum ,longitude maximum.The grid should be divided into exactly 4 quadrants. The map is of NY state of USA. I want to know how can I do it. Help would be appreciated. Thanks Jaimin [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Correlation Matrix
On 7 April 2011 12:09, Dmitry Berman ravenb...@gmail.com wrote: Listers, I have a question regarding correlation matrices. It is fairly straight forward to build a correlation matrix of an entire data frame. I simply use the command cor(MyDataFrame). However, what I would like to do is construct a smaller correlation matrix using just three of the variable out of my data set. When I run this: cor(MyDataFrame$variable1, MyDataFrame$variable2,MyDataFrame$variable3) I get an error. Is there a way to do this through a built in function or is this something I have to construct manually? You can use cbind(). cor(cbind(MyDataFrame$variable1, MyDataFrame$variable2,MyDataFrame$variable3) ) Jeremy __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.