Re: [R] xyplot and lwd
On Wed, Sep 4, 2013 at 1:45 PM, Daniel Hornung daniel.horn...@ds.mpg.dewrote: Hello, can it be that xyplot does not support the lwd argument? At least here, the following still shows thin lines, as opposed to the regular plot command: xyplot(Sepal.Length ~ Sepal.Width, data = iris, pch=4, lwd=4) On Thursday, September 05, 2013 00:33:32 Bert Gunter wrote: You should get no lines at all, as you have not specified that lines be drawn. Use the type argument to do so. xyplot(rnorm(5) ~1:5,pch=4) ## points only xyplot(rnorm(5) ~1:5,pch=4,type=b,lwd=4) ## points with thick lines read ?panel.xyplot carefully (the default panel function for xyplot) for details Cheers, Bert Hello Bert, no, maybe I expressed myself ambiguously: I was referring to the line thickness of the symbols, not a line between symbols: xyplot(rnorm(5) ~ 1:5, pch=4, lwd=4) versus plot(rnorm(5), 1:5, pch=4, lwd=4) I would like the points (4(x) in this case) to have thicker lines. Cheers, Daniel -- Max-Planck-Institute for Dynamics and Self-Organization Laboratory for Fluid Dynamics, Pattern Formation and Biocomplexity Biomedical Physics Group Am Fassberg 17 D-37077 Goettingen (+49) 551 5176 373 signature.asc Description: This is a digitally signed message part. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Question about R2 in pls package
Euna Jeong eaje...@gmail.com writes: I have questions about R2 used in pls (or multivariate analysis). Is R2 same with the square of the PCC (Pearson Correlation Coefficient)? If you read the manual for R2 in the pls package, it will tell you how R2 is calculated there, and that for _training_ data it is indeed PCC^2, but _not_ for cross-validation or test data. IMHO, R^2 only has a meaningful interpretation for training data. For test data or cross-validation, I prefer MSEP or RMSEP. -- Regards, Bjørn-Helge Mevik __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Problem with installing the TRR package
Do you know if R-3.0.1 is available for Linux Mint? Do you know how I can check it? De : John Kane [jrkrid...@inbox.com] Envoyé : mercredi 4 septembre 2013 17:31 À : BLANDENIER Lucien; r-help@R-project.org Objet : RE: [R] Problem with installing the TRR package The latest release (2013-05-16, Good Sport) R-3.0.1 so perhaps you need to upgrade to 3.0.1? John Kane Kingston ON Canada -Original Message- From: lucien.blanden...@unine.ch Sent: Wed, 4 Sep 2013 15:05:03 + To: r-help@r-project.org Subject: [R] Problem with installing the TRR package Dear all, I met some problems trying to install the TRR package. I runed the command : install.packages(TRR) I've received the following message : In getDependencies(pkgs, dependencies, available, lib) : package ‘TRR’ is not available (for R version 2.14.1) I'm in Linux Mint and it seems it that the R 2.14.1 is the latest version. Does someones could give some guidance how to install the TRR package? Regards Lucien __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. FREE 3D MARINE AQUARIUM SCREENSAVER - Watch dolphins, sharks orcas on your desktop! Check it out at http://www.inbox.com/marineaquarium __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Problem with installing the TRR package
I do not know Linux Mint, but what is always possible is to build R from sources on a UNIX system. Gesendet über den BlackBerry® Service von E-Plus. -Original Message- From: BLANDENIER Lucien lucien.blanden...@unine.ch Sender: r-help-bounces@r-project.orgDate: Thu, 5 Sep 2013 07:01:48 To: John Kanejrkrid...@inbox.com; r-help@R-project.orgr-help@r-project.org Subject: Re: [R] Problem with installing the TRR package Do you know if R-3.0.1 is available for Linux Mint? Do you know how I can check it? De : John Kane [jrkrid...@inbox.com] Envoyé : mercredi 4 septembre 2013 17:31 À : BLANDENIER Lucien; r-help@R-project.org Objet : RE: [R] Problem with installing the TRR package The latest release (2013-05-16, Good Sport) R-3.0.1 so perhaps you need to upgrade to 3.0.1? John Kane Kingston ON Canada -Original Message- From: lucien.blanden...@unine.ch Sent: Wed, 4 Sep 2013 15:05:03 + To: r-help@r-project.org Subject: [R] Problem with installing the TRR package Dear all, I met some problems trying to install the TRR package. I runed the command : install.packages(TRR) I've received the following message : In getDependencies(pkgs, dependencies, available, lib) : package ‘TRR’ is not available (for R version 2.14.1) I'm in Linux Mint and it seems it that the R 2.14.1 is the latest version. Does someones could give some guidance how to install the TRR package? Regards Lucien __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. FREE 3D MARINE AQUARIUM SCREENSAVER - Watch dolphins, sharks orcas on your desktop! Check it out at http://www.inbox.com/marineaquarium __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Problem with installing the TRR package
On 05-09-2013, at 09:01, BLANDENIER Lucien lucien.blanden...@unine.ch wrote: Do you know if R-3.0.1 is available for Linux Mint? Do you know how I can check it? Look on CRAN: http://cran.r-project.org/bin/linux/ubuntu/ Since Mint is derived from Ubuntu this should work. Berend De : John Kane [jrkrid...@inbox.com] Envoyé : mercredi 4 septembre 2013 17:31 À : BLANDENIER Lucien; r-help@R-project.org Objet : RE: [R] Problem with installing the TRR package The latest release (2013-05-16, Good Sport) R-3.0.1 so perhaps you need to upgrade to 3.0.1? John Kane Kingston ON Canada -Original Message- From: lucien.blanden...@unine.ch Sent: Wed, 4 Sep 2013 15:05:03 + To: r-help@r-project.org Subject: [R] Problem with installing the TRR package Dear all, I met some problems trying to install the TRR package. I runed the command : install.packages(TRR) I've received the following message : In getDependencies(pkgs, dependencies, available, lib) : package ‘TRR’ is not available (for R version 2.14.1) I'm in Linux Mint and it seems it that the R 2.14.1 is the latest version. Does someones could give some guidance how to install the TRR package? Regards Lucien __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. FREE 3D MARINE AQUARIUM SCREENSAVER - Watch dolphins, sharks orcas on your desktop! Check it out at http://www.inbox.com/marineaquarium __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] sparse PCA using nsprcomp package
Hi all, I am using nsprcomp() from nsprcomp package to run sparse PCA. The output is very much like regular PCA by prcomp() in that it provides sdev for standard deviation of principle components (PC). For regular PCA by prcomp(), we can easily calculate the percent of total variance explained by the first k PCs by using cumsum(obj$sdev^2) because these PCs are independent of each other so you can simply add up the variance of these PCs. For sparse PCA, as far as I understand, the generated PCs are not independent of each other anymore, so you can not simply add up variances to calculate percentage of variance explained by the first k PCs. For example, in the package of elasticnet where spca() also performs sparse PCA, one of the output from spca() is pev for percent explained variation which is based on so-called adjusted variance that adjusted for the fact that these variances of PCs are not independent anymore. My question is for nsprcomp, how can I calculate percent explained variation by using sdev when I know these PCs are not independent of each other? Thanks! 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] R Help
Hi everone and thanks for this service, I have a dataset which look like: X. IE.2003 IE.2004 IE.2005 IE.2006 IE.2007 IE.2008 IE.2009 IE.2010 14560 118958 187 475 571 76410471203 715 807 12737 105571 935 942 917 948 991 861 NA 541 15463 126514 NA 296 495 598 NA11921174 800 4402 34370 NA 82 395 67916541445 88 NA 6924 56280 668 863 851 8121211 799 NA 588 17910 146534 887 9711026 9661037 855 562 675 18428 151088 99 263 584 8321148 NA NA NA 17990 147181 93 169 670 5651491 6711219 518 15156 124148 NA 6801991 426 282 784 921 733 8906 71851 49129413771735 723 310 139 NA My deal is to do imputation, I was trying with library mice, method=pmm, but I get an error: too high correlation Which imputation can I use? I have tried with other methods in mice but the same error appears Thanks in advance, Teresa [[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 Help
Hello, Please stop to use R help for the subject of your mail. You already used it several times. You have been asked to stop to send e-mail in HTML. You also have been asked to use dput() when you want to submit data to this list. For the current problem, there is no reproducible code, as it is kindly requested. Regards, Pascal 2013/9/5 Mª Teresa Martinez Soriano teresama...@hotmail.com Hi everone and thanks for this service, I have a dataset which look like: X. IE.2003 IE.2004 IE.2005 IE.2006 IE.2007 IE.2008 IE.2009 IE.2010 14560 118958 187 475 571 76410471203 715 807 12737 105571 935 942 917 948 991 861 NA 541 15463 126514 NA 296 495 598 NA11921174 800 4402 34370 NA 82 395 67916541445 88 NA 6924 56280 668 863 851 8121211 799 NA 588 17910 146534 887 9711026 9661037 855 562 675 18428 151088 99 263 584 8321148 NA NA NA 17990 147181 93 169 670 5651491 6711219 518 15156 124148 NA 6801991 426 282 784 921 733 8906 71851 49129413771735 723 310 139 NA My deal is to do imputation, I was trying with library mice, method=pmm, but I get an error: too high correlation Which imputation can I use? I have tried with other methods in mice but the same error appears Thanks in advance, Teresa [[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] New Version of R 3.0.1 problems with installing Rcmdr
On 05.09.2013 04:19, alanidris wrote: I have been using R version 2.15.1 happly along side R Commander. I then tried to go through a fresh install using the latest version of R, R 3.0.1. The trouble started when I wanted to install Rcmdr, I kept getting an error message about previous installs of R Commander. I went through and deinstalled all versions of R and tried fresh installs. Still could not get R Commander installed using the Latest version of R. It is possible that restrictions placed on me through my work computer may be a factor. But I tried numerous times to deinstall all versions of R and reinstall R 3.0.1, but I could not install the R Commander package. I then deinstalled all versions of R and then decided to install an earlier verision of R. This time I was more succesfull and after a few repeated starts of R 2.15.1 i managed to get R Commander working. Talk about a frustrating effort, can any one put any light on this issue? I work at a University where firewalls may be a factor, but this is only a guess. Please dont get too technical I know very little of how R installs itself and finds out where various packages and modules are. PS I am using Windows 7 as the operating system. 1. You must not load a package such as Rcmdr prior to reinstalltion / update. 2. If this is installed on a network shared directory, all other members of your group have to unload the package. Uwe Ligges -- View this message in context: http://r.789695.n4.nabble.com/New-Version-of-R-3-0-1-problems-with-installing-Rcmdr-tp4675414.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] optim evils
Thanks for all replies. The problem occurred in the following context: A Gaussian one dimensional mixture (number of constituents, locations, variances all unknown) is to be fitted to data (as starting value to or in lieu of mixtools). A likelihood maximization is performed. I'll try to destill the code so that reproducible failure of L-BFGS-B occurs and post it here. Michael Meyer [[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] Capturing warnings with capture.output
Dear R-users, I would like to follow-up on a old thread by Hadley Wickham about capturing warnings with capture.output. My goal is to evaluate a function call and capture the results of the function call plus warning calls and messages if a warning is returned. For instance, in the following case, I would like to capture the 3 lines of text returned by R log(-1) [1] NaN Warning message: In log(-1) : NaNs produced In Hadley's thread, a combination of capture.output and a custom withWarnings function was proposed to capture warnings but this seems to only capture the warning message and the results of the function call. withWarnings - function(expr) { wHandler - function(w) { cat(w$message, \n) invokeRestart(muffleWarning) } withCallingHandlers(expr, warning = wHandler) } out - capture.output(withWarnings(log(-1))) out [1] NaNs produced [1] NaN In withWarnings, the wHandler function manipulate an object w, which I understand to be a list with a call and message levels. All my attempts to manipulate w$call failed because w$call is of class language. I don't know how to work with this class and I would appreciate any advise on how to process this type of object. Again, the goal is to store both call and message in the output of the withWarnings function. Thank you Sebastien __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Read a Google Spreadsheet?
I've also never had a problem with both 32 and 64 bit java installed. Best, Ista On Wed, Sep 4, 2013 at 9:50 PM, Joshua Wiley jwiley.ps...@gmail.com wrote: Hi Spencer, It really is not very hard, and I have never had issue with it: http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html Just download the x86 and x64 versions for your OS and install. Worst case, you need to add the directory to the PATH variable in Windows. I do this regularly so I can use/test either version of R. Cheers, Josh P.S. Emacs + ESS allows for different versions of R and it is not too difficult to use the 64 or 32 bit version... M-x R-version-architecture On Wed, Sep 4, 2013 at 6:36 PM, Spencer Graves spencer.gra...@structuremonitoring.com wrote: On 9/4/2013 6:09 PM, Ista Zahn wrote: Hi Spencer, Why don't you want to install 64bit Java? That may be a reasonable approach. I may have Java confused with something else, but I remember hearing that it was difficult or unwise to try to install both 32- and 64-bit versions of something like Java or Java Script on the same Windows operating system. If I need to uninstall 32-bit Java to install 64-bit, who knows what else I could break. I'm a statistician, not an information technologist: If I spend more time playing with Java, I'll have less time for other things I want to do. Thanks for the reply. Spencer On Wed, Sep 4, 2013 at 6:12 PM, Spencer Graves spencer.gra...@structuremonitoring.com wrote: Hello, All: What do you recommend for reading a Google Spreadsheet into R? I didn't find anything useful using library(sos); findFn('google spreadsheet'). I can solve the problem by downloading the file either as *.ods or *.xlsx format, then opening it and saving it as *.xls, then using read.xls{gdata}. Alternatives I haven't tried use read.xlsx{xlsx} and readWorksheetFromFile{XLConnect} with 32-bit R. Neither of these work for me with 64-bit R, because they can't find an appropriate rJava on my computer; see below. (I've been using 64-bit R with Emacs, so switching to 32-bit R is not completely trivial.) Similarly, read.gnumeric.sheet{gnumeric} requires the external program, ssconvert, which seems not to be available on my computer or installed for 64-bit R. What do you suggest? Avoid 64-bit R unless I really need it? That seems to be the message I'm getting from this. (The writeFindFn2xls{sos} also works in 32-bit R but fails in 64-bit apparently for the same reason.) Thanks, Spencer library(xlsx) Loading required package: xlsxjars Loading required package: rJava Error : .onLoad failed in loadNamespace() for 'rJava', details: call: fun(libname, pkgname) error: No CurrentVersion entry in Software/JavaSoft registry! Try re-installing Java and make sure R and Java have matching architectures. Error: package ‘rJava’ could not be loaded library(XLConnect) Loading required package: rJava Error : .onLoad failed in loadNamespace() for 'rJava', details: call: fun(libname, pkgname) error: No CurrentVersion entry in Software/JavaSoft registry! Try re-installing Java and make sure R and Java have matching architectures. Error: package ‘rJava’ could not be loaded sessionInfo() R version 3.0.1 (2013-05-16) Platform: x86_64-w64-mingw32/x64 (64-bit) locale: [1] LC_COLLATE=English_United States.1252 [2] LC_CTYPE=English_United States.1252 [3] LC_MONETARY=English_United States.1252 [4] LC_NUMERIC=C [5] LC_TIME=English_United States.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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. -- Joshua Wiley Ph.D. Student, Health Psychology University of California, Los Angeles http://joshuawiley.com/ Senior Analyst - Elkhart Group Ltd. http://elkhartgroup.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] xyplot and lwd
On Sep 5, 2013, at 2:54 AM, Daniel Hornung wrote: On Wed, Sep 4, 2013 at 1:45 PM, Daniel Hornung daniel.horn...@ds.mpg.dewrote: Hello, can it be that xyplot does not support the lwd argument? The lattice plotting system uses the grid plotting engine and does accepts some base par-type arguments but not all. You may need to read more about lattice and grid: ?lattice ?trellis.par.set require(grid) ?gpar -- David. At least here, the following still shows thin lines, as opposed to the regular plot command: xyplot(Sepal.Length ~ Sepal.Width, data = iris, pch=4, lwd=4) On Thursday, September 05, 2013 00:33:32 Bert Gunter wrote: You should get no lines at all, as you have not specified that lines be drawn. Use the type argument to do so. xyplot(rnorm(5) ~1:5,pch=4) ## points only xyplot(rnorm(5) ~1:5,pch=4,type=b,lwd=4) ## points with thick lines read ?panel.xyplot carefully (the default panel function for xyplot) for details Cheers, Bert Hello Bert, no, maybe I expressed myself ambiguously: I was referring to the line thickness of the symbols, not a line between symbols: xyplot(rnorm(5) ~ 1:5, pch=4, lwd=4) versus plot(rnorm(5), 1:5, pch=4, lwd=4) I would like the points (4(x) in this case) to have thicker lines. Cheers, Daniel David Winsemius, MD Alameda, CA, USA __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] xyplot and lwd
On Thursday, September 05, 2013 13:40:00 David Winsemius wrote: can it be that xyplot does not support the lwd argument? The lattice plotting system uses the grid plotting engine and does accepts some base par-type arguments but not all. You may need to read more about lattice and grid: ?lattice ?trellis.par.set require(grid) ?gpar Thanks for the hint, I will look further into this direction. Daniel -- Max-Planck-Institute for Dynamics and Self-Organization Laboratory for Fluid Dynamics, Pattern Formation and Biocomplexity Biomedical Physics Group Am Fassberg 17 D-37077 Goettingen (+49) 551 5176 373 signature.asc Description: This is a digitally signed message part. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Attribute Length Error when Trying plm Regression
Dear Laura, as Arun said it is difficult to help w/o a reproducible example. However this is most likely to be an indexing problem, as he suggests; the output of traceback() is far from useless here, because it shows that the problem occurs in the data transformation step. The latter, which is by default the within transf., wants (correct indexing and-) time variation in the data. Hence I suggest you - better check the data, especially indices, possibly with str() to see if they have the right type etc. then do simpler things, complicating step by step until you spot the critical one: - try lm(yourformula, yourdata) to see whether there are data problems w.r.t. OLS (unlikely, but would spot string variables or other common pitfalls) - try pdata.frame() using the individual and time index, to spot if the indices are somehow inappropriate - try plm(... , model=pooling), which does not transform the data, or model=random, which allows for time-invariants; both are more tolerant than within This is most likely either bad indices or bad data formats/NAs/empty groups... Best wishes, Giovanni Giovanni Millo, PhD Research Dept., Assicurazioni Generali SpA Via Machiavelli 3, 34132 Trieste (Italy) tel. +39 040 671184 fax +39 040 671160 Original thread -- Message: 48 Date: Wed, 4 Sep 2013 14:14:23 -0700 (PDT) From: arun smartpink...@yahoo.com To: lross8 lro...@kent.edu Cc: R help r-help@r-project.org Subject: Re: [R] Attribute Length Error when Trying plm Regression Message-ID: 1378329263.73618.yahoomail...@web142604.mail.bf1.yahoo.com Content-Type: text/plain; charset=iso-8859-1 HI, It is better to provide a reproducible example using ?dput(). you can also check in this link. http://r.789695.n4.nabble.com/names-attribute-must-be-the-same-length-as -the-vector-td4503946.html library(plm) #Using the example from ?plm() ?data(Produc, package = plm) ?zz - plm(log(gsp) ~ log(pcap) + log(pc) + log(emp) + unemp, data = Produc, index = c(state,year)) #Suppose, if I use a model like this: zz1- plm(gsp~pcap+pc+emp+unemp+water+util,data=Produc,index=c(gsp,year)) #Error in names(y) - namesy : ?# 'names' attribute [816] must be the same length as the vector [0] In your model statement, fixed - plm (h ~ o + m + a, data=drugsXX, index=c(h,year), model=within) A.K. - Original Message - From: lross8 lro...@kent.edu To: r-help@r-project.org Cc: Sent: Wednesday, September 4, 2013 3:22 PM Subject: [R] Attribute Length Error when Trying plm Regression Hello, I am trying to run a fixed effects panel regression on data containing 5 columns and 1,494 rows. I read the data in as follows: drugsXX-read.csv(file=C:\\Folder\\vX.X\\Drugs\\drugsXX_panel.csv, head=TRUE, sep=,) Verified it read in correctly and had a good data.frame: dim(drugsXX) [1] 1494? ? 5 drugs XX produce expected data with correct column names The issue is, when I go to run the plm using: fixed - plm (h ~ o + m + a, data=drugsXX, index=c(h,year), model=within) I get this error: Error in names(y) - namesy : ? 'names' attribute [996] must be the same length as the vector [0] I know the data recognizes that I have 5 columns. I also know that there's nothing wrong with row 996 (I even want back and checked for hidden characters in the original .csv file). traceback() was useless: 4: pmodel.response.pFormula(formula, data, model = model, effect = effect, ? ? ? theta = theta) 3: pmodel.response(formula, data, model = model, effect = effect, ? ? ? theta = theta) 2: plm.fit(formula, data, model, effect, random.method, inst.method) 1: plm(h ~ o + m + a, data = drugsXX, index = c(h, ? ? ? year), model = within) What explicit steps can I follow to get my panel regression to run? Thank you, Laura -- View this message in context: http://r.789695.n4.nabble.com/Attribute-Length-Error-when-Trying-plm-Reg ression-tp4675384.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. - end original thread -- Ai sensi del D.Lgs. 196/2003 si precisa che le informazi...{{dropped:12}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 with converting F to FALSE
Hi, I have a peculier problem in R-Project that is when my CSV file have one column with all values as 'F' the R-Project converting this 'F' to FALSE. Can some one please suggest how to stop this convertion. Because I want to use 'F' in my calculations and show it in screen. for example my data is like sex group F 1 F 2 F 3 but when I use read.csv and load the csv file data is converting it to sex group FALSE 1 FALSE 2 FALSE 3 but i want it as source data like sex group F 1 F 2 F 3 Thanks in advance, D V Kiran Kumar [[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 with converting F to FALSE
Look at colClasses in ?read.csv Date: Thu, 5 Sep 2013 18:14:49 +0530 From: kiran4u2...@gmail.com To: r-help@r-project.org Subject: [R] Problem with converting F to FALSE Hi, I have a peculier problem in R-Project that is when my CSV file have one column with all values as 'F' the R-Project converting this 'F' to FALSE. Can some one please suggest how to stop this convertion. Because I want to use 'F' in my calculations and show it in screen. for example my data is like sex group F 1 F 2 F 3 but when I use read.csv and load the csv file data is converting it to sex group FALSE 1 FALSE 2 FALSE 3 but i want it as source data like sex group F 1 F 2 F 3 Thanks in advance, D V Kiran Kumar [[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] Problem with converting F to FALSE
Hi, Try: dat1-read.table(text= sex group F 1 F 2 F 3 ,sep=,header=TRUE,colClasses=c(character,numeric)) dat1 # sex group #1 F 1 #2 F 2 #3 F 3 #if you are using read.csv() dat2-read.csv(new1.csv,sep=,header=TRUE,colClasses=c(character,numeric)) dat2 # sex group #1 F 1 #2 F 2 #3 F 3 #Suppose you want to convert after reading it: dat2New-read.csv(new1.csv,sep=,header=TRUE) dat2New[,1]-substr(dat2New[,1],1,1) dat2New # sex group #1 F 1 #2 F 2 #3 F 3 A.K. Hi, I have a peculier problem in R-Project that is when my CSV file have one column with all values as 'F' the R-Project converting this 'F' to FALSE. Can some one please suggest how to stop this convertion. Because I want to use 'F' in my calculations and show it in screen. for example my data is like sex group F 1 F 2 F 3 but when I use read.csv and load the csv file data is converting it to sex group FALSE 1 FALSE 2 FALSE 3 but i want it as source data like sex group F 1 F 2 F 3 Thanks in advance, D V Kiran Kumar __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Problem with converting F to FALSE
Hi, You can either manually specify colClasses or the asis argument. See ?read.csv for more details. If you just had those two columns, something like: read.table(header = TRUE, text = sex group F 1 T 2 , colClasses = c(character, integer)) Cheers, Josh read.csv(file.csv, colClasses = c(character, integer)) On Thu, Sep 5, 2013 at 5:44 AM, Venkata Kirankumar kiran4u2...@gmail.com wrote: Hi, I have a peculier problem in R-Project that is when my CSV file have one column with all values as 'F' the R-Project converting this 'F' to FALSE. Can some one please suggest how to stop this convertion. Because I want to use 'F' in my calculations and show it in screen. for example my data is like sex group F 1 F 2 F 3 but when I use read.csv and load the csv file data is converting it to sex group FALSE 1 FALSE 2 FALSE 3 but i want it as source data like sex group F 1 F 2 F 3 Thanks in advance, D V Kiran Kumar [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Joshua Wiley Ph.D. Student, Health Psychology University of California, Los Angeles http://joshuawiley.com/ Senior Analyst - Elkhart Group Ltd. http://elkhartgroup.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] Y-axis labels as decimal numbers
Hi, I am able to create a graph with this code but the decimal numbers are not plotted accurately because the ylim values are not set properly. x-axis is proper. How do I accurately set the ylim for duration.1 column ? Thanks, Mohan set1$duration- as.POSIXct(paste('2013-08-24', set1$duration)) plot(set1$duration,set1$duration.1,type=b,col = blue, ylab=, xaxt = 'n', xlab=,las=2,lwd=2.5, lty=1,cex.axis=2.5) # now plot you times axis(1, at = set1$duration, labels = set1$duration, las = 2,cex.axis=2.5) duration duration.1 2 16:03:41 0.05 3 17:03:41 0.27 4 18:03:43 1.22 5 19:03:45 1.51 6 20:03:47 1.27 7 21:03:48 1.15 8 22:03:50 1.22 9 23:03:52 1.27 10 00:03:54 1.27 11 01:03:55 1.22 12 02:03:57 1.26 13 03:03:59 1.57 14 04:04:01 1.31 15 05:04:03 1.24 This e-Mail may contain proprietary and confidential information and is sent for the intended recipient(s) only. If by an addressing or transmission error this mail has been misdirected to you, you are requested to delete this mail immediately. You are also hereby notified that any use, any form of reproduction, dissemination, copying, disclosure, modification, distribution and/or publication of this e-mail message, contents or its attachment other than by its intended recipient/s is strictly prohibited. Visit us at http://www.polarisFT.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] ggplot2: connecting medians of boxes using facet_wrap. Changing median marker.
# Dear all, # Thank you for taking your time. # What I would like to do: # (Run the code below to see what I am referring to) # I want lines connecting the medians of of the boxes. I do not want a function, just a simple, # straight connection between points. I also would like the lines to be different: lty=c(1:3) # Furthermore, I wish to change the line/dot marking the medians to be pch=c(1:3). It seems not to be so simple when using facet_wrap? I have obviously missed something obvious. # Finally, I would like the boxes to be filled white and to have the legend reflecting this. # I know that this was many questions, I apologize if some may seem basic. It is just that I am # jumping packages the whole time and sometimes par() adjustments work and sometimes not. # I have searched alot for answers, but as a ggplot2 beginner, I have failed to find a solution # to my problems above. # I would like to thank the programmers for a great package. The layer principle is much easier to work with. # Some dummy data: mydata- data.frame(week = factor(rep(c(19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39), each = 45*3)), #week station = factor(rep(c(BY31, B1, H2, H3, H4, H5, H6, H7, H8), each = 15)), #station organism = factor(rep(c(zpl, ses, cy), each = 5)), #organism var1 = rnorm(1485, mean = rep(c(0, 3, 15), each = 40), sd = rep(c(1, 3, 6), each = 20))) p - ggplot(mydata, aes(x = week, y = var1, fill = organism)) + geom_boxplot() + facet_wrap(~ station, ncol = 3) + theme_bw() + theme(strip.background = element_blank())+ ylab(var1)+ xlab(week) + geom_smooth(aes(group = 1), method=lm, se = F) + #Here is my problem. theme(strip.text.x = element_text(size = 12, colour=black, family=serif, angle=00)) + theme(axis.text.x = element_text(size = 12, colour=black, family=serif, angle=90)) + theme(axis.text.y = element_text(size = 12, colour=black, family=serif, angle=00)) + geom_hline(yintercept=0, linetype=3) #draws dotted line at 0 p # method=lm is definately wrong, # I just added it to be a ble to draw some lines at all. # I also suspect geom_smooth to be wrong. ### TO CLARIFY: I want the medians connected within each level. cy medians connected and # and ses medians connected and zpl connected. Not cy-ses-zpl, but that is perhaps obvious. ### Thank you for your time! # with kind regards # A. Zakrisson Anna Zakrisson Braeunlich PhD student Department of Ecology, Environment and Plant Sciences Stockholm University Svante Arrheniusv. 21A SE-106 91 Stockholm Sweden/Sverige Lives in Berlin. For paper mail: Katzbachstr. 21 D-10965, Berlin - Kreuzberg Germany/Deutschland E-mail: anna.zakris...@su.se Tel work: +49-(0)3091541281 Mobile: +49-(0)15777374888 LinkedIn: http://se.linkedin.com/pub/anna-zakrisson-braeunlich/33/5a2/51b º`. . `. . `. . º`. . `. . `. .º`. . `. . `. .º [[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] Using qmap module
Dear all, Is there anybody who is using qmap module for bias correction of RCM data. I have few queries about that. Please let me know if anybody is using qmap module in R. Thanking in Advance -- Jaya Pudashine M.Eng. Water Engineering and Management Asian Institute of Technology, Thailand Contact : +66-920598298 [[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] Poly Correlations
Hi Michael, See comments in line. On Wed, Sep 4, 2013 at 10:18 PM, Michael Hacker mhac...@nycap.rr.com wrote: Dear Colleagues, I'm working on a Delphi study comparing perceptions of high school technology teachers and university engineering educators about the importance of concepts about engineering for HS students to learn as part of their fundamental education. I'm actually doing this as part of my Ph.D. The survey items (n=37) are categorized into five scales: design, human values, modeling, resources, and systems thinking. I'm seeking to determine the reliability of these scales and of the overall survey instrument. Since I'm working with ordinal data, Chronbach's Alpha probably isn't the best statistical tool to use. I've literally spent several days learning my way around R-project but am struggling with procedures and interpretations. I'm aware that there is now a plug-in for R for SPSS that can be downloaded ( http://www-01.ibm.com/support/docview.wss?uid=swg21477550 http://www-01.ibm.com/support/docview.wss?uid=swg21477550 and http://gruener.userpage.fu-berlin.de/Essentials%20for%20R%20Installation%20 Instructions_21.pdf http://gruener.userpage.fu-berlin.de/Essentials%20for%20R%20Installation%20I nstructions_21.pdf). Just learned that today and I downloaded PolyCorrelations.zip from https://www.ibm.com/developerworks/community/files/app?lang=en#/file/9f47f9a 0-7793-4ad5-8bb7-d3fd1a028e44 I would ditch the SPSS/R integration and just run R from RCommander. You don't need PollyCorrelations.zip or SPSS for this, and trying to get the R and SPSS talking to each other is just another level of complication that you don't need. I've gotten as far as loading Rcmdr and running some analyses - (Statistics, dimensional analysis, scale reliability) and I've generated this output: Reliability deleting each item in turn: Alpha Std.Alpha r(item, total) design 0.84450.8490 0.7629 humanvalues 0.85260.8541 0.7170 modeling 0.85110.8546 0.7271 resources0.87120.8757 0.6328 systems 0.84610.8498 0.7488 I now would sincerely appreciate some help. At the age of 70, never having studied programming, the meaning of these statistics is not apparent. Understanding these statistics has nothing to do with studying programming. You need to study statistics! For example, I'm not clear if either of these three statistics are Ordinal Alpha. Since I'm working with Likert scale items, my advisor suggested that I seek an alternative to Chronbach's Alpha to determine reliability. Since we have no idea how you calculated these statistics there is no way for us to answer this question. So far, here are the steps I have taken: I've searched the FAQs Searched specifically for answers on the Web Played with the software for hours Read the accompanying documentation. Downloaded and installed Rcmdr Downloaded and installed PolyCorrelations. I tried running PolyCorrelations but I get a message that states that this requires the Polychor and Gclus libraries. I tried to install them into the R console, but no luck. What does no luck mean? I'd also be pleased to work with someone-on-one on a consulting basis if someone has the time and inclination. Hoping to find an individual who knows SPSS and R. Appendix B of http://pareonline.net/pdf/v17n3.pdf shows how to calculate reliability from ordinal data using R. Best, Ista Thanks very sincerely for considering this request. Michael END OF MESSAGE Michael Hacker, Co-Director Hofstra University Center for STEM Education Research Ph: 518-724-6437 Cell: 518-229-7300 Fax: 518-434-6783 URL: www.Hofstra.edu/CSR [[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] Problem with converting F to FALSE
Depending what you're doing with the data, you might want colClasses=c(factor,numeric) On 05/09/2013 13:58, Joshua Wiley wrote: Hi, You can either manually specify colClasses or the asis argument. See ?read.csv for more details. If you just had those two columns, something like: read.table(header = TRUE, text = sex group F 1 T 2 , colClasses = c(character, integer)) Cheers, Josh read.csv(file.csv, colClasses = c(character, integer)) On Thu, Sep 5, 2013 at 5:44 AM, Venkata Kirankumar kiran4u2...@gmail.com wrote: Hi, I have a peculier problem in R-Project that is when my CSV file have one column with all values as 'F' the R-Project converting this 'F' to FALSE. Can some one please suggest how to stop this convertion. Because I want to use 'F' in my calculations and show it in screen. for example my data is like sex group F 1 F 2 F 3 but when I use read.csv and load the csv file data is converting it to sex group FALSE 1 FALSE 2 FALSE 3 but i want it as source data like sex group F 1 F 2 F 3 Thanks in advance, D V Kiran Kumar __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 densities outside axis
I've been working on a way to visualize a spearman correlation. That seemed pretty simple: generate skewed data x = rnorm(100)^2 y = .6*x + rnorm(100, 0, sqrt(1-.6^2)) plot(x,y) regular plot plot(rank(x),rank(y), xaxt=n, yaxt=n) ### spearman-like plot make axis labels axis(1, at=quantile(rank(x)), labels=round(quantile(x), digits=2)) axis(2, at=quantile(rank(y)), labels=round(quantile(y), digits=2)) However, transforming the data into ranks eliminates any information we have about the distributions of the data. My solution to this problem is to plot the densities outside the x/y axis with the mode of the distribution pointing away from the plot. I've seen plots like this in textbooks, but can't think of a way to do this in R. Any ideas? [[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] Histogram
I wasn't suggesting that much detail, but I think the addition of one sentence in the last paragraph of the Details section would make it the meaning of the number is a suggestion only clearer. These functions provide a suggested number of bins that may be modified to produce 'round' breakpoints covering the range of the values in x. Added just before the last sentence, Alternatively, . . . Also pretty() could be added to the See Also section. David Carlson -Original Message- From: Duncan Murdoch [mailto:murdoch.dun...@gmail.com] Sent: Wednesday, September 4, 2013 7:00 PM To: dcarl...@tamu.edu Cc: 'philippe massicotte'; 'Rui Barradas'; 'r-help@R-project.org' Subject: Re: [R] Histogram On 13-09-04 4:44 PM, David Carlson wrote: Good question. It turns out that the manual page does not tell the whole story. Do you really think the manual page would be improved if it went into as much detail as you give below? It does say clearly that breaks is a suggestion only. I don't think it would be clearer if it explained exactly how the suggestion is used. It would just be more complicated, and less likely to be read. Duncan Murdoch Looking at the source code for hist.default, the function starts with the number of breaks suggested by nclass.Sturges(), but then this number (or any other number of breaks that you specify) is passed to pretty() along with the maximum and the minimum values of the data (ie range(data)) to create pretty break intervals. In your example, nclass.Sturges() always recommends 8 breaks, but the number of the breaks changes based on the minimum and maximum values. So the only way to get exactly the number of breaks you want is to specify the break intervals yourself. David Carlson -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of philippe massicotte Sent: Wednesday, September 4, 2013 3:02 PM To: Rui Barradas Cc: r-help@R-project.org Subject: Re: [R] Histogram Thank you everyone. Try executing this: replicate(100, length(hist(rnorm(100), nclass = 10)$counts)) I'm still not sure why the number of bins (classes) is not consistent. Thank in advance. Date: Wed, 4 Sep 2013 20:27:36 +0100 From: ruipbarra...@sapo.pt To: pmassico...@hotmail.com CC: r-help@r-project.org Subject: Re: [R] Histogram Hello, See the arguments 'right' and 'include.lowest' of ?hist. To give what you want, try instead h1 - hist(1:10, 10) # counts are 2, 1, 1, ... h2 - hist(1:10, breaks = 0:10) # all counts are 1 and see the difference between h1 and h2, components 'breaks' and 'counts'. Hope this helps, Rui Barradas Em 04-09-2013 19:34, philippe massicotte escreveu: Hi everyone. I'm currently translating some Matlab code into R. However, I realized that the hsit function produce different results in both languages. in Matlab, hist(1:10, 10) will produce 10 bins with a count of 1 in each, but in R it will produce 9 classes with count of 2,1,1,1,1,1,1,1,1. I'm a bit embarrassed to ask such question, but why R is not producing 10 classes as requested? Thanks in advance,Phil [[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-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] xyplot and lwd
Daniel: I wondered if that might be what you meant ... To amplify a bit on David's response, the answer is that you do **not** have separate control over the line width of characters -- lwd controls the width of lines in a graph (exactly as it does in base graphics! ), so you misunderstood the lwd parameter in the first place. The cex parameter controls the overall size of plotting characters (and text), so that incidentally affects the thickness of lines in character rendering. To get different line thicknesses without changing the overall size, you need to use different characters, fonts (e.g. bold), or font families, for which details can be found on the gpar man page, as David said. Note that some of this may also be device and system dependent, Cheers, Bert On Thu, Sep 5, 2013 at 4:52 AM, Daniel Hornung daniel.horn...@ds.mpg.dewrote: On Thursday, September 05, 2013 13:40:00 David Winsemius wrote: can it be that xyplot does not support the lwd argument? The lattice plotting system uses the grid plotting engine and does accepts some base par-type arguments but not all. You may need to read more about lattice and grid: ?lattice ?trellis.par.set require(grid) ?gpar Thanks for the hint, I will look further into this direction. Daniel -- Max-Planck-Institute for Dynamics and Self-Organization Laboratory for Fluid Dynamics, Pattern Formation and Biocomplexity Biomedical Physics Group Am Fassberg 17 D-37077 Goettingen (+49) 551 5176 373 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Bert Gunter Genentech Nonclinical Biostatistics Internal Contact Info: Phone: 467-7374 Website: http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm [[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] optim evils
Thanks for all replies. The problem occurred in the following context: A Gaussian one dimensional mixture (number of constituents, locations, variances all unknown) is to be fitted to data (as starting value to or in lieu of mixtools). A likelihood maximization is performed. Cool. That is all provided with my nor1mix CRAN package (of which most parts I have written even before R came to life, i.e., for S): The relatively new addition to nor1mix is the norMixMLE() function which uses my smart (almost) unconstrained parametrization and hence typically works much better, i.e., faster than the EM. Then, the code uses optim(), currently always with BFGS. Martin Maechler, ETH Zurich I'll try to destill the code so that reproducible failure of L-BFGS-B occurs and post it here. Michael Meyer __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Histogram
On 05/09/2013 10:17 AM, David Carlson wrote: I wasn't suggesting that much detail, but I think the addition of one sentence in the last paragraph of the Details section would make it the meaning of the number is a suggestion only clearer. These functions provide a suggested number of bins that may be modified to produce 'round' breakpoints covering the range of the values in x. I think that's the wrong place for it (since breaks=10 is perfectly fine, but is not a function). I'll change the initial sentence to say: In the last three cases the number is a suggestion only; the breakpoints will be set to \code{\link{pretty}} values. If people want to know what pretty values are, they can follow the link. Duncan Murdoch Added just before the last sentence, Alternatively, . . . Also pretty() could be added to the See Also section. David Carlson -Original Message- From: Duncan Murdoch [mailto:murdoch.dun...@gmail.com] Sent: Wednesday, September 4, 2013 7:00 PM To: dcarl...@tamu.edu Cc: 'philippe massicotte'; 'Rui Barradas'; 'r-help@R-project.org' Subject: Re: [R] Histogram On 13-09-04 4:44 PM, David Carlson wrote: Good question. It turns out that the manual page does not tell the whole story. Do you really think the manual page would be improved if it went into as much detail as you give below? It does say clearly that breaks is a suggestion only. I don't think it would be clearer if it explained exactly how the suggestion is used. It would just be more complicated, and less likely to be read. Duncan Murdoch Looking at the source code for hist.default, the function starts with the number of breaks suggested by nclass.Sturges(), but then this number (or any other number of breaks that you specify) is passed to pretty() along with the maximum and the minimum values of the data (ie range(data)) to create pretty break intervals. In your example, nclass.Sturges() always recommends 8 breaks, but the number of the breaks changes based on the minimum and maximum values. So the only way to get exactly the number of breaks you want is to specify the break intervals yourself. David Carlson -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of philippe massicotte Sent: Wednesday, September 4, 2013 3:02 PM To: Rui Barradas Cc: r-help@R-project.org Subject: Re: [R] Histogram Thank you everyone. Try executing this: replicate(100, length(hist(rnorm(100), nclass = 10)$counts)) I'm still not sure why the number of bins (classes) is not consistent. Thank in advance. Date: Wed, 4 Sep 2013 20:27:36 +0100 From: ruipbarra...@sapo.pt To: pmassico...@hotmail.com CC: r-help@r-project.org Subject: Re: [R] Histogram Hello, See the arguments 'right' and 'include.lowest' of ?hist. To give what you want, try instead h1 - hist(1:10, 10) # counts are 2, 1, 1, ... h2 - hist(1:10, breaks = 0:10) # all counts are 1 and see the difference between h1 and h2, components 'breaks' and 'counts'. Hope this helps, Rui Barradas Em 04-09-2013 19:34, philippe massicotte escreveu: Hi everyone. I'm currently translating some Matlab code into R. However, I realized that the hsit function produce different results in both languages. in Matlab, hist(1:10, 10) will produce 10 bins with a count of 1 in each, but in R it will produce 9 classes with count of 2,1,1,1,1,1,1,1,1. I'm a bit embarrassed to ask such question, but why R is not producing 10 classes as requested? Thanks in advance,Phil [[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-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible
Re: [R] ggplot2: connecting medians of boxes using facet_wrap. Changing median marker.
On Thu, Sep 5, 2013 at 11:08 AM, Anna Zakrisson Braeunlich anna.zakris...@su.se wrote: Hi and thank you for the help and for the fast reply! A. One thing still is a problem. I have prior my first mail tried to not fill the boxes. The result is a different plot. If chosing to do: ggplot(mydata, aes(x = week, y = var1)) instead of ggplot(mydata, aes(x = week, y = var1, fill=organism)) I get the median of all the levels of organisms plotted per week and not the median per organism level per week. I would like to have white boxes, but to define each level of organism with a different non-filled symbol that mark the median of each box. Ooops, sorry I missed that before. You can use geom_boxplot(mapping=aes(group=interaction(week, organism))) to achieve this, though it now becomes hard to tell which boxplots correspond to which organisms. B. Can I define the shapes of the geom_point other than the default filled points that I will automatically generate when I define: geom_point(stat=summary, fun.y = median, mapping=aes(shape=organism)) + # I need non-filled symbols add scale_shape(solid=FALSE) or scale_shape_manual(values = 1:3) Best, Ista The two versions mentioned in A are: ###DATA mydata- data.frame(week = factor(rep(c(19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39), each = 45*3)), #week station = factor(rep(c(BY31, B1, H2, H3, H4, H5, H6, H7, H8), each = 15)), #station organism = factor(rep(c(zpl, ses, cy), each = 5)), #organism var1 = rnorm(1485, mean = rep(c(0, 3, 15), each = 40), sd = rep(c(1, 3, 6), each = 20))) ###VERSION 1 p - ggplot(mydata, aes(x = week, y = var1)) + #here all organisms are bunted together geom_boxplot() + facet_wrap(~ station, ncol = 3) + theme_bw() + theme(strip.background = element_blank())+ ylab(var1)+ xlab(week) + geom_line(stat=summary, fun.y = median, mapping=aes(linetype=organism, group=organism))+ #must add jitter if using this geom_point(stat=summary, fun.y = median, mapping=aes(shape=organism)) + #must be unfilled theme(strip.text.x = element_text(size = 12, colour=black, family=serif, angle=00)) + theme(axis.text.x = element_text(size = 12, colour=black, family=serif, angle=90)) + theme(axis.text.y = element_text(size = 12, colour=black, family=serif, angle=00)) + geom_hline(yintercept=0, linetype=3) #draws dotted line at 0 p ###VERSION 2 p - ggplot(mydata, aes(x = week, y = var1, fill=organism)) + #here the levels in organism are considered geom_boxplot() + facet_wrap(~ station, ncol = 3) + theme_bw() + theme(strip.background = element_blank())+ ylab(var1)+ xlab(week) + geom_line(stat=summary, fun.y = median, mapping=aes(linetype=organism, group=organism))+ #must add jitter if using this geom_point(stat=summary, fun.y = median, mapping=aes(shape=organism)) + #must be unfilled theme(strip.text.x = element_text(size = 12, colour=black, family=serif, angle=00)) + theme(axis.text.x = element_text(size = 12, colour=black, family=serif, angle=90)) + theme(axis.text.y = element_text(size = 12, colour=black, family=serif, angle=00)) + geom_hline(yintercept=0, linetype=3) #draws dotted line at 0 p # Anna Zakrisson Braeunlich PhD student Department of Ecology, Environment and Plant Sciences Stockholm University Svante Arrheniusv. 21A SE-106 91 Stockholm Sweden/Sverige Lives in Berlin. For paper mail: Katzbachstr. 21 D-10965, Berlin - Kreuzberg Germany/Deutschland E-mail: anna.zakris...@su.se Tel work: +49-(0)3091541281 Mobile: +49-(0)15777374888 LinkedIn: http://se.linkedin.com/pub/anna-zakrisson-braeunlich/33/5a2/51b º`•. . • `•. .• `•. . º`•. . • `•. .• `•. .º`•. . • `•. .• `•. .º From: Ista Zahn [istaz...@gmail.com] Sent: 05 September 2013 16:02 To: Anna Zakrisson Braeunlich Cc: r-help@r-project.org Subject: Re: [R] ggplot2: connecting medians of boxes using facet_wrap. Changing median marker. Hi Anna, On Thu, Sep 5, 2013 at 6:13 AM, Anna Zakrisson Braeunlich anna.zakris...@su.se wrote: # Dear all, # Thank you for taking your time. # What I would like to do: # (Run the code below to see what I am referring to) # I want lines connecting the medians of of the boxes. I do not want a function, just a simple, # straight connection between points. I also would like the lines to be different: lty=c(1:3) geom_line(stat=summary, fun.y = median, mapping=aes(linetype=organism,
Re: [R] ggplot2: connecting medians of boxes using facet_wrap. Changing median marker.
Hi Anna, On Thu, Sep 5, 2013 at 6:13 AM, Anna Zakrisson Braeunlich anna.zakris...@su.se wrote: # Dear all, # Thank you for taking your time. # What I would like to do: # (Run the code below to see what I am referring to) # I want lines connecting the medians of of the boxes. I do not want a function, just a simple, # straight connection between points. I also would like the lines to be different: lty=c(1:3) geom_line(stat=summary, fun.y = median, mapping=aes(linetype=organism, group=organism)) # Furthermore, I wish to change the line/dot marking the medians to be pch=c(1:3). It seems not to be so simple when using facet_wrap? I have obviously missed something obvious. geom_point(stat=summary, fun.y = median, mapping=aes(shape=organism)) + # Finally, I would like the boxes to be filled white and to have the legend reflecting this. Then don't tell ggplot to color them. Change ggplot(mydata, aes(x = week, y = var1, fill = organism)) to ggplot(mydata, aes(x = week, y = var1)) # I know that this was many questions, I apologize if some may seem basic. It is just that I am # jumping packages the whole time and sometimes par() adjustments work and sometimes not. # I have searched alot for answers, but as a ggplot2 beginner, I have failed to find a solution # to my problems above. Hope this helps! Best, Ista # I would like to thank the programmers for a great package. The layer principle is much easier to work with. # Some dummy data: mydata- data.frame(week = factor(rep(c(19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39), each = 45*3)), #week station = factor(rep(c(BY31, B1, H2, H3, H4, H5, H6, H7, H8), each = 15)), #station organism = factor(rep(c(zpl, ses, cy), each = 5)), #organism var1 = rnorm(1485, mean = rep(c(0, 3, 15), each = 40), sd = rep(c(1, 3, 6), each = 20))) p - ggplot(mydata, aes(x = week, y = var1, fill = organism)) + geom_boxplot() + facet_wrap(~ station, ncol = 3) + theme_bw() + theme(strip.background = element_blank())+ ylab(var1)+ xlab(week) + geom_smooth(aes(group = 1), method=lm, se = F) + #Here is my problem. theme(strip.text.x = element_text(size = 12, colour=black, family=serif, angle=00)) + theme(axis.text.x = element_text(size = 12, colour=black, family=serif, angle=90)) + theme(axis.text.y = element_text(size = 12, colour=black, family=serif, angle=00)) + geom_hline(yintercept=0, linetype=3) #draws dotted line at 0 p # method=lm is definately wrong, # I just added it to be a ble to draw some lines at all. # I also suspect geom_smooth to be wrong. ### TO CLARIFY: I want the medians connected within each level. cy medians connected and # and ses medians connected and zpl connected. Not cy-ses-zpl, but that is perhaps obvious. ### Thank you for your time! # with kind regards # A. Zakrisson Anna Zakrisson Braeunlich PhD student Department of Ecology, Environment and Plant Sciences Stockholm University Svante Arrheniusv. 21A SE-106 91 Stockholm Sweden/Sverige Lives in Berlin. For paper mail: Katzbachstr. 21 D-10965, Berlin - Kreuzberg Germany/Deutschland E-mail: anna.zakris...@su.se Tel work: +49-(0)3091541281 Mobile: +49-(0)15777374888 LinkedIn: http://se.linkedin.com/pub/anna-zakrisson-braeunlich/33/5a2/51b º`•. . • `•. .• `•. . º`•. . • `•. .• `•. .º`•. . • `•. .• `•. .º [[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] ggplot2: connecting medians of boxes using facet_wrap. Changing median marker.
Hi and thank you for the help and for the fast reply! A. One thing still is a problem. I have prior my first mail tried to not fill the boxes. The result is a different plot. If chosing to do: ggplot(mydata, aes(x = week, y = var1)) instead of ggplot(mydata, aes(x = week, y = var1, fill=organism)) I get the median of all the levels of organisms plotted per week and not the median per organism level per week. I would like to have white boxes, but to define each level of organism with a different non-filled symbol that mark the median of each box. B. Can I define the shapes of the geom_point other than the default filled points that I will automatically generate when I define: geom_point(stat=summary, fun.y = median, mapping=aes(shape=organism)) + # I need non-filled symbols The two versions mentioned in A are: ###DATA mydata- data.frame(week = factor(rep(c(19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39), each = 45*3)), #week station = factor(rep(c(BY31, B1, H2, H3, H4, H5, H6, H7, H8), each = 15)), #station organism = factor(rep(c(zpl, ses, cy), each = 5)), #organism var1 = rnorm(1485, mean = rep(c(0, 3, 15), each = 40), sd = rep(c(1, 3, 6), each = 20))) ###VERSION 1 p - ggplot(mydata, aes(x = week, y = var1)) + #here all organisms are bunted together geom_boxplot() + facet_wrap(~ station, ncol = 3) + theme_bw() + theme(strip.background = element_blank())+ ylab(var1)+ xlab(week) + geom_line(stat=summary, fun.y = median, mapping=aes(linetype=organism, group=organism))+ #must add jitter if using this geom_point(stat=summary, fun.y = median, mapping=aes(shape=organism)) + #must be unfilled theme(strip.text.x = element_text(size = 12, colour=black, family=serif, angle=00)) + theme(axis.text.x = element_text(size = 12, colour=black, family=serif, angle=90)) + theme(axis.text.y = element_text(size = 12, colour=black, family=serif, angle=00)) + geom_hline(yintercept=0, linetype=3) #draws dotted line at 0 p ###VERSION 2 p - ggplot(mydata, aes(x = week, y = var1, fill=organism)) + #here the levels in organism are considered geom_boxplot() + facet_wrap(~ station, ncol = 3) + theme_bw() + theme(strip.background = element_blank())+ ylab(var1)+ xlab(week) + geom_line(stat=summary, fun.y = median, mapping=aes(linetype=organism, group=organism))+ #must add jitter if using this geom_point(stat=summary, fun.y = median, mapping=aes(shape=organism)) + #must be unfilled theme(strip.text.x = element_text(size = 12, colour=black, family=serif, angle=00)) + theme(axis.text.x = element_text(size = 12, colour=black, family=serif, angle=90)) + theme(axis.text.y = element_text(size = 12, colour=black, family=serif, angle=00)) + geom_hline(yintercept=0, linetype=3) #draws dotted line at 0 p # Anna Zakrisson Braeunlich PhD student Department of Ecology, Environment and Plant Sciences Stockholm University Svante Arrheniusv. 21A SE-106 91 Stockholm Sweden/Sverige Lives in Berlin. For paper mail: Katzbachstr. 21 D-10965, Berlin - Kreuzberg Germany/Deutschland E-mail: anna.zakris...@su.se Tel work: +49-(0)3091541281 Mobile: +49-(0)15777374888 LinkedIn: http://se.linkedin.com/pub/anna-zakrisson-braeunlich/33/5a2/51b º`•. . • `•. .• `•. . º`•. . • `•. .• `•. .º`•. . • `•. .• `•. .º From: Ista Zahn [istaz...@gmail.com] Sent: 05 September 2013 16:02 To: Anna Zakrisson Braeunlich Cc: r-help@r-project.org Subject: Re: [R] ggplot2: connecting medians of boxes using facet_wrap. Changing median marker. Hi Anna, On Thu, Sep 5, 2013 at 6:13 AM, Anna Zakrisson Braeunlich anna.zakris...@su.se wrote: # Dear all, # Thank you for taking your time. # What I would like to do: # (Run the code below to see what I am referring to) # I want lines connecting the medians of of the boxes. I do not want a function, just a simple, # straight connection between points. I also would like the lines to be different: lty=c(1:3) geom_line(stat=summary, fun.y = median, mapping=aes(linetype=organism, group=organism)) # Furthermore, I wish to change the line/dot marking the medians to be pch=c(1:3). It seems not to be so simple when using facet_wrap? I have obviously missed something obvious. geom_point(stat=summary, fun.y = median, mapping=aes(shape=organism)) + # Finally, I would like the boxes to be filled white and to have the legend reflecting this. Then don't tell ggplot to color them. Change ggplot(mydata, aes(x = week, y = var1, fill = organism)) to
[R] setStatusBar function gives error message in R 3.01 under Windows 7
I am running R 3.01 under 64-bit Windows 7. When I try to set the status bar, I get an error message. For example: text-hello setStatusBar(text) Error in .Call(setStatusBar, text) : first argument must be a string (of length 1) or native symbol reference The related function, setWindowTitle(), appears to work just fine. Is this a bug? Or am I doing something wrong? It does seem to work OK in R 2.13.0. Thanks, Gwen Babcock New York State Department of Health Albany, NY 12237 USA [[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 with converting F to FALSE
Thank you everyone I got actual values in my view On Thu, Sep 5, 2013 at 7:31 PM, Keith Jewell keith.jew...@campdenbri.co.ukwrote: Depending what you're doing with the data, you might want colClasses=c(factor,**numeric) On 05/09/2013 13:58, Joshua Wiley wrote: Hi, You can either manually specify colClasses or the asis argument. See ?read.csv for more details. If you just had those two columns, something like: read.table(header = TRUE, text = sex group F 1 T 2 , colClasses = c(character, integer)) Cheers, Josh read.csv(file.csv, colClasses = c(character, integer)) On Thu, Sep 5, 2013 at 5:44 AM, Venkata Kirankumar kiran4u2...@gmail.com wrote: Hi, I have a peculier problem in R-Project that is when my CSV file have one column with all values as 'F' the R-Project converting this 'F' to FALSE. Can some one please suggest how to stop this convertion. Because I want to use 'F' in my calculations and show it in screen. for example my data is like sex group F 1 F 2 F 3 but when I use read.csv and load the csv file data is converting it to sex group FALSE 1 FALSE 2 FALSE 3 but i want it as source data like sex group F 1 F 2 F 3 Thanks in advance, D V Kiran Kumar __** R-help@r-project.org mailing list https://stat.ethz.ch/mailman/**listinfo/r-helphttps://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/** posting-guide.html 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] Y-axis labels as decimal numbers
So what is wrong with the y-axis? When I run your script, things seem right. Can you explain what it is that you want. Jim Holtman Data Munger Guru What is the problem that you are trying to solve? Tell me what you want to do, not how you want to do it. On Thu, Sep 5, 2013 at 9:22 AM, mohan.radhakrish...@polarisft.com wrote: Hi, I am able to create a graph with this code but the decimal numbers are not plotted accurately because the ylim values are not set properly. x-axis is proper. How do I accurately set the ylim for duration.1 column ? Thanks, Mohan set1$duration- as.POSIXct(paste('2013-08-24', set1$duration)) plot(set1$duration,set1$duration.1,type=b,col = blue, ylab=, xaxt = 'n', xlab=,las=2,lwd=2.5, lty=1,cex.axis=2.5) # now plot you times axis(1, at = set1$duration, labels = set1$duration, las = 2,cex.axis=2.5) duration duration.1 2 16:03:41 0.05 3 17:03:41 0.27 4 18:03:43 1.22 5 19:03:45 1.51 6 20:03:47 1.27 7 21:03:48 1.15 8 22:03:50 1.22 9 23:03:52 1.27 10 00:03:54 1.27 11 01:03:55 1.22 12 02:03:57 1.26 13 03:03:59 1.57 14 04:04:01 1.31 15 05:04:03 1.24 This e-Mail may contain proprietary and confidential information and is sent for the intended recipient(s) only. If by an addressing or transmission error this mail has been misdirected to you, you are requested to delete this mail immediately. You are also hereby notified that any use, any form of reproduction, dissemination, copying, disclosure, modification, distribution and/or publication of this e-mail message, contents or its attachment other than by its intended recipient/s is strictly prohibited. Visit us at http://www.polarisFT.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] optim evils
Slight correction: On Thu, Sep 5, 2013 at 7:48 AM, Bert Gunter bgun...@gene.com wrote: Michael: Your parameter specification is probably over-determined, so that you have an infinite set of parameter **values** that give essentially the same solution within numerical error. I would venture to guess that this will not be fixable with alternative optimizers. It is up to you to provide a sensible problem specification; failure to do so cannot be blamed on the optimizer. Cheers, Bert On Thu, Sep 5, 2013 at 3:23 AM, Michael Meyer spyqqq...@yahoo.com wrote: Thanks for all replies. The problem occurred in the following context: A Gaussian one dimensional mixture (number of constituents, locations, variances all unknown) is to be fitted to data (as starting value to or in lieu of mixtools). A likelihood maximization is performed. I'll try to destill the code so that reproducible failure of L-BFGS-B occurs and post it here. Michael Meyer [[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. -- Bert Gunter Genentech Nonclinical Biostatistics Internal Contact Info: Phone: 467-7374 Website: http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm -- Bert Gunter Genentech Nonclinical Biostatistics Internal Contact Info: Phone: 467-7374 Website: http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm [[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] binary symmetric matrix combination
Also, some of the steps could be reduced by: names1-unique(c(colnames(m1),colnames(m2),colnames(m3),colnames(m4))) Out3-matrix(0,length(names1),length(names1),dimnames=list(names1,names1)) lst1-sapply(paste0(m,1:4),function(x) {x1- get(x); x2-paste0(colnames(x1)[col(x1)],rownames(x1)[row(x1)]); match(x2,vecOut)}) lst2- list(m1,m2,m3,m4) N- length(lst1) fn1- function(N,Out){ i=1 while(i=N){ Out[lst1[[i]]]-lst2[[i]] i-i+1 } Out } fn1(N,Out3) # y1 g24 c1 c2 l17 h4 s2 s30 e5 l15 #y1 0 1 1 1 1 1 1 1 1 1 #g24 1 0 0 0 0 0 0 0 0 0 #c1 1 0 0 1 1 0 0 0 0 0 #c2 1 0 1 0 1 0 0 0 0 0 #l17 1 0 1 1 0 0 0 0 0 0 #h4 1 0 0 0 0 0 1 1 0 0 #s2 1 0 0 0 0 1 0 1 0 0 #s30 1 0 0 0 0 1 1 0 0 0 #e5 1 0 0 0 0 0 0 0 0 1 #l15 1 0 0 0 0 0 0 0 1 0 identical(Out2,fn1(N,Out3)) #[1] TRUE A.K. - Original Message - From: arun smartpink...@yahoo.com To: R help r-help@r-project.org Cc: Sent: Thursday, September 5, 2013 4:09 PM Subject: Re: binary symmetric matrix combination Hi, May be this helps: m1- as.matrix(read.table(text= y1 g24 y1 0 1 g24 1 0 ,sep=,header=TRUE)) m2-as.matrix(read.table(text=y1 c1 c2 l17 y1 0 1 1 1 c1 1 0 1 1 c2 1 1 0 1 l17 1 1 1 0,sep=,header=TRUE)) m3- as.matrix(read.table(text=y1 h4 s2 s30 y1 0 1 1 1 h4 1 0 1 1 s2 1 1 0 1 s30 1 1 1 0,sep=,header=TRUE)) m4- as.matrix(read.table(text=y1 e5 l15 y1 0 1 1 e5 1 0 1 l15 1 1 0,sep=,header=TRUE)) ###desired output: at some place the label is s2 and at other s29. I used s2 for consistency Out1- as.matrix(read.table(text=y1 g24 c1 c2 l17 h4 s2 s30 e5 l15 y1 0 1 1 1 1 1 1 1 1 1 g24 1 0 0 0 0 0 0 0 0 0 c1 1 0 0 1 1 0 0 0 0 0 c2 1 0 1 0 1 0 0 0 0 0 l17 1 0 1 1 0 0 0 0 0 0 h4 1 0 0 0 0 0 1 1 0 0 s2 1 0 0 0 0 1 0 1 0 0 s30 1 0 0 0 0 1 1 0 0 0 e5 1 0 0 0 0 0 0 0 0 1 l15 1 0 0 0 0 0 0 0 1 0,sep=,header=TRUE)) names1-unique(c(colnames(m1),colnames(m2),colnames(m3),colnames(m4))) Out2-matrix(0,length(names1),length(names1),dimnames=list(names1,names1)) vec1- paste0(colnames(m1)[col(m1)],rownames(m1)[row(m1)]) vecOut- paste0(colnames(Out2)[col(Out2)],rownames(Out2)[row(Out2)]) Out2[match(vec1,vecOut)]- m1 vec2- paste0(colnames(m2)[col(m2)],rownames(m2)[row(m2)]) Out2[match(vec2,vecOut)]- m2 vec3- paste0(colnames(m3)[col(m3)],rownames(m3)[row(m3)]) Out2[match(vec3,vecOut)]- m3 vec4- paste0(colnames(m4)[col(m4)],rownames(m4)[row(m4)]) Out2[match(vec4,vecOut)]- m4 all.equal(Out1,Out2) #[1] TRUE Out2 y1 g24 c1 c2 l17 h4 s2 s30 e5 l15 y1 0 1 1 1 1 1 1 1 1 1 g24 1 0 0 0 0 0 0 0 0 0 c1 1 0 0 1 1 0 0 0 0 0 c2 1 0 1 0 1 0 0 0 0 0 l17 1 0 1 1 0 0 0 0 0 0 h4 1 0 0 0 0 0 1 1 0 0 s2 1 0 0 0 0 1 0 1 0 0 s30 1 0 0 0 0 1 1 0 0 0 e5 1 0 0 0 0 0 0 0 0 1 l15 1 0 0 0 0 0 0 0 1 0 A.K. I have the following binary labeled matrices with different dimensions (2x2, 3x3, 4x4) which I need to create in R as seen below: y1 g24 y1 0 1 g2 4 1 0 y1 c1 c2 l17 y1 0 1 1 1 c1 1 0 1 1 c2 1 1 0 1 l17 1 1 1 0 y1 h4 s2 s30 y1 0 1 1 1 h4 1 0 1 1 s29 1 1 0 1 s30 1 1 1 0 y1 e5 l15 y1 0 1 1 e5 1 0 1 l15 1 1 0 Then, I need to combine them to achieve the following result: y1 g24 c1 c2 l17 h4 s29 s30 e5 l15 y1 0 1 1 1 1 1 1 1 1 1 g24 1 0 0 0 0 0 0 0 0 0 c1 1 0 0 1 1 0 0 0 0 0 c2 1 0 1 0 1 0 0 0 0 0 l17 1 0 1 1 0 0 0 0 0 0 h4 1 0 0 0 0 0 1 1 0 0 s29 1 0 0 0 0 1 0 1 0 0 s30 1 0 0 0 0 1 1 0 0 0 e5 1 0 0 0 0 0 0 0 0 1 l15 1 0 0 0 0 0 0 0 1 0 Your help would be very much appreciated. ps. if the matrices don't appear correctly, please notice that all values different from 0 and 1 are row and column names Thank You! __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] xyplot() with discontinuous x-axis variable
My xyplot() with superposed multiple condiions looks better with lines than with points (it's easier to see changes over time with the lines). But, there are gaps in the years (the x axis) for which there are data to be plotted. For example, there are data for years 2004-2006 and 2010-2012, but not for 2007-2009. I would like to have the lines for only the two groups with data. Reading ?xyplot suggests that the group attribute might do the job but I do not see how to write the equation. Is it possible to plot with lines on discontinuous data or should I use large, solid circles for each year's data points? Rich __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Poly Correlations
Dear Michael, Please see comments below, interspersed with your questions: On Wed, 4 Sep 2013 22:18:57 -0400 Michael Hacker mhac...@nycap.rr.com wrote: Dear Colleagues, I'm working on a Delphi study comparing perceptions of high school technology teachers and university engineering educators about the importance of concepts about engineering for HS students to learn as part of their fundamental education. I'm actually doing this as part of my Ph.D. The survey items (n=37) are categorized into five scales: design, human values, modeling, resources, and systems thinking. I'm seeking to determine the reliability of these scales and of the overall survey instrument. Since I'm working with ordinal data, Chronbach's Alpha probably isn't the best statistical tool to use. I've literally spent several days learning my way around R-project but am struggling with procedures and interpretations. I'm aware that there is now a plug-in for R for SPSS that can be downloaded ( http://www-01.ibm.com/support/docview.wss?uid=swg21477550 http://www-01.ibm.com/support/docview.wss?uid=swg21477550 and http://gruener.userpage.fu-berlin.de/Essentials%20for%20R%20Installation%20 Instructions_21.pdf http://gruener.userpage.fu-berlin.de/Essentials%20for%20R%20Installation%20I nstructions_21.pdf). Just learned that today and I downloaded PolyCorrelations.zip from https://www.ibm.com/developerworks/community/files/app?lang=en#/file/9f47f9a 0-7793-4ad5-8bb7-d3fd1a028e44 I've gotten as far as loading Rcmdr and running some analyses - (Statistics, dimensional analysis, scale reliability) and I've generated this output: Reliability deleting each item in turn: Alpha Std.Alpha r(item, total) design 0.84450.8490 0.7629 humanvalues 0.85260.8541 0.7170 modeling 0.85110.8546 0.7271 resources0.87120.8757 0.6328 systems 0.84610.8498 0.7488 I now would sincerely appreciate some help. At the age of 70, never having studied programming, the meaning of these statistics is not apparent. For example, I'm not clear if either of these three statistics are Ordinal Alpha. Since I'm working with Likert scale items, my advisor suggested that I seek an alternative to Chronbach's Alpha to determine reliability. The table seems self-explanatory to me: it includes Chronbach's alpha and alpha for standardized items with each item deleted in turn, along with the correlation of each item with the total of the other items. All of this is described if you press the Help button in the Reliability dialog for the Rcmdr. The computation isn't really appropriate for ordinal items (unless you plan to treat the ordinal items as numeric). So far, here are the steps I have taken: I've searched the FAQs Searched specifically for answers on the Web Played with the software for hours Read the accompanying documentation. Downloaded and installed Rcmdr Downloaded and installed PolyCorrelations. I tried running PolyCorrelations but I get a message that states that this requires the Polychor and Gclus libraries. I tried to install them into the R console, but no luck. As far as I know, this is no Polychor package on CRAN, though there is a polycor package, which will compute polychoric and polyserial correlations. These could be used to calculate reliability for ordinal items, I suppose, though not, to my knowledge, with the Rcmdr. I'd also be pleased to work with someone-on-one on a consulting basis if someone has the time and inclination. Hoping to find an individual who knows SPSS and R. It's unclear to me what SPSS has to do with all this. Best, John John Fox McMaster University Hamilton, Ontario, Canada http://socserv.mcmaster.ca/jfox/ Thanks very sincerely for considering this request. Michael END OF MESSAGE Michael Hacker, Co-Director Hofstra University Center for STEM Education Research Ph: 518-724-6437 Cell: 518-229-7300 Fax: 518-434-6783 URL: www.Hofstra.edu/CSR [[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] ANN: Course Data Mining with R in Spain
We do it tomorrow if you have some time.good night! On Sep 3, 2013 5:04 PM, Soledad De Esteban Trivigno [via R] ml-node+s789695n4675267...@n4.nabble.com wrote: Dear colleague: Registration is open for the course CLASSIFICATION AND REGRESSION TREES AND NEURAL NETWORKS WITH R - Second Edition. INSTRUCTORS: Dr. Llorenç Badiella (UAB, Spain), Dr. Joan Valls (Biomedical Research Institute of Lleida, Spain) and Dr. Montserrat MartÃnez-Alonso (Biomedical Research Institute of Lleida, Spain). DATES: November 4-7, 2013; 24 teaching hours. PLACE: Premises of Sabadell of the Institut Català de Paleontologia Miquel Crusafont, Sabadell, Barcelona (Spain). Organized by: Transmitting Science and the Institut Catalá de Paleontologia Miquel Crusafont. More information: http://www.transmittingscience.org/cart_with_r.htm or writing to [hidden email] http://user/SendEmail.jtp?type=nodenode=4675267i=0 The main goal of the methods such as CART (Classification and Regression Trees), is to model and predict one response variable explained by a set of dependent variables. This methods can be particularly effective to model interactions between explanatory variables. On the other hand, as a statistical model, a neural network is based on linear and non-linear combinations of explanatory variables that interact with other combinations to predict or explain an outcome variable. Both CART and neural networks methods can provide good results to explain or predict an outcome variable, particularly when the number of interactions is important. Nevertheless, these techniques also tend to over-fit the data and a validation of the models is required. ROC methods, including a sensitivity/specificity analyses and/or external validations can be performed to assess the consistency of these techniques. Applications cover a wide range of problems, including species classification in biology, prediction of the prognosis of a patient in biomedicine, etc. Please feel free to distribute this information between your colleagues if you consider it appropriate. With best regards Soledad De Esteban-Trivigno, PhD. Academic Director [hidden email] http://user/SendEmail.jtp?type=nodenode=4675267i=1 Transmitting Science www.transmittingscience.org __ [hidden email] http://user/SendEmail.jtp?type=nodenode=4675267i=2mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- If you reply to this email, your message will be added to the discussion below: http://r.789695.n4.nabble.com/ANN-Course-Data-Mining-with-R-in-Spain-tp4675267.html To start a new topic under R help, email ml-node+s789695n789696...@n4.nabble.com To unsubscribe from R, click herehttp://r.789695.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_codenode=789695code=dmlsbGFyaW5vLmVybmVzdG9AZ21haWwuY29tfDc4OTY5NXwxOTIwMjI1Njcz . NAMLhttp://r.789695.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewerid=instant_html%21nabble%3Aemail.namlbase=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespacebreadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml -- View this message in context: http://r.789695.n4.nabble.com/ANN-Course-Data-Mining-with-R-in-Spain-tp4675267p4675489.html Sent from the R help mailing list archive at Nabble.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] Matrix randomization
Dear friends I am very new to R and no experience in programming at all. I need to generate random swaps of binary matrix in a way that row and column totals remain constant. and for each derived matrix calculate site weighted richness. Could you suggest most appropriate function (package) to do this? Or could you suggest a text book where such things will be explained? Thank you in advance Levan [[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] sparse PCA using nsprcomp package
Hi John I am currently traveling and have sporadic net access, I therefore can only answer briefly. It's also quite late, I hope what follows still makes sense... For regular PCA by prcomp(), we can easily calculate the percent of total variance explained by the first k PCs by using cumsum(obj$sdev^2) because these PCs are independent of each other so you can simply add up the variance of these PCs. For sparse PCA, as far as I understand, the generated PCs are not independent of each other anymore, so you can not simply add up variances to calculate percentage of variance explained by the first k PCs. For example, in the package of elasticnet where spca() also performs sparse PCA, one of the output from spca() is pev for percent explained variation which is based on so-called adjusted variance that adjusted for the fact that these variances of PCs are not independent anymore. You are correct that measuring explained variance is more involved with sparse (or non-negative) PCA, because the principal axes no longer correspond to eigenvectors of the covariance matrix, and are usually not even orthogonal. The next update for the 'nsprcomp' package is almost done, and one of the changes will concern the reported standard deviations. In the current version (0.3), the standard deviations are computed from the scores matrix X*W, where X is the data matrix and W is the (pseudo-)rotation matrix consisting of the sparse loadings. Computing variance this way has the advantage that 'sdev' is consistent with the scores matrix, but it has the disadvantage that some of the explained variance is counted more than once because of the non-orthogonality of the principal axes. One of the symptoms of this counting is that the variance of a later component can actually exceed the variance of an earlier component, which is not possible in regular PCA. In the new version of the package, 'sdev' will report the _additional_ standard deviation of each component, i.e. the variance not explained by the previous components. Given a basis of the space spanned by the previous PAs, the variance of the PC is computed after projecting the current PA to the ortho-complement space of the basis. This procedure reverts back to standard PCA if no sparsity or non-negativity constraints are enforced on the PAs. My question is for nsprcomp, how can I calculate percent explained variation by using sdev when I know these PCs are not independent of each other? The new version of the package will do it for you. Until then, you can use something like the following function asdev - function(X, W) { nc - ncol(W) sdev - numeric(nc) Q - qr.Q(qr(W)) Xp - X for (cc in seq_len(nc)) { sdev[cc] - sd(Xp%*%W[ , cc]) Xp - Xp - Xp%*%Q[ , cc]%*%t(Q[ , cc]) } return(sdev) } to compute the additional variances for given X and W. The package documentation will explain the above in some more detail, and I will also have a small blog post which compares the 'nsprcomp' and 'spca' routine from the 'elasticnet' package on the 'marty' data from the EMA package. Best regards Christian __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Assessing temporal correlation in GAM with irregular time steps
On 3 September 2013 16:10, Worthington, Thomas A thomas.worthing...@okstate.edu wrote: Dear Gavin Thank you for the very detailed response. I had started to go down the route of fitting a correlation structure via gamm. I tried applying your code to my data but returned the error Error in corCAR1(~ID | SiteCode1971) : parameter in CAR(1) structure must be between 0 and 1 Sorry, that is my fault, I keep forgetting that you need to specify the formula argument, the first argument of corCAR1() is the value of the correlation parameter if you want to specify it. So try: corCAR1(form = ~ID | SiteCode1971) I do this (get that error) all the time myself. I set the 'bar' in your code to the sample ID (basically a number between 1 and 192) but I wasn't sure if this was what you meant in relation to 'ordering of the samples' That is not that useful as you need to give the software something about when the samples occur in time, otherwise it doesn't have the information needed to properly model the decay in correlation with time. You need to give it the observation time, however you measured it. HTH G Best wishes Tom -Original Message- From: Gavin Simpson [mailto:ucfa...@gmail.com] Sent: Tuesday, September 03, 2013 3:17 PM To: Worthington, Thomas A Cc: r-help@r-project.org Subject: Re: [R] Assessing temporal correlation in GAM with irregular time steps It is possible, but you can't use the discrete time or classical stochastic trend models (or evaluate using the ACF). Also, why do you care to do this with regard to DoY? The assumption of the model relates to the residuals, so you should check those for residual autocorrelation. As you are using `mgcv::gam` you could also use `mgcv::gamm` which can then leverage the correlation structures from the nlme package, which has spatial correlation structures (and you can think of time as a 1-d spatial direction). The package also has a `corCAR1()` correlation structure which is the continuous-time analogue of the AR(1). Fitting via `gamm()` will also allow you to use the `Variogram()` function from the nlme package to assess the model residuals for residual autocorrelation. For example you could compare the two fits m0 - gamm(Length ~ s(DOY, by = SiteCode) + SiteCode, data = foo, method = REML) m1 - gamm(Length ~ s(DOY, by = SiteCode) + SiteCode, data = foo, method = REML, correlation = corCAR1( ~ bar | SiteCode)) where `foo` is the object that contains the variables mentioned in the call, and `bar` is the variable (in `foo)` that indicates the ordering of the samples. Notice that I nest the CAR(1) within the two respective Sites, but do note IIRC that this fits the same residual correlation structure to both sites' residuals (i.e. there is 1 CAR(1) process, not two separate ones). require(nlme) anova(m0$lme, m1$lme) will perform a likelihood ratio test on the two models. If you have residual autocorrelation, do note that the smooth for DoY may be chosen to be more complex than is appropriate (it might be fitting the autocorrleated noise), so you may want to fix the degrees of freedom for the smoother at some a priori chosen value and use this same value when fitting both m0 and m1, or at the very least set an upper limit on the complexity of the DoY smooth, say via s(DoY, by = SiteCode, k = 5). Finally, as a length = 0 insect makes no sense, the assumption of Gaussian (Normal) errors may be in trouble with your data; apart from their strictly positive nature, the mean-variance relationship of the data may not follow that of the assumptions for the errors. You can move to a GLM (GAM) to account for this but things get very tricky with the correlation structures (you can use gamm() still but fitting then goes via glmmPQL() in the MASS package a thence to lme()). If you just want to fit a variogram to something, there are a large number of spatial packages available for R, several of which can fit variograms to data, though you will need to study their respective help files for how to use them. As for the input data, often the time/date of sampling encoded as a numeric will be sufficient input, but you will need to check individual functions for what they require. I would check out the Spatial Task View on CRAN. HTH G On 28 August 2013 14:26, Worthington, Thomas A thomas.worthing...@okstate.edu wrote: I have constructed a GAM using the package mgcv to test whether the lengths of an emerging insect (Length) varies with day of the year (DOY) and between two sites (SiteCode). The data are collected at irregular time steps ranging from 2 days to 20 days between samples. The GAM takes the form M3 - gam(Length ~s(DOY, by = SiteCode) + SiteCode) As the data are a time series I would like to test for temporal autocorrelation. I have read that it is not possible to use the autocorrelation function (ACF) due to the
[R] get syntax for inherited environments
quick question. how do I search up the calling environments until I find a variable? x=function() { m=22; y() } y=function() { z() } z=function() { mget(m, inherits=TRUE, ifnotfound=m not found) } x() $m [1] m not found from the perspective of z(), function x is not an enclosing environment. do I write a while loop to look back, or is there a standard R function that searches all calling environments until it finds one that works? regards, /iaw Ivo Welch (ivo.we...@gmail.com) [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] sparse PCA using nsprcomp package
HI Christian, Thanks so much for the detailed explanation! I look forward to the new release of nsprcomp package! At the meantime, I will use the function below for calculation of adjusted standard deviation. I have 2 more questions, hope you can shed some lights on: 1). Assume now I can calculate these adjusted standard deviation from sparse PCA, should the percent variation explained by each sparse PC be calculated using the sum of all these adjusted variance (i.e. square of the adjusted standard deviation) as the denominator (then these percent variation explained will always add up to 1 if all sparse PCs are counted, or using the sum of the PC variances estimated by REGULAR PCA as the denominator (then, adding up all PCs may not be equal to 1)? 2). How do you choose the 2 important parameters in nsprcomp(), ncomp and k? If for example, my regular PCA showed that I need 20 PCs to account for 80% of the variation in my dataset, does it mean I should set ncomp=20? And then what about any rules setting the value of k? 3). Would you recommend nscumcomp() or nsprcomp() in general? Thanks so much again, John From: Christian Sigg r-h...@sigg-iten.ch Cc: r-help@r-project.org Sent: Thursday, September 5, 2013 2:43 PM Subject: Re: [R] sparse PCA using nsprcomp package Hi John I am currently traveling and have sporadic net access, I therefore can only answer briefly. It's also quite late, I hope what follows still makes sense... For regular PCA by prcomp(), we can easily calculate the percent of total variance explained by the first k PCs by using cumsum(obj$sdev^2) because these PCs are independent of each other so you can simply add up the variance of these PCs. For sparse PCA, as far as I understand, the generated PCs are not independent of each other anymore, so you can not simply add up variances to calculate percentage of variance explained by the first k PCs. For example, in the package of elasticnet where spca() also performs sparse PCA, one of the output from spca() is pev for percent explained variation which is based on so-called adjusted variance that adjusted for the fact that these variances of PCs are not independent anymore. You are correct that measuring explained variance is more involved with sparse (or non-negative) PCA, because the principal axes no longer correspond to eigenvectors of the covariance matrix, and are usually not even orthogonal. The next update for the 'nsprcomp' package is almost done, and one of the changes will concern the reported standard deviations. In the current version (0.3), the standard deviations are computed from the scores matrix X*W, where X is the data matrix and W is the (pseudo-)rotation matrix consisting of the sparse loadings. Computing variance this way has the advantage that 'sdev' is consistent with the scores matrix, but it has the disadvantage that some of the explained variance is counted more than once because of the non-orthogonality of the principal axes. One of the symptoms of this counting is that the variance of a later component can actually exceed the variance of an earlier component, which is not possible in regular PCA. In the new version of the package, 'sdev' will report the _additional_ standard deviation of each component, i.e. the variance not explained by the previous components. Given a basis of the space spanned by the previous PAs, the variance of the PC is computed after projecting the current PA to the ortho-complement space of the basis. This procedure reverts back to standard PCA if no sparsity or non-negativity constraints are enforced on the PAs. My question is for nsprcomp, how can I calculate percent explained variation by using sdev when I know these PCs are not independent of each other? The new version of the package will do it for you. Until then, you can use something like the following function asdev - function(X, W) { nc - ncol(W) sdev - numeric(nc) Q - qr.Q(qr(W)) Xp - X for (cc in seq_len(nc)) { sdev[cc] - sd(Xp%*%W[ , cc]) Xp - Xp - Xp%*%Q[ , cc]%*%t(Q[ , cc]) } return(sdev) } to compute the additional variances for given X and W. The package documentation will explain the above in some more detail, and I will also have a small blog post which compares the 'nsprcomp' and 'spca' routine from the 'elasticnet' package on the 'marty' data from the EMA package. Best regards Christian [[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] binary symmetric matrix combination
HI, No problem. I think you didn't run the `vecOut` after adding the new matrix. `lst1` is based on `vecOut` For example: m5- as.matrix(read.table(text=y1 e6 l16 y1 0 1 1 e6 1 0 1 l16 1 1 0,sep=,header=TRUE)) names1-unique(c(colnames(m1),colnames(m2),colnames(m3),colnames(m4), colnames(m5))) Out3-matrix(0,length(names1),length(names1),dimnames=list(names1,names1)) lst1-sapply(paste0(m,1:5),function(x) {x1- get(x); x2-paste0(colnames(x1)[col(x1)],rownames(x1)[row(x1)]); match(x2,vecOut)}) lst1 #$m1 #[1] 1 2 11 12 # #$m2 #[1] 1 3 4 5 21 23 24 25 31 33 34 35 41 43 44 45 # #$m3 #[1] 1 6 7 8 51 56 57 58 61 66 67 68 71 76 77 78 # #$m4 #[1] 1 9 10 81 89 90 91 99 100 # #$m5 #[1] 1 NA NA NA NA NA NA NA NA ###Here vecOut was based on Out2 lst2- list(m1,m2,m3,m4,m5) N- length(lst1) fn1- function(N,Out){ i=1 while(i=N){ Out[lst1[[i]]]-lst2[[i]] i-i+1 } Out } fn1(N,Out3) #Error in Out[lst1[[i]]] - lst2[[i]] : # NAs are not allowed in subscripted assignments ###Running vecOut using Out3 vecOut-paste0(colnames(Out3)[col(Out3)],rownames(Out3)[row(Out3)]) lst1-sapply(paste0(m,1:5),function(x) {x1- get(x); x2-paste0(colnames(x1)[col(x1)],rownames(x1)[row(x1)]); match(x2,vecOut)}) fn1(N,Out3) # y1 g24 c1 c2 l17 h4 s2 s30 e5 l15 e6 l16 #y1 0 1 1 1 1 1 1 1 1 1 1 1 #g24 1 0 0 0 0 0 0 0 0 0 0 0 #c1 1 0 0 1 1 0 0 0 0 0 0 0 #c2 1 0 1 0 1 0 0 0 0 0 0 0 #l17 1 0 1 1 0 0 0 0 0 0 0 0 #h4 1 0 0 0 0 0 1 1 0 0 0 0 #s2 1 0 0 0 0 1 0 1 0 0 0 0 #s30 1 0 0 0 0 1 1 0 0 0 0 0 #e5 1 0 0 0 0 0 0 0 0 1 0 0 #l15 1 0 0 0 0 0 0 0 1 0 0 0 #e6 1 0 0 0 0 0 0 0 0 0 0 1 #l16 1 0 0 0 0 0 0 0 0 0 1 0 A.K. Thanks a lot, all the codes worked perfectly. I have an additional question on the last steps you mentioned. I wanted to add another matrix to the ones I gave as an example, inputing m5 worked well, however when I type the code (added colnames (m5), changed 1:4 with 1:5 and added m5 to list2 I get the following error: Error in Out[lst1[[i]]] - lst2[[i]] : NAs are not allowed in subscripted assignments Below is the code: (am I doing something wrong? very many thanks again for helping!! names1-unique(c(colnames(m1),colnames(m2),colnames(m3),colnames(m4), colnames(m5))) Out3-matrix(0,length(names1),length(names1),dimnames=list(names1,names1)) lst1-sapply(paste0(m,1:5),function(x) {x1- get(x); x2-paste0(colnames(x1)[col(x1)],rownames(x1)[row(x1)]); match(x2,vecOut)}) lst2- list(m1,m2,m3,m4,m5) N- length(lst1) fn1- function(N,Out){ i=1 while(i=N){ Out[lst1[[i]]]-lst2[[i]] i-i+1 } Out } fn1(N,Out3) - Original Message - From: arun smartpink...@yahoo.com To: R help r-help@r-project.org Cc: Sent: Thursday, September 5, 2013 4:30 PM Subject: Re: binary symmetric matrix combination Also, some of the steps could be reduced by: names1-unique(c(colnames(m1),colnames(m2),colnames(m3),colnames(m4))) Out3-matrix(0,length(names1),length(names1),dimnames=list(names1,names1)) lst1-sapply(paste0(m,1:4),function(x) {x1- get(x); x2-paste0(colnames(x1)[col(x1)],rownames(x1)[row(x1)]); match(x2,vecOut)}) lst2- list(m1,m2,m3,m4) N- length(lst1) fn1- function(N,Out){ i=1 while(i=N){ Out[lst1[[i]]]-lst2[[i]] i-i+1 } Out } fn1(N,Out3) # y1 g24 c1 c2 l17 h4 s2 s30 e5 l15 #y1 0 1 1 1 1 1 1 1 1 1 #g24 1 0 0 0 0 0 0 0 0 0 #c1 1 0 0 1 1 0 0 0 0 0 #c2 1 0 1 0 1 0 0 0 0 0 #l17 1 0 1 1 0 0 0 0 0 0 #h4 1 0 0 0 0 0 1 1 0 0 #s2 1 0 0 0 0 1 0 1 0 0 #s30 1 0 0 0 0 1 1 0 0 0 #e5 1 0 0 0 0 0 0 0 0 1 #l15 1 0 0 0 0 0 0 0 1 0 identical(Out2,fn1(N,Out3)) #[1] TRUE A.K. - Original Message - From: arun smartpink...@yahoo.com To: R help r-help@r-project.org Cc: Sent: Thursday, September 5, 2013 4:09 PM Subject: Re: binary symmetric matrix combination Hi, May be this helps: m1- as.matrix(read.table(text= y1 g24 y1 0 1 g24 1 0 ,sep=,header=TRUE)) m2-as.matrix(read.table(text=y1 c1 c2 l17 y1 0 1 1 1 c1 1 0 1 1 c2 1 1 0 1 l17 1 1 1 0,sep=,header=TRUE)) m3- as.matrix(read.table(text=y1 h4 s2 s30 y1 0 1 1 1 h4 1 0 1 1 s2 1 1 0 1 s30 1 1 1 0,sep=,header=TRUE)) m4- as.matrix(read.table(text=y1 e5 l15 y1 0 1 1 e5 1 0 1 l15 1 1 0,sep=,header=TRUE)) ###desired output: at some place the label is s2 and at other s29. I used s2 for consistency Out1- as.matrix(read.table(text=y1 g24 c1 c2 l17 h4 s2 s30 e5 l15 y1 0 1 1 1 1 1 1 1 1 1 g24 1 0 0 0 0 0 0 0 0 0 c1 1 0 0 1 1 0 0 0 0 0 c2 1 0 1 0 1 0 0 0 0 0 l17 1 0 1 1 0 0 0 0 0 0 h4 1 0 0 0 0 0 1 1 0 0 s2 1 0 0 0 0 1 0 1 0 0 s30 1 0 0 0 0 1 1 0 0 0 e5 1 0 0 0 0 0 0 0 0 1 l15 1 0 0 0 0 0 0 0 1 0,sep=,header=TRUE))
Re: [R] get syntax for inherited environments
?sys.parent (and friends) -- Bert On Thu, Sep 5, 2013 at 4:37 PM, ivo welch ivo.we...@anderson.ucla.eduwrote: quick question. how do I search up the calling environments until I find a variable? x=function() { m=22; y() } y=function() { z() } z=function() { mget(m, inherits=TRUE, ifnotfound=m not found) } x() $m [1] m not found from the perspective of z(), function x is not an enclosing environment. do I write a while loop to look back, or is there a standard R function that searches all calling environments until it finds one that works? regards, /iaw Ivo Welch (ivo.we...@gmail.com) [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Bert Gunter Genentech Nonclinical Biostatistics Internal Contact Info: Phone: 467-7374 Website: http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm [[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] Y-axis labels as decimal numbers
On 09/05/2013 11:22 PM, mohan.radhakrish...@polarisft.com wrote: Hi, I am able to create a graph with this code but the decimal numbers are not plotted accurately because the ylim values are not set properly. x-axis is proper. How do I accurately set the ylim for duration.1 column ? Hi Mohan, I think you may have your axes mixed up. Try this and see: set1-read.table(text=duration duration.1 16:03:41 0.05 17:03:41 0.27 18:03:43 1.22 19:03:45 1.51 20:03:47 1.27 21:03:48 1.15 22:03:50 1.22 23:03:52 1.27 00:03:54 1.27 01:03:55 1.22 02:03:57 1.26 03:03:59 1.57 04:04:01 1.31 05:04:03 1.24,header=TRUE) set1$duration- as.POSIXct(paste(c(rep('2013-08-24',8),rep('2013-08-25',6)), set1$duration)) par(mar=c(10,4,4,2)) plot(set1$duration,set1$duration.1,type=b,col=blue,ylab=,xaxt='n', xlab=,las=2,lwd=2.5,lty=1,cex.axis=2.5) axis(1, at = set1$duration, labels = set1$duration, las = 2,cex.axis=1) par(mar=c(5,4,4,2)) Jim __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Looping an lapply linear regression function
Hello Arun. Can you provide some data? To help you better i will need a complete reproducible example ok? On Thu, Sep 5, 2013 at 1:49 PM, arun smartpink...@yahoo.com wrote: HI, May be this helps: set.seed(28) dat1- setNames(as.data.frame(matrix(sample(1:40,10*5,replace=TRUE),ncol=5)),letters[1:5]) indx-as.data.frame(combn(names(dat1),2),stringsAsFactors=FALSE) res-t(sapply(indx,function(x) {x1-cbind(dat1[x[1]],dat1[x[2]]);summary(lm(x1[,1]~x1[,2]))$coef[,4]})) rownames(res)-apply(indx,2,paste,collapse=_) colnames(res)[2]- Coef1 head(res,3) #(Intercept) Coef1 #a_b 0.39862676 0.8365606 #a_c 0.02427885 0.6094141 #a_d 0.37521423 0.7578723 #permutation indx2-expand.grid(names(dat1),names(dat1),stringsAsFactors=FALSE) #or indx2- expand.grid(rep(list(names(dat1)),2),stringsAsFactors=FALSE) indx2New- indx2[indx2[,1]!=indx2[,2],] res2-t(sapply(seq_len(nrow(indx2New)),function(i) {x1- indx2New[i,]; x2-cbind(dat1[x1[,1]],dat1[x1[,2]]);summary(lm(x2[,1]~x2[,2]))$coef[,4]})) row.names(res2)-apply(indx2New,1,paste,collapse=_) colnames(res2)- colnames(res) A.K. Hi everyone, First off just like to say thanks to everyone´s contributions. Up until now, I´ve never had to post as I´ve always found the answers from trawling through the database. I´ve finally managed to stump myself, and although for someone out there, I´m sure the answer to my problem is fairly simple, I, however have spent the whole day infront of my computer struggling. I know I´ll probably get an absolute ribbing for making a basic mistake, or not understanding something fully, but I´m blind to the mistake now after looking so long at it. What I´m looking to do, is formulate a matrix ([28,28]) of p-values produced from running linear regressions of 28 variables against themselves (eg a~b, a~c, a~d.b~a, b~c etc...), if that makes sense. I´ve managed to get this to work if I just input each variable by hand, but this isn´t going to help when I have to make 20 matrices. My script is as follows; for (j in [1:28]) { ##This section works perfectly, if I don´t try to loop it, I know this wont work at the moment, because I haven´t designated what j is, but I´m showing to highlight what I´m attempting to do. models - lapply(varlist, function(x) { lm(substitute(ANS ~ i, list(i = as.name(x))), data = con.i) }) abc- lapply(models, function(f) summary(f)$coefficients[,4]) abc- do.call(rbind, abc) } I get the following error when I try to loop it... Error in model.frame.default(formula = substitute(j ~ i, list(i = as.name(x))), : variable lengths differ (found for 'ANS') ##ÄNS being my first variable All variables are of the same length, with 21 recordings for each If anyone can suggest a method of looping, or another means or producing ´models´ for each of my 28 variables, without having to do it by hand that would be fantastic. Thanks in advance!! __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] setStatusBar function gives error message in R 3.01 under Windows 7
On 05/09/2013 10:20 AM, Gwen D. LaSelva wrote: I am running R 3.01 under 64-bit Windows 7. When I try to set the status bar, I get an error message. For example: text-hello setStatusBar(text) Error in .Call(setStatusBar, text) : first argument must be a string (of length 1) or native symbol reference The related function, setWindowTitle(), appears to work just fine. Is this a bug? Or am I doing something wrong? It does seem to work OK in R 2.13.0. Could you please try the R-patched nightly build (from http://cran.r-project.org/bin/windows/base/rpatched.html)? I think this has already been fixed. Duncan Murdoch __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] setStatusBar function gives error message in R 3.01 under Windows 7
On 05/09/2013 10:20 AM, Gwen D. LaSelva wrote: I am running R 3.01 under 64-bit Windows 7. When I try to set the status bar, I get an error message. For example: text-hello setStatusBar(text) Error in .Call(setStatusBar, text) : first argument must be a string (of length 1) or native symbol reference The related function, setWindowTitle(), appears to work just fine. Is this a bug? Or am I doing something wrong? It does seem to work OK in R 2.13.0. Thanks, looks like a bug, and looks easy to fix. Should make it into 3.0.2 later this month. Duncan Murdoch __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] applying a univariate function for each response in a multivariate linear model (mlm)
After fitting a multivariate linear model (mlm), I'd like to be able to run or apply a standard univariate stats:::*.lm function to each of the response variables, within a function -- i.e., by operating on the mlm object, rather than re-running the univariate models separately manually. An example: extracting cooks.distance components (via stats:::cooks.distance.lm) grain - c(40, 17, 9, 15, 6, 12, 5, 9)# y1 straw - c(53, 19, 10, 29, 13, 27, 19, 30)# y2 fertilizer - c(24, 11, 5, 12, 7, 14, 11, 18) # x Fertilizer - data.frame(grain, straw, fertilizer) # fit the mlm mod - lm(cbind(grain, straw) ~ fertilizer, data=Fertilizer) # run univariate regressionsand get cooks.distance (cookd.grain - cooks.distance(lm(grain ~ fertilizer, data=Fertilizer))) 1 2 3 4 5 6 7 3.4436e+00 4.0957e-02 2.2733e-01 4.8605e-03 1.4073e-05 2.0479e-02 6.4192e-02 8 4.8383e-01 (cookd.straw - cooks.distance(lm(straw ~ fertilizer, data=Fertilizer))) 1 2 3 4 5 6 7 8 2.0003953 0.0283225 0.0675803 0.1591198 0.0013352 0.0024076 0.0283225 0.4672299 This is the result I want: data.frame(cookd.grain, cookd.straw) cookd.grain cookd.straw 1 3.4436e+00 2.0003953 2 4.0957e-02 0.0283225 3 2.2733e-01 0.0675803 4 4.8605e-03 0.1591198 5 1.4073e-05 0.0013352 6 2.0479e-02 0.0024076 7 6.4192e-02 0.0283225 8 4.8383e-01 0.4672299 Note that if I call cooks.distance.lm directly on the mlm object, there is no complaint or warning, but the result is silently WRONG: # try calling cooks.distance.lm directly: silently WRONG stats:::cooks.distance.lm(mod) grain straw 1 3.4436e+00 0.51729792 2 1.5838e-01 0.02832250 3 2.2733e-01 0.01747613 4 1.8796e-02 0.15911979 5 1.4073e-05 0.00034527 6 7.9192e-02 0.00240762 7 6.4192e-02 0.00732414 8 1.8710e+00 0.46722985 I realize that I can also use update() on the mlm object to re-fit the univariate models, but I don't know how to extract the response names from it to do this in a function coef(mod) # multivariate grain straw (Intercept) -3.7524 -2.2965 fertilizer 1.4022 2.1409 coef(update(mod, grain ~ .)) (Intercept) fertilizer -3.7524 1.4022 coef(update(mod, straw ~ .)) (Intercept) fertilizer -2.2965 2.1409 -- Michael Friendly Email: friendly AT yorku DOT ca Professor, Psychology Dept. Chair, Quantitative Methods York University Voice: 416 736-2100 x66249 Fax: 416 736-5814 4700 Keele StreetWeb: http://www.datavis.ca Toronto, ONT M3J 1P3 CANADA __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Looping an lapply linear regression function
HI, May be this helps: set.seed(28) dat1- setNames(as.data.frame(matrix(sample(1:40,10*5,replace=TRUE),ncol=5)),letters[1:5]) indx-as.data.frame(combn(names(dat1),2),stringsAsFactors=FALSE) res-t(sapply(indx,function(x) {x1-cbind(dat1[x[1]],dat1[x[2]]);summary(lm(x1[,1]~x1[,2]))$coef[,4]})) rownames(res)-apply(indx,2,paste,collapse=_) colnames(res)[2]- Coef1 head(res,3) # (Intercept) Coef1 #a_b 0.39862676 0.8365606 #a_c 0.02427885 0.6094141 #a_d 0.37521423 0.7578723 #permutation indx2-expand.grid(names(dat1),names(dat1),stringsAsFactors=FALSE) #or indx2- expand.grid(rep(list(names(dat1)),2),stringsAsFactors=FALSE) indx2New- indx2[indx2[,1]!=indx2[,2],] res2-t(sapply(seq_len(nrow(indx2New)),function(i) {x1- indx2New[i,]; x2-cbind(dat1[x1[,1]],dat1[x1[,2]]);summary(lm(x2[,1]~x2[,2]))$coef[,4]})) row.names(res2)-apply(indx2New,1,paste,collapse=_) colnames(res2)- colnames(res) A.K. Hi everyone, First off just like to say thanks to everyone´s contributions. Up until now, I´ve never had to post as I´ve always found the answers from trawling through the database. I´ve finally managed to stump myself, and although for someone out there, I´m sure the answer to my problem is fairly simple, I, however have spent the whole day infront of my computer struggling. I know I´ll probably get an absolute ribbing for making a basic mistake, or not understanding something fully, but I´m blind to the mistake now after looking so long at it. What I´m looking to do, is formulate a matrix ([28,28]) of p-values produced from running linear regressions of 28 variables against themselves (eg a~b, a~c, a~d.b~a, b~c etc...), if that makes sense. I´ve managed to get this to work if I just input each variable by hand, but this isn´t going to help when I have to make 20 matrices. My script is as follows; for (j in [1:28]) { ##This section works perfectly, if I don´t try to loop it, I know this wont work at the moment, because I haven´t designated what j is, but I´m showing to highlight what I´m attempting to do. models - lapply(varlist, function(x) { lm(substitute(ANS ~ i, list(i = as.name(x))), data = con.i) }) abc- lapply(models, function(f) summary(f)$coefficients[,4]) abc- do.call(rbind, abc) } I get the following error when I try to loop it... Error in model.frame.default(formula = substitute(j ~ i, list(i = as.name(x))), : variable lengths differ (found for 'ANS') ##ÄNS being my first variable All variables are of the same length, with 21 recordings for each If anyone can suggest a method of looping, or another means or producing ´models´ for each of my 28 variables, without having to do it by hand that would be fantastic. Thanks in advance!! __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] optim evils
Michael: Your parameter specification is probably over-determined, so that you have an infinite set of parameters that give essentially the same solution within numerical error. I would venture to guess that this will not be fixable with alternative optimizers. It is up to you to provide a sensible problem specification; failure to do so cannot be blamed on the optimizer. Cheers, Bert On Thu, Sep 5, 2013 at 3:23 AM, Michael Meyer spyqqq...@yahoo.com wrote: Thanks for all replies. The problem occurred in the following context: A Gaussian one dimensional mixture (number of constituents, locations, variances all unknown) is to be fitted to data (as starting value to or in lieu of mixtools). A likelihood maximization is performed. I'll try to destill the code so that reproducible failure of L-BFGS-B occurs and post it here. Michael Meyer [[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. -- Bert Gunter Genentech Nonclinical Biostatistics Internal Contact Info: Phone: 467-7374 Website: http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm [[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] Question about R2 in pls package
Thank you David, it is a good resouce to find related subjects. I need time to understand the topics. Thank you again Bjørn-Helge for your response. Euna [[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] read.dta()
I've been using R 3.0.1 version. I tried to read a file named abc.dta() I used the command X - read.dta(abc.dta) and it gave me Error: could not find function read.dta Can anyone help me what could be the problem and how to fix it ? Thanks, Deb. [[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] read.dta()
I don't know about 3.0.1, but the 2.15.x that I'm still using requires the foreign package--that's where the read.dta command resides. library(foreign) --Chris Ryan SUNY Upstate Medical University Binghamton, NY USA Debasish Roy wrote: I've been using R 3.0.1 version. I tried to read a file named abc.dta() I used the command X - read.dta(abc.dta) and it gave me Error: could not find function read.dta Can anyone help me what could be the problem and how to fix it ? Thanks, Deb. [[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] Y-axis labels as decimal numbers
Hi, set1$duration.2- as.POSIXct(paste('2013-08-24', set1$duration)) plot(set1$duration.2,set1$duration.1,type=b,col = blue, ylab=, xaxt = 'n', xlab=,las=2,lwd=2.5, lty=1,cex.axis=2.5) # now plot you times axis(1, at = set1$duration.2, labels = set1$duration, las = 2,cex.axis=2.5) text(set1$duration,set1$duration.1, set1$duration.1, 2, cex=1.45) I think this is the correct code. The graphs is attached. y-axis is not accurately shown. Thanks. From: jim holtman jholt...@gmail.com To: mohan.radhakrish...@polarisft.com Cc: R mailing list r-help@r-project.org Date: 09/05/2013 10:01 PM Subject:Re: [R] Y-axis labels as decimal numbers So what is wrong with the y-axis? When I run your script, things seem right. Can you explain what it is that you want. Jim Holtman Data Munger Guru What is the problem that you are trying to solve? Tell me what you want to do, not how you want to do it. On Thu, Sep 5, 2013 at 9:22 AM, mohan.radhakrish...@polarisft.com wrote: Hi, I am able to create a graph with this code but the decimal numbers are not plotted accurately because the ylim values are not set properly. x-axis is proper. How do I accurately set the ylim for duration.1 column ? Thanks, Mohan set1$duration- as.POSIXct(paste('2013-08-24', set1$duration)) plot(set1$duration,set1$duration.1,type=b,col = blue, ylab=, xaxt = 'n', xlab=,las=2,lwd=2.5, lty=1,cex.axis=2.5) # now plot you times axis(1, at = set1$duration, labels = set1$duration, las = 2,cex.axis=2.5) duration duration.1 2 16:03:41 0.05 3 17:03:41 0.27 4 18:03:43 1.22 5 19:03:45 1.51 6 20:03:47 1.27 7 21:03:48 1.15 8 22:03:50 1.22 9 23:03:52 1.27 10 00:03:54 1.27 11 01:03:55 1.22 12 02:03:57 1.26 13 03:03:59 1.57 14 04:04:01 1.31 15 05:04:03 1.24 This e-Mail may contain proprietary and confidential information and is sent for the intended recipient(s) only. If by an addressing or transmission error this mail has been misdirected to you, you are requested to delete this mail immediately. You are also hereby notified that any use, any form of reproduction, dissemination, copying, disclosure, modification, distribution and/or publication of this e-mail message, contents or its attachment other than by its intended recipient/s is strictly prohibited. Visit us at http://www.polarisFT.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. This e-Mail may contain proprietary and confidential information and is sent for the intended recipient(s) only. If by an addressing or transmission error this mail has been misdirected to you, you are requested to delete this mail immediately. You are also hereby notified that any use, any form of reproduction, dissemination, copying, disclosure, modification, distribution and/or publication of this e-mail message, contents or its attachment other than by its intended recipient/s is strictly prohibited. Visit us at http://www.polarisFT.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 densities outside axis
Hello, Using a web search engine, I found, for example: http://www.unt.edu/benchmarks/archives/2003/february03/rss.htm http://sas-and-r.blogspot.jp/2012_09_01_archive.html Hope this helps, Pascal 2013/9/5 Dustin Fife df...@ou.edu I've been working on a way to visualize a spearman correlation. That seemed pretty simple: generate skewed data x = rnorm(100)^2 y = .6*x + rnorm(100, 0, sqrt(1-.6^2)) plot(x,y) regular plot plot(rank(x),rank(y), xaxt=n, yaxt=n) ### spearman-like plot make axis labels axis(1, at=quantile(rank(x)), labels=round(quantile(x), digits=2)) axis(2, at=quantile(rank(y)), labels=round(quantile(y), digits=2)) However, transforming the data into ranks eliminates any information we have about the distributions of the data. My solution to this problem is to plot the densities outside the x/y axis with the mode of the distribution pointing away from the plot. I've seen plots like this in textbooks, but can't think of a way to do this in R. Any ideas? [[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.