Re: [R] reading files
Dear Arun, Thanks a ton for your help. Regards, Anupam On Tue, Sep 3, 2013 at 7:12 PM, arun smartpink...@yahoo.com wrote: HI, ?list.files() list.files() #created 4 files in my working directory #[1] A_hubs.txtA_nonhubs.txt B_hubs.txtB_nonhubs.txt #If you want to do wilcox.test in a pairwise manner: combn(list.files(),2) # [,1][,2] [,3][,4] #[1,] A_hubs.txtA_hubs.txt A_hubs.txtA_nonhubs.txt #[2,] A_nonhubs.txt B_hubs.txt B_nonhubs.txt B_hubs.txt #[,5][,6] #[1,] A_nonhubs.txt B_hubs.txt #[2,] B_nonhubs.txt B_nonhubs.txt P_value- sapply(as.data.frame(combn(list.files(),2),stringsAsFactors=FALSE),function(x){ x1-read.table(x[1],sep=,header=TRUE); x2- read.table(x[2],sep=,header=TRUE); wilcox.test(x1$TIS_SV,x2$TIS_SV)$p.value}) NAME-gsub([.txt],,apply(as.data.frame(combn(list.files(),2),stringsAsFactors=FALSE),2, paste,collapse=_)) res- data.frame(NAME,P_value,stringsAsFactors=FALSE) row.names(res)-1:nrow(res) res # NAME P_value #1A_hubs_A_nonhubs 0.3684845 #2 A_hubs_B_hubs 0.1388408 #3A_hubs_B_nonhubs 0.1531984 #4A_nonhubs_B_hubs 0.7910863 #5 A_nonhubs_B_nonhubs 0.4926012 #6B_hubs_B_nonhubs 0.6350055 A.K. - Original Message - From: anupam sinha anupam.cont...@gmail.com To: r-help@r-project.org Cc: Sent: Tuesday, September 3, 2013 6:58 AM Subject: [R] reading files Dear all, I need help with some coding. I have a directory with files like these: A_hubs A_nonhubs B_hubs B_nonhubs : : Each of these files have the following header and content: GENE TIS_DEG TOT_SVTIS_SVTIS_DISO ensg1 20 12 4 40 . . and so on... I want to calculate the p-value of the function wilcox.test(A_hubs$TIS_SV,A_nonhubs$TIS_SV) and store it in a table of the format NAME p-value A 0.05 Can some give me pointers in the direction? Thanks in advance Anupam [[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. -- Graduate Student, Laboratory of Computational Biology, Center For DNA Fingerprinting And Diagnostics, 4-1-714 to 725/2, Tuljaguda complex Mozamzahi Road, Nampally, Hyderabad-51 [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Error in Parts of Speach Tagging using openNLP
I posted on both the forums because i needed urgent help on the issue. And I am still waiting for a relevant reply on how to solve the issue. If you have any suggestions please do share. On Wed, Sep 4, 2013 at 6:08 AM, David Winsemius dwinsem...@comcast.netwrote: This was also posted on StackOverflow. Crossposting to R-help is discouraged. You are encouraged to read the Posting Guide and to learn how to post from gmail using plain text. -- David. On Sep 3, 2013, at 10:15 AM, Siddharth Arun wrote: I have an Ubuntu Quantal 12.10 Server 64-bit instance. I am using openNLP for POS Tagging of sentences. I am using POS tagging using openNLP with âParallel Lapply setupâ°. It is running fine in RStudio environment. But in Ubuntu environment it is showing the following error. *Error in do.call(c, clusterApply(cl, x = splitList(X, length(cl)), fun = lapply, :* * second argument must be a list* Any suggestion for the problem Iâm facing? This is the code that I am using: tagPOS - function(x, ...) { s - as.String(x) word_token_annotator - Maxent_Word_Token_Annotator() a2 - Annotation(1L, sentence, 1L, nchar(s)) a2 - annotate(s, word_token_annotator, a2) a3 - annotate(s, PTA, a2) a3w - a3[a3$type == word] POStags - unlist(lapply(a3w$features, `[[`, POS)) POStagged - paste(sprintf(%s/%s, s[a3w], POStags), collapse = ) list(POStagged = POStagged, POStags = POStags) } cl - makeCluster(mc - getOption(cl.cores, detectCores()/2)) clusterEvalQ(cl, { library(openNLP) library(NLP) PTA - Maxent_POS_Tag_Annotator() }) This is the setup I am using: · Created an cloud instance with Ubuntu Quantal 12.10 Server 64-bit instance · Installed LAMP server in the instance · After which I installed R. By default R version was 2.15.0 · Upgraded the R version to R 3.0.1 -- Regards, Siddharth Arun, Contact No. - +91 8880065278 [[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. David Winsemius Alameda, CA, USA -- Regards, Siddharth Arun, Contact No. - +91 8880065278 [[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] summary(object) not showing all values of a factor
Hi see ?contrasts ?model.matrix go through archives and through chapter 11.1.1 Contrasts from R-Intro document. Anyway, when you go through this chapter you will probably benefit from reading previous chapters too. Regards Petr -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On Behalf Of Soumitro Dey Sent: Tuesday, September 03, 2013 8:51 PM To: r-help@r-project.org Subject: [R] summary(object) not showing all values of a factor Dear all, I am encountering some odd results from the summary(object) command for coxph and hurdle models. In both cases the result of summary(object) function leaves out one of the categories of a categorical variable used in the model. It is typically the first category if sorted alphabetically. Is there any way around this problem? For example, if I have categorical variable type with values {A,B,C,D,E}, it typically leaves out A in the result of the summary. Thanks! [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting- guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Error in Parts of Speach Tagging using openNLP
Well, abusing the system does not appear to be working, does it? The correct approach is to be more targeted in your audience. Is your problem with Ubuntu? Perhaps you need to post in the r-sig-debian mailing list. Is your issue specifically with the openNLS package? Try a simplified parallel processing example to see if that works (the error indicates some problem with the clusterApply function). If the package is the issue, contact the package maintainer. If the parallel processing example does not work, you will have narrowed the scope of concern considerably for discussion here. However, with RStudio and unfamiliar (to me) packages in the mix, and cross-posting that I interpret to mean some other conversation may answer it anyway, it is way easier to ignore your plea than to try to help you figure it out. And you still have not followed the Posting Guide recommendation to post using plain text format, so your example code is messed up. --- Jeff NewmillerThe . . Go Live... DCN:jdnew...@dcn.davis.ca.usBasics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/BatteriesO.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --- Sent from my phone. Please excuse my brevity. Siddharth Arun sid.aru...@gmail.com wrote: I posted on both the forums because i needed urgent help on the issue. And I am still waiting for a relevant reply on how to solve the issue. If you have any suggestions please do share. On Wed, Sep 4, 2013 at 6:08 AM, David Winsemius dwinsem...@comcast.netwrote: This was also posted on StackOverflow. Crossposting to R-help is discouraged. You are encouraged to read the Posting Guide and to learn how to post from gmail using plain text. -- David. On Sep 3, 2013, at 10:15 AM, Siddharth Arun wrote: I have an Ubuntu Quantal 12.10 Server 64-bit instance. I am using openNLP for POS Tagging of sentences. I am using POS tagging using openNLP with ���Parallel Lapply setup���. It is running fine in RStudio environment. But in Ubuntu environment it is showing the following error. *Error in do.call(c, clusterApply(cl, x = splitList(X, length(cl)), fun = lapply, :* * second argument must be a list* Any suggestion for the problem I���m facing? This is the code that I am using: tagPOS - function(x, ...) { s - as.String(x) word_token_annotator - Maxent_Word_Token_Annotator() a2 - Annotation(1L, sentence, 1L, nchar(s)) a2 - annotate(s, word_token_annotator, a2) a3 - annotate(s, PTA, a2) a3w - a3[a3$type == word] POStags - unlist(lapply(a3w$features, `[[`, POS)) POStagged - paste(sprintf(%s/%s, s[a3w], POStags), collapse = ) list(POStagged = POStagged, POStags = POStags) } cl - makeCluster(mc - getOption(cl.cores, detectCores()/2)) clusterEvalQ(cl, { library(openNLP) library(NLP) PTA - Maxent_POS_Tag_Annotator() }) This is the setup I am using: �� Created an cloud instance with Ubuntu Quantal 12.10 Server 64-bit instance �� Installed LAMP server in the instance �� After which I installed R. By default R version was 2.15.0 �� Upgraded the R version to R 3.0.1 -- Regards, Siddharth Arun, Contact No. - +91 8880065278 [[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. David Winsemius 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.
[R] optim evils
It would take some effort to extract selfcontained code from the mass of code wherein this optimization is embedded. Moreover I would have to obtain permission from my employer to do so. This is not efficient. However some things are evident from the trace log which I have submitted: (a) L-BFGS-B does not identify itself even though it was called overriding the method parameter in optim. (b) Optim reports as final converged minimum value a function value that is much larger than others computed during the optimization. I think we can agree on calling this a bug. [[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
Hi Michael, You do not need to create a self-contained example from the mass of code where it is embedded, but given that optim() works in many cases, to file a bug report, you do need to give _an_ example where it is failing. Here is an example where it works great: optim(1, fn = function(x) x - 5, method = CG, lower = 3) $par [1] 3 $value [1] -2 $counts function gradient 11 $convergence [1] 0 $message [1] CONVERGENCE: NORM OF PROJECTED GRADIENT = PGTOL Warning message: In optim(1, fn = function(x) x - 5, method = CG, lower = 3) : bounds can only be used with method L-BFGS-B (or Brent) and it gives a warning at the end regarding L-BFGS-B. On Wed, Sep 4, 2013 at 1:34 AM, Michael Meyer spyqqq...@yahoo.com wrote: It would take some effort to extract selfcontained code from the mass of code wherein this optimization is embedded. Moreover I would have to obtain permission from my employer to do so. This is not efficient. However some things are evident from the trace log which I have submitted: (a) L-BFGS-B does not identify itself even though it was called overriding the method parameter in optim. (b) Optim reports as final converged minimum value a function value that is much larger than others computed during the optimization. I think we can agree on calling this a bug. [[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.
Re: [R] XLSX package + Excel creation question
http://stackoverflow.com/questions/18511249/excel-cell-coloring-using-xlsx This is the initial post on stackoverflow. Please look at this maybe I'm clearer here. Thank you in advance, - - László-András Zsurzsa,- - Msc. Infromatics, Technical University Munich, Germany - - Scientific Employee, TUM - - On Fri, Aug 30, 2013 at 3:48 PM, jim holtman jholt...@gmail.com wrote: You can also look at the XLConnect package. 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, Aug 29, 2013 at 9:40 AM, Zsurzsa Laszlo zsurzsalas...@gmail.com wrote: I understand you response but it does not solve the problem. I'am aware that one can simply color every cell in an excel file by using his own algorithm. The question was if I can write my data to a *single* cells and use different formatting for every piece of data. - - László-András Zsurzsa,- - Msc. Infromatics, Technical University Munich, Germany - - Scientific Employee, TUM - - On Thu, Aug 29, 2013 at 3:36 PM, Rainer Hurling rhur...@gwdg.de wrote: Am 29.08.2013 15:03 (UTC+1) schrieb Zsurzsa Laszlo: First of all thank you for the quick resposen. I know I can color and set up every cell. I will take a look again * CellStyle* but is it possbile for example to write an array to a single cell that has different colors for some data. Basically the color depends on the data. As far as I know there is no ready to use functionality to mask groups of selected cells. You have to write your own function, which selects the right cells and changes their style with setCellStyle(cell, cellStyle). Some hints are given in the examples section of ?CellStyle. - - László-András Zsurzsa, - - Msc. Infromatics, Technical University Munich, Germany - - Scientific Employee, TUM - - On Thu, Aug 29, 2013 at 2:55 PM, Rainer Hurling rhur...@gwdg.de wrote: Am 29.08.2013 12:08 (UTC+1) schrieb Zsurzsa Laszlo: Dear R users, I have a question about the xlsx package. It's possible to create excel files and color cells and etc. yes, with package xlsx you can colourize you data sheets, even the fonts. See for example ?CellStyle . A good demonstration of the capabilities is on http://tradeblotter.wordpress.com/2013/05/02/writing-from-r-to-excel-with-xlsx/ My question would be that is it possible to color only some part of the data hold in a cell. Let's assume I've got the following data : 167,153,120,100 and I want to color to red everything that is bigger then 120. How can I achive this using R. Example file setup with a few lines in attachment. (SEL_MASS column can be used for example) Attachment missing ... HTH, Rainer Thank you in advance, - - László-András Zsurzsa, - - Msc. Infromatics, Technical University Munich, Germany - - Scientific Employee, TUM - - [[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. [[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] Multiple regression (with interactions) by hand
Hi Christoph, ginv() computes the Moore-Penrose generalized inverse by way of a singular value decomposition. Part of the calculation involves taking the reciprocal of the non zero values. In practice, non zero is really within some precision tolerance of zero. Numerical precision can bite you in scientific computing. There are many examples where the most conceptually straightforward approach is not the best approach because whereas the equation may be easy to write symbolically, it is more vulnerable to rounding or truncation errors that occur in floating point representations. Aside from working through some matrix algebra for understanding, using established code (like lm) for models where the authors will have taken issues like numerical precision and stability into consideration is generally safest. Cheers, Josh On Tue, Sep 3, 2013 at 6:22 AM, Christoph Scherber christoph.scher...@agr.uni-goettingen.de wrote: Dear all, But why are there such huge differences betwen solve() and ginv()? (see code below)? ## m1=lm(Ozone~Solar.R*Wind,airquality) # remove NA´s: airquality2=airquality[complete.cases(airquality$Ozone) complete.cases(airquality$Solar.R) complete.cases(airquality$Wind),] # create the model matrix by hand: X=cbind((Intercept)=1,Solar.R=airquality2$Solar.R,Wind=airquality2$Wind,Solar.R:Wind=airquality2$Solar.R*airquality2$Wind) # is the same as: model.matrix(m1) # create the response vector by hand: Y=airquality2$Ozone # is the same as: m1$model$Ozone # Now solve for the parameter estimates: solve(crossprod(X)) %*% crossprod(X,Y) #gives the correct answer library(MASS) ginv(t(X)%*%X)%*%t(X)%*%Y #gives a wrong answer Am 03/09/2013 12:29, schrieb Joshua Wiley: Hi Christoph, Use this matrix expression instead: solve(crossprod(X)) %*% t(X) %*% Y Note that: all.equal(crossprod(X), t(X) %*% X) Cheers, Joshua On Tue, Sep 3, 2013 at 2:51 AM, Christoph Scherber christoph.scher...@agr.uni-goettingen.de wrote: Dear all, I´ve played around with the airquality dataset, trying to solve the matrix equations of a simple multiple regression by hand; however, my matrix multiplications don´t lead to the estimates returned by coef(). What have I done wrong here? ## m1=lm(Ozone~Solar.R*Wind,airquality) # remove NA´s: airquality2=airquality[complete.cases(airquality$Ozone) complete.cases(airquality$Solar.R) complete.cases(airquality$Wind),] # create the model matrix by hand: X=cbind((Intercept)=1,Solar.R=airquality2$Solar.R,Wind=airquality2$Wind,Solar.R:Wind=airquality2$Solar.R*airquality2$Wind) # is the same as: model.matrix(m1) # create the response vector by hand: Y=airquality2$Ozone # is the same as: m1$model$Ozone # Now solve for the parameter estimates: library(MASS) ginv(t(X)%*%X)%*%t(X)%*%Y # is not the same as: coef(m1) ## Now why is my result (line ginv(...)) not the same as the one returned by coef(m1)? Thanks very much for your help! Best regards, Christoph [using R 3.0.1 on Windows 7 32-Bit] -- PD Dr Christoph Scherber Georg-August University Goettingen Department of Crop Science Agroecology Grisebachstrasse 6 D-37077 Goettingen Germany phone 0049 (0)551 39 8807 fax 0049 (0)551 39 8806 http://www.gwdg.de/~cscherb1 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Memory usage bar plot
Hi, I have tried the ideas with an actual data set but couldn't pass the parsing phase. The name of the 'Program' varies. MiB and KiB are both included. I should have shown the real-time data set. Private + Shared = RAM used Program 84.0 KiB + 14.5 KiB = 98.5 KiB sleep 108.0 KiB + 11.5 KiB = 119.5 KiB klogd 124.0 KiB + 15.0 KiB = 139.0 KiB hidd 128.0 KiB + 12.5 KiB = 140.5 KiB gpm 116.0 KiB + 28.5 KiB = 144.5 KiB hald-addon-storage 120.0 KiB + 28.0 KiB = 148.0 KiB acpid 128.0 KiB + 25.0 KiB = 153.0 KiB dbus-launch 128.0 KiB + 31.5 KiB = 159.5 KiB hald-addon-acpi 144.0 KiB + 19.0 KiB = 163.0 KiB sdpd 152.0 KiB + 16.5 KiB = 168.5 KiB irqbalance 140.0 KiB + 28.5 KiB = 168.5 KiB pam_timestamp_check 152.0 KiB + 20.0 KiB = 172.0 KiB init 148.0 KiB + 26.0 KiB = 174.0 KiB mapping-daemon 152.0 KiB + 25.5 KiB = 177.5 KiB gnome-keyring-daemon 152.0 KiB + 26.5 KiB = 178.5 KiB portmap 164.0 KiB + 16.0 KiB = 180.0 KiB syslogd 168.0 KiB + 24.5 KiB = 192.5 KiB atd 180.0 KiB + 18.5 KiB = 198.5 KiB brcm_iscsiuio 188.0 KiB + 37.0 KiB = 225.0 KiB rpc.statd 208.0 KiB + 26.0 KiB = 234.0 KiB audispd 208.0 KiB + 39.5 KiB = 247.5 KiB hald-runner 244.0 KiB + 23.5 KiB = 267.5 KiB smartd 240.0 KiB + 35.5 KiB = 275.5 KiB hpiod 244.0 KiB + 35.0 KiB = 279.0 KiB hcid 228.0 KiB + 73.0 KiB = 301.0 KiB hald-addon-keyboard (2) 328.0 KiB + 32.5 KiB = 360.5 KiB gam_server 336.0 KiB + 31.5 KiB = 367.5 KiB xinetd 364.0 KiB + 28.5 KiB = 392.5 KiB auditd 420.0 KiB + 78.0 KiB = 498.0 KiB mingetty (6) 552.0 KiB + 19.5 KiB = 571.5 KiB udevd 532.0 KiB + 56.0 KiB = 588.0 KiB rpc.idmapd 544.0 KiB + 51.5 KiB = 595.5 KiB ssh-agent 372.0 KiB + 225.0 KiB = 597.0 KiB sh (2) 612.0 KiB + 28.0 KiB = 640.0 KiB crond 484.0 KiB + 175.0 KiB = 659.0 KiB avahi-daemon (2) 744.0 KiB + 74.5 KiB = 818.5 KiB automount 756.0 KiB + 186.5 KiB = 942.5 KiB gnome-vfs-daemon 736.0 KiB + 295.0 KiB = 1.0 MiB dbus-daemon (2) 988.0 KiB + 61.5 KiB = 1.0 MiB pcscd 824.0 KiB + 231.5 KiB = 1.0 MiB pam-panel-icon 1.0 MiB + 26.0 KiB = 1.1 MiB nmon 864.0 KiB + 229.5 KiB = 1.1 MiB bt-applet 712.0 KiB + 402.0 KiB = 1.1 MiB nm-system-settings 1.0 MiB + 63.0 KiB = 1.1 MiB nmbd 996.0 KiB + 131.0 KiB = 1.1 MiB bonobo-activation-server 740.0 KiB + 398.5 KiB = 1.1 MiB escd 868.0 KiB + 375.0 KiB = 1.2 MiB bash (2) 1.1 MiB + 212.5 KiB = 1.3 MiB gnome-screensaver 796.0 KiB + 621.5 KiB = 1.4 MiB gdm-rh-security-token-helper 1.2 MiB + 387.5 KiB = 1.6 MiB gnome-session 916.0 KiB + 749.5 KiB = 1.6 MiB gdm-binary (2) 1.4 MiB + 225.0 KiB = 1.6 MiB cupsd 1.3 MiB + 443.5 KiB = 1.8 MiB notification-area-applet 2.1 MiB + 68.0 KiB = 2.2 MiB xfs 1.8 MiB + 545.5 KiB = 2.3 MiB eggcups 2.2 MiB + 86.5 KiB = 2.3 MiB gconfd-2 1.9 MiB + 492.5 KiB = 2.4 MiB gnome-settings-daemon 2.0 MiB + 421.5 KiB = 2.4 MiB gnome-power-manager 1.9 MiB + 570.0 KiB = 2.5 MiB trashapplet 1.7 MiB + 1.0 MiB = 2.7 MiB smbd (2) 2.6 MiB + 422.0 KiB = 3.0 MiB iscsid (2) 2.7 MiB + 350.0 KiB = 3.0 MiB sendmail.sendmail (2) 3.2 MiB + 72.0 KiB = 3.2 MiB hald 2.0 MiB + 1.3 MiB = 3.3 MiB sshd (3) 2.7 MiB + 651.0 KiB = 3.4 MiB clock-applet 2.5 MiB + 1.4 MiB = 3.9 MiB nm-applet 3.4 MiB + 728.5 KiB = 4.1 MiB metacity 3.4 MiB + 853.0 KiB = 4.3 MiB wnck-applet 4.4 MiB + 376.5 KiB = 4.8 MiB Xorg 4.3 MiB + 718.5 KiB = 5.0 MiB mixer_applet2 4.5 MiB + 809.5 KiB = 5.3 MiB gnome-panel 5.3 MiB + 251.5 KiB = 5.6 MiB hpssd.py 6.2 MiB + 4.1 MiB = 10.3 MiB httpd (18) 10.5 MiB + 869.0 KiB = 11.3 MiB gdmgreeter 12.8 MiB + 1.1 MiB = 13.8 MiB Xvnc 13.7 MiB + 515.5 KiB = 14.2 MiB yum-updatesd 16.3 MiB + 1.6 MiB = 17.9 MiB nautilus 20.8 MiB + 1.4 MiB = 22.2 MiB puplet 1.5 GiB + 441.0 KiB = 1.5 GiB java - 1.7 GiB = Private + Shared = RAM used Program 108.0 KiB + 11.5 KiB = 119.5 KiB klogd 124.0 KiB + 15.0 KiB = 139.0 KiB hidd 128.0 KiB + 12.5 KiB = 140.5 KiB gpm 116.0 KiB + 29.5 KiB = 145.5 KiB hald-addon-storage 120.0 KiB + 28.0 KiB = 148.0 KiB acpid 128.0 KiB + 25.0 KiB = 153.0 KiB dbus-launch 128.0 KiB + 31.5 KiB = 159.5 KiB hald-addon-acpi 144.0 KiB + 20.0 KiB = 164.0 KiB sdpd 140.0 KiB + 26.5 KiB = 166.5 KiB pam_timestamp_check 152.0 KiB + 16.5 KiB = 168.5 KiB irqbalance 152.0 KiB + 20.0 KiB = 172.0 KiB
Re: [R] ESEM in R
Hi Krzysztof, Have a look at the packages sem, lavaan and psych. Regards, José Prof. José Iparraguirre Chief Economist Age UK -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of fronc...@vizja.pl Sent: 03 September 2013 13:33 To: r-help@r-project.org Subject: [R] ESEM in R Hello R experts, Is there any possibility to perform exploratory structural equation modeling (ESEM) in R? Which package should I use? Thanks a lot for help, Krzysztof __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. The Wireless from Age UK | Radio for grown-ups. www.ageuk.org.uk/thewireless If you’re looking for a radio station that offers real variety, tune in to The Wireless from Age UK. Whether you choose to listen through the website at www.ageuk.org.uk/thewireless, on digital radio (currently available in London and Yorkshire) or through our TuneIn Radio app, you can look forward to an inspiring mix of music, conversation and useful information 24 hours a day. --- Age UK is a registered charity and company limited by guarantee, (registered charity number 1128267, registered company number 6825798). Registered office: Tavis House, 1-6 Tavistock Square, London WC1H 9NA. For the purposes of promoting Age UK Insurance, Age UK is an Appointed Representative of Age UK Enterprises Limited, Age UK is an Introducer Appointed Representative of JLT Benefit Solutions Limited and Simplyhealth Access for the purposes of introducing potential annuity and health cash plans customers respectively. Age UK Enterprises Limited, JLT Benefit Solutions Limited and Simplyhealth Access are all authorised and regulated by the Financial Services Authority. -- This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you receive a message in error, please advise the sender and delete immediately. Except where this email is sent in the usual course of our business, any opinions expressed in this email are those of the author and do not necessarily reflect the opinions of Age UK or its subsidiaries and associated companies. Age UK monitors all e-mail transmissions passing through its network and may block or modify mails which are deemed to be unsuitable. Age Concern England (charity number 261794) and Help the Aged (charity number 272786) and their trading and other associated companies merged on 1st April 2009. Together they have formed the Age UK Group, dedicated to improving the lives of people in later life. The three national Age Concerns in Scotland, Northern Ireland and Wales have also merged with Help the Aged in these nations to form three registered charities: Age Scotland, Age NI, Age Cymru. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] XLSX package + Excel creation question
I'll skip over the courtesy implications of double posting/pointing to stackoverflow. The stackoverflow thread makes it look as if you need to learn more Excel. Do you really not know what an Excel template is? It sounds as if you want what Excel calls conditional formatting which you can specify as custom number formats, see http://www.ozgrid.com/Excel/CustomFormats.htm. Excel's help on custom number formats says: To specify number formats that will be applied only if a number meets a condition that you specify, enclose the condition in square brackets. The condition consists of a comparison operator (comparison operator: A sign that is used in comparison criteria to compare two values. Operators include: = Equal to, Greater than, Less than, = Greater than or equal to, = Less than or equal to, and Not equal to.) and a value. For example, the following format displays numbers that are less than or equal to 100 in a red font and numbers that are greater than 100 in a blue font. [Red][=100];[Blue][100] -- R package xlsx allows such formats (?DataFormat) as does R package XLConnect (?setDataFormat). HTH Keith J On 04/09/2013 09:57, Zsurzsa Laszlo wrote: http://stackoverflow.com/questions/18511249/excel-cell-coloring-using-xlsx This is the initial post on stackoverflow. Please look at this maybe I'm clearer here. Thank you in advance, - - László-András Zsurzsa,- - Msc. Infromatics, Technical University Munich, Germany - - Scientific Employee, TUM - - On Fri, Aug 30, 2013 at 3:48 PM, jim holtmanjholt...@gmail.com wrote: You can also look at the XLConnect package. 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, Aug 29, 2013 at 9:40 AM, Zsurzsa Laszlozsurzsalas...@gmail.com wrote: I understand you response but it does not solve the problem. I'am aware that one can simply color every cell in an excel file by using his own algorithm. The question was if I can write my data to a *single* cells and use different formatting for every piece of data. - - László-András Zsurzsa,- - Msc. Infromatics, Technical University Munich, Germany - - Scientific Employee, TUM - - On Thu, Aug 29, 2013 at 3:36 PM, Rainer Hurlingrhur...@gwdg.de wrote: Am 29.08.2013 15:03 (UTC+1) schrieb Zsurzsa Laszlo: First of all thank you for the quick resposen. I know I can color and set up every cell. I will take a look again * CellStyle* but is it possbile for example to write an array to a single cell that has different colors for some data. Basically the color depends on the data. As far as I know there is no ready to use functionality to mask groups of selected cells. You have to write your own function, which selects the right cells and changes their style with setCellStyle(cell, cellStyle). Some hints are given in the examples section of ?CellStyle. - - László-András Zsurzsa, - - Msc. Infromatics, Technical University Munich, Germany - - Scientific Employee, TUM - - On Thu, Aug 29, 2013 at 2:55 PM, Rainer Hurlingrhur...@gwdg.de wrote: Am 29.08.2013 12:08 (UTC+1) schrieb Zsurzsa Laszlo: Dear R users, I have a question about the xlsx package. It's possible to create excel files and color cells and etc. yes, with package xlsx you can colourize you data sheets, even the fonts. See for example ?CellStyle . A good demonstration of the capabilities is on http://tradeblotter.wordpress.com/2013/05/02/writing-from-r-to-excel-with-xlsx/ My question would be that is it possible to color only some part of the data hold in a cell. Let's assume I've got the following data : 167,153,120,100 and I want to color to red everything that is bigger then 120. How can I achive this using R. Example file setup with a few lines in attachment. (SEL_MASS column can be used for example) Attachment missing ... HTH, Rainer Thank you in advance, - - László-András Zsurzsa, - - Msc. Infromatics, Technical University Munich, Germany - - Scientific Employee, TUM - -
Re: [R] XLSX package + Excel creation question
Thank you for the reply, I wount post any other link anymore. I did not know it's not allowed. - - László-András Zsurzsa,- - Msc. Infromatics, Technical University Munich, Germany - - Scientific Employee, TUM - - On Wed, Sep 4, 2013 at 1:22 PM, Keith Jewell keith.jew...@campdenbri.co.ukwrote: I'll skip over the courtesy implications of double posting/pointing to stackoverflow. The stackoverflow thread makes it look as if you need to learn more Excel. Do you really not know what an Excel template is? It sounds as if you want what Excel calls conditional formatting which you can specify as custom number formats, see http://www.ozgrid.com/Excel/ **CustomFormats.htm http://www.ozgrid.com/Excel/CustomFormats.htm. Excel's help on custom number formats says: To specify number formats that will be applied only if a number meets a condition that you specify, enclose the condition in square brackets. The condition consists of a comparison operator (comparison operator: A sign that is used in comparison criteria to compare two values. Operators include: = Equal to, Greater than, Less than, = Greater than or equal to, = Less than or equal to, and Not equal to.) and a value. For example, the following format displays numbers that are less than or equal to 100 in a red font and numbers that are greater than 100 in a blue font. [Red][=100];[Blue][100] -- R package xlsx allows such formats (?DataFormat) as does R package XLConnect (?setDataFormat). HTH Keith J On 04/09/2013 09:57, Zsurzsa Laszlo wrote: http://stackoverflow.com/**questions/18511249/excel-cell-** coloring-using-xlsxhttp://stackoverflow.com/questions/18511249/excel-cell-coloring-using-xlsx This is the initial post on stackoverflow. Please look at this maybe I'm clearer here. Thank you in advance, --**--** - - László-András Zsurzsa,- - Msc. Infromatics, Technical University Munich, Germany - - Scientific Employee, TUM - --**--** - On Fri, Aug 30, 2013 at 3:48 PM, jim holtmanjholt...@gmail.com wrote: You can also look at the XLConnect package. 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, Aug 29, 2013 at 9:40 AM, Zsurzsa Laszlozsurzsalas...@gmail.com* * wrote: I understand you response but it does not solve the problem. I'am aware that one can simply color every cell in an excel file by using his own algorithm. The question was if I can write my data to a *single* cells and use different formatting for every piece of data. --**--** - - László-András Zsurzsa, - - Msc. Infromatics, Technical University Munich, Germany - - Scientific Employee, TUM - --**--** - On Thu, Aug 29, 2013 at 3:36 PM, Rainer Hurlingrhur...@gwdg.de wrote: Am 29.08.2013 15:03 (UTC+1) schrieb Zsurzsa Laszlo: First of all thank you for the quick resposen. I know I can color and set up every cell. I will take a look again * CellStyle* but is it possbile for example to write an array to a single cell that has different colors for some data. Basically the color depends on the data. As far as I know there is no ready to use functionality to mask groups of selected cells. You have to write your own function, which selects the right cells and changes their style with setCellStyle(cell, cellStyle). Some hints are given in the examples section of ?CellStyle. --**--** - - László-András Zsurzsa, - - Msc. Infromatics, Technical University Munich, Germany - - Scientific Employee, TUM - --**--** - On Thu, Aug 29, 2013 at 2:55 PM, Rainer Hurlingrhur...@gwdg.de wrote: Am 29.08.2013 12:08 (UTC+1) schrieb Zsurzsa Laszlo: Dear R users, I have a question about the xlsx package. It's possible to create excel files and color cells and etc. yes, with package xlsx you can colourize you data sheets, even the fonts. See for example ?CellStyle . A good demonstration of the capabilities is on
Re: [R] Multiple regression (with interactions) by hand
On Tue, Sep 3, 2013 at 2:51 AM, Christoph Scherber christoph.scher...@agr.uni-goettingen.de wrote: Dear all, I´ve played around with the airquality dataset, trying to solve the matrix equations of a simple multiple regression by hand; however, my matrix multiplications don´t lead to the estimates returned by coef(). What have I done wrong here? ## m1=lm(Ozone~Solar.R*Wind,airquality) # remove NA´s: airquality2=airquality[complete.cases(airquality$Ozone) complete.cases(airquality$Solar.R) complete.cases(airquality$Wind),] # create the model matrix by hand: X=cbind((Intercept)=1,Solar.R=airquality2$Solar.R,Wind=airquality2$Wind,Solar.R:Wind=airquality2$Solar.R*airquality2$Wind) # is the same as: model.matrix(m1) # create the response vector by hand: Y=airquality2$Ozone # is the same as: m1$model$Ozone # Now solve for the parameter estimates: library(MASS) ginv(t(X)%*%X)%*%t(X)%*%Y # is not the same as: coef(m1) ## Now why is my result (line ginv(...)) not the same as the one returned by coef(m1)? Have a look at the help of ginv. It mentions the tol argument. If you do ginv(crossprod(X),tol=1e-12) %*% crossprod(X,Y) you'll see that all is well. It's up to you to play with tol. Berend __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] would you give me hints in r?
Dear R User, Would you give me some hints on why I could not predict using data. format' data. Here is the example: ex-structure(list(env1 = c(182, 163.33, 443.02, 1240.16), env2 = c(1134, 550, 2111, 2523), env3 = c(24.53, 24.93, 24.71, 21.05), env4 = c(0.05, 0, 0, 0)), .Names = c(env1, env2, env3, env4), row.names = c(NA, -4L), class = data.frame) mod-bioclim(ex) pred-predict(ex,mod) Error in UseMethod(predict) : no applicable method for 'predict' applied to an object of class data.frame Thanks for your help KG [[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] Should I wrap more package examples in \dontrun{} ?
To give a specific example, the simple code for my test suite is given at the bottom of this message. A simpler (simple-minded maybe) approach than creating a new packge for testing. I now run this on the survival package every time that I submit a new version to CRAN. It takes a while, since there are over 200 dependencies. It creates a file progress containing each package name as it is run folllowed by either Ok or Failed along with a directory tests containing the results. Almost every run generates 1-3 hits. I have not automated this further because many runs also lead to exceptions, often packages that won't load because I don't have some ancillary piece of software installed that they depend on. (I can't seem to get JAVA set up sufficient to satisfy everyone, for example, and have very low motivation to work harder at the task.) And a small number have made it to the bad actors I give up don't even bother to test list. Note that any package I want to fully test was installed on this local machine using install.packages(xxx, dependencies=TRUE, INSTALL_opts=--install-tests) where xxx is the name of the package. Terry T. On 09/04/2013 05:00 AM, r-help-requ...@r-project.org wrote: n 03/09/2013 1:53 PM, Hadley Wickham wrote: As a user of your package, I would find it irritating if example(foo) didn't run anything. It would be more irritating (and would indicate sloppiness on your part) if the examples failed when I cut and pasted them. These both suggest leaving the examples running. As the author of your package, it sounds as though you find it quite irritating when other authors break your code. Isn't the right solution to this to work with the other package authors to come up with code that is unlikely to break? If that's not possible, then maybe don't use those packages that cause you trouble. It was my understanding that package authors are responsible for not breaking other CRAN packages without warning. For example, before I release a new version of plyr or ggplot2, I run R CMD check on every package that depends on my package. I then let the maintainers know if something is broken - sometimes it's because I introduced a bug, and other times it's because I'm enforcing a stricter check than I did previously It sounds as though you're doing the right thing. Can you describe how you determine the set of packages to check, and how you do your checks? It would be great if we could convince everyone to follow those steps. Duncan Murdoch tmt% cat checkdeps.R require(tools) # First set a repository to look at #chooseCRANmirror() # do it graphically #chooseBioCmirror() options(repos=c(CRAN=http://streaming.stat.iastate.edu/CRAN/;, BioC=http://bioconductor.org/packages/2.11/bioc/;)) # This function is provided by Uwe Wigges reverse - function(packages, which = c(Depends, Imports, LinkingTo), recursive = FALSE) { description - sprintf(%s/web/packages/packages.rds, getOption(repos)[CRAN]) con - if(substring(description, 1L, 7L) == file://) file(description, rb) else url(description, rb) on.exit(close(con)) db - readRDS(gzcon(con)) rownames(db) - NULL rdepends - package_dependencies(packages, db, which, recursive = recursive, reverse = TRUE) rdepends - sort(unique(unlist(rdepends))) pos - match(rdepends, db[, Package], nomatch = 0L) db[pos, c(Package, Version, Maintainer)] } survdep - reverse(survival)[,1] # I don't want to check coxme (since I maintain a more up to date # local copy), and there are a few known bad actors avoid - c(coxme, STAR, compareGroups) survdep - survdep[is.na(match(survdep, avoid))] # Some packages may have failed to install, don't test those inplace - installed.packages()[,Package] #ones we already have missed - is.na(match(survdep, inplace)) if (any(missed)) { message(Unable to load packages , paste(survdep[missed], collapse=, ), \n) survdep - survdep[!missed] } # Do the long list of tests unlink(progress) unlink(tests, recursive=TRUE) system(mkdir tests) pfile - file(progress, open=write) for (testpkg in survdep) { z - testInstalledPackage(testpkg, outDir=tests) cat(testpkg, c(Ok, Failed)[z+1], \n, file=pfile) } __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] tm::stemDocument function not work
Hello, I noticed the commented line and I get no error when I run this specific line. Regards, Pascal 2013/9/4 Ricardo Pietrobon pietr...@gmail.com thanks Pascal. actually, right after I sent the post I realized that I didn't send my sessionInfo (at the bottom of this message now). Just to make sure, everything in my script works except for the line with stemDocument, which was commented in my gist. Below is the specific warning I am getting: corpus - tm_map(corpus, stemDocument, language = english) Warning message: In parallel::mclapply(x, FUN, ...) : all scheduled cores encountered errors in user code sessionInfo() R version 3.0.1 (2013-05-16) Platform: x86_64-apple-darwin10.8.0 (64-bit) locale: [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8 attached base packages: [1] stats graphics grDevices utils datasets methods base On Wed, Sep 4, 2013 at 12:54 AM, Pascal Oettli kri...@ymail.com wrote: Hello, Your example worked for me. R sessionInfo() R version 3.0.1 Patched (2013-09-02 r63805) Platform: x86_64-unknown-linux-gnu (64-bit) locale: [1] LC_CTYPE=en_GB.UTF-8 LC_NUMERIC=C [3] LC_TIME=en_GB.UTF-8LC_COLLATE=en_GB.UTF-8 [5] LC_MONETARY=en_GB.UTF-8LC_MESSAGES=en_GB.UTF-8 [7] LC_PAPER=C LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=en_GB.UTF-8 LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] scatterplot3d_0.3-33 lsa_0.63-3 RWeka_0.4-19 [4] Snowball_0.0-10 ggplot2_0.9.3.1 tm_0.5-9.1 loaded via a namespace (and not attached): [1] colorspace_1.2-2 dichromat_2.0-0digest_0.6.3 grid_3.0.1 [5] gtable_0.1.2 labeling_0.2 MASS_7.3-29 munsell_0.4.2 [9] parallel_3.0.1 plyr_1.8 proto_0.3-10 RColorBrewer_1.0-5 [13] reshape2_1.2.2 rJava_0.9-4RWekajars_3.7.10-1 scales_0.2.3 [17] slam_0.1-28stringr_0.6.2 Regards, Pascal 2013/9/4 Ricardo Pietrobon pietr...@gmail.com https://gist.github.com/rpietro/6430771 stemDocument function doesn't seem to be working. Tried to look up and a few people have reported the problem, but no solution that I could find. would appreciate any help __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] tm::stemDocument function not work
thanks Pascal. actually, right after I sent the post I realized that I didn't send my sessionInfo (at the bottom of this message now). Just to make sure, everything in my script works except for the line with stemDocument, which was commented in my gist. Below is the specific warning I am getting: corpus - tm_map(corpus, stemDocument, language = english) Warning message: In parallel::mclapply(x, FUN, ...) : all scheduled cores encountered errors in user code sessionInfo() R version 3.0.1 (2013-05-16) Platform: x86_64-apple-darwin10.8.0 (64-bit) locale: [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8 attached base packages: [1] stats graphics grDevices utils datasets methods base On Wed, Sep 4, 2013 at 12:54 AM, Pascal Oettli kri...@ymail.com wrote: Hello, Your example worked for me. R sessionInfo() R version 3.0.1 Patched (2013-09-02 r63805) Platform: x86_64-unknown-linux-gnu (64-bit) locale: [1] LC_CTYPE=en_GB.UTF-8 LC_NUMERIC=C [3] LC_TIME=en_GB.UTF-8LC_COLLATE=en_GB.UTF-8 [5] LC_MONETARY=en_GB.UTF-8LC_MESSAGES=en_GB.UTF-8 [7] LC_PAPER=C LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=en_GB.UTF-8 LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] scatterplot3d_0.3-33 lsa_0.63-3 RWeka_0.4-19 [4] Snowball_0.0-10 ggplot2_0.9.3.1 tm_0.5-9.1 loaded via a namespace (and not attached): [1] colorspace_1.2-2 dichromat_2.0-0digest_0.6.3 grid_3.0.1 [5] gtable_0.1.2 labeling_0.2 MASS_7.3-29munsell_0.4.2 [9] parallel_3.0.1 plyr_1.8 proto_0.3-10 RColorBrewer_1.0-5 [13] reshape2_1.2.2 rJava_0.9-4RWekajars_3.7.10-1 scales_0.2.3 [17] slam_0.1-28stringr_0.6.2 Regards, Pascal 2013/9/4 Ricardo Pietrobon pietr...@gmail.com https://gist.github.com/rpietro/6430771 stemDocument function doesn't seem to be working. Tried to look up and a few people have reported the problem, but no solution that I could find. would appreciate any help __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Random products of rows in a matrix
Hello everybody, Without any loop and any package, I would like to return N products of M rows in a matrix A : Today, I managed to do it with a loop : B - matrix(NA, ncol = ncol(A), nrow = 0) for (i in 1 : N) B - rbind(B, apply(A[sample(1 : nrow(A), M, replace = T), ], 2, prod)) Do you have a solution ? Thank you in advance ! [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] panel multinomial logit
Hi there, I am trying to apply multinomial Logit for a panel data set. I have 5016 observations for 22 countries (id). Each country has 228 observations over time domain. Following table shows the part of my dataset including 10 variables. id t X1X2X3X4X5 X6 X7 X8 X9 X10 500 3 44 NA NA NA NANA 150.9211 NA NA NA 0.005684 501 3 45 NA NA NA NANA 153.6307 0.409641 NA NA 0.006196 502 3 46 NA NA NA NANA 156.1034 0.43 NA NA 0.00 503 3 47 NA NA NA NANA 157.7336 0.541157 NA NA 0.007110 504 3 48 NA NA NA NANA 163.7610 0.717920 NA NA 0.007533 505 3 49 NA NA NA NANA 151.5358 0.727861 NA NA 0.007580 506 3 50 NA NA NA NANA 151.9387 0.842376 NA NA 0.008198 I have generated a dependent variable with 3 states which are 0, 1, 2. id ty 500 3 44 1 501 3 45 2 502 3 46 0 503 3 47 0 504 3 48 0 505 3 49 0 506 3 50 1 In order to reshape data from wide to long format I used the command below; mdat - mlogit.data (dat, id=id, choice=y, shape = long, alt.levels = c(0, 1,2)) mdat[500:510,] id tX1 X2X3 X4X5 X6 X7 X8 X9 167.1 3 44 NA NA NA NANA 150.9211 NA NA NA 167.2 3 45 NA NA NA NANA 153.6307 0.409641 NA NA 168.0 3 46 NA NA NA NANA 156.1034 0.43 NA NA 168.1 3 47 NA NA NA NANA 157.7336 0.541157 NA NA 168.2 3 48 NA NA NA NANA 163.7610 0.717920 NA NA 169.0 3 49 NA NA NA NANA 151.5358 0.727861 NA NA 169.1 3 50 NA NA NA NANA 151.9387 0.842376 NA NA X10 y 167.1 0.005684 TRUE 167.2 0.006196 TRUE 168.0 0.00 FALSE 168.1 0.007110 FALSE 168.2 0.007533 FALSE 169.0 0.007580 FALSE 169.1 0.008198 TRUE This code has not given /chid/ or /alt/ columns in the result. These two columns usually appear when you run the command for reshape the data format. The problem in here is when I check y it shows True and False. I think it ignores the other state that I defined for y it just shows 2 states! I am confused. I don’t know whether the code which I have used for reshaping is correct? The main struggle is when I run the mlogit command. I have tried two commands: First; mlogit.model - mlogit(y~ X1 + X2 +X3 + X4 + X5 + X6 + X7 + X8 + X9 + X10, data = mdat, reflevel = 0) I got following error; Error in if (abs(x - oldx) ftol) { : missing value where TRUE/FALSE needed Second; mlogit.model - mlogit(y~ X1 + X2 +X3 + X4 + X5 + X6 + X7 + X8 + X9 + X10, data = mdat, reflevel = 0, R=50, halton=NA, print.level=0, panel=TRUE) Error in mlogit(y ~ X1 + X2 +X3 + X4 + X5 + X6 + X7 + X8 + X9 + X10 + : panel is only relevant for mixed logit models. Now, I would like to know if the mlogit.dat is correct or not? Secondly, how could I make correct the mlogit command. Any help would be appreciated in advance. Best, Rose -- View this message in context: http://r.789695.n4.nabble.com/panel-multinomial-logit-tp4675348.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] Placeholders for String Operations
Hi all, what are the placeholders for string operations/modifications? Is there a placeholder for numbers, which would allow me to easily replace all numbers in a string? Something like text1 - c(this is a number 23%) text2 - c(this is not a number bla%) newtext1 - gsub(#%, [percentagevalue], text) newtext2 - gsub(#%, [percentagevalue], text) newtext1 should be this is a number [percentagevalue] newtext2 should be this is not a number 23% I figured there is * ? . but I can't find a source that explains their use and lists other placeholders.. Appreciate your help! Thanks Simon __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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
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! __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] glmnet lambda and number of variables
Greetings, I have recently been exploring the 'glmnet' package and subsequently cv.glmnet. The basic code as follows: model - cv.glmnet(variables, group, family=multinomial, alpha=.5, standardize=F) I understand that cv.glmnet does k-fold cross-validation to return a value of lambda. However, sometimes when I follow up the cv.glmnet to extract the coefficients either very few or all are zero. If I understand this correctly, it means that there aren't very many (if any) variables to separate the groups. Despite this, I would like to provide a list of variables and rank them in terms of importance (even if not discriminatory as this is for some simulation purposes and not working on a particular question/experiment). Is there a way for my to set up the analysis to provide a user determined number of variables? Or perhaps another way, is it possible to determine the order with which variables are dropped from the model? Best regards, -- Charles Determan Integrated Biosciences PhD Candidate University of Minnesota [[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] 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.
Re: [R] Placeholders for String Operations
Hi, gsub(#%, [percentagevalue], text1) #[1] this is a number 23% gsub(\\d+%$, [percentagevalue], text1) #[1] this is a number [percentagevalue] gsub(bla, 23, text2) #[1] this is not a number 23% A.K. - Original Message - From: Simon Pickert simon.pick...@t-online.de To: r-help@r-project.org Cc: Sent: Wednesday, September 4, 2013 11:17 AM Subject: [R] Placeholders for String Operations Hi all, what are the placeholders for string operations/modifications? Is there a placeholder for numbers, which would allow me to easily replace all numbers in a string? Something like text1 - c(this is a number 23%) text2 - c(this is not a number bla%) newtext1 - gsub(#%, [percentagevalue], text) newtext2 - gsub(#%, [percentagevalue], text) newtext1 should be this is a number [percentagevalue] newtext2 should be this is not a number 23% I figured there is * ? . but I can't find a source that explains their use and lists other placeholders.. Appreciate your help! Thanks Simon __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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
This is not efficient. For whom? (a) L-BFGS-B does not identify itself even though it was called overriding the method parameter in optim. Would you prefer that the warning o - optim(par=c(1,2), fn=function(x)-sum(abs(sin(x))), method=CG, lower=c(-1,-1), upper= c(2,3)) Warning message: In optim(par = c(1, 2), fn = function(x) -sum(abs(sin(x))), method = CG, : bounds can only be used with method L-BFGS-B (or Brent) explicitly say that method L-BFGS-B was used because bounds were given? (b) Optim reports as final converged minimum value a function value that is much larger than others computed during the optimization. That is where a self-contained example would make it much quicker to identify and perhaps fix the problem. Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Michael Meyer Sent: Wednesday, September 04, 2013 1:35 AM To: r-help@r-project.org Subject: [R] optim evils It would take some effort to extract selfcontained code from the mass of code wherein this optimization is embedded. Moreover I would have to obtain permission from my employer to do so. This is not efficient. However some things are evident from the trace log which I have submitted: (a) L-BFGS-B does not identify itself even though it was called overriding the method parameter in optim. (b) Optim reports as final converged minimum value a function value that is much larger than others computed during the optimization. I think we can agree on calling this a bug. [[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] Placeholders for String Operations
Hello, I'm not sure I understand, but if you want a ?regexp to only match numbers before a %, try the following. gsub([0-9]+%, [percentagevalue], text1) gsub([0-9]+%, [percentagevalue], text2) [0-9] matches any character in the range from 0 to 9, and the + means to repeat that character any number of times. See the help page for ?regexp. Hope this helps, Rui Barradas Em 04-09-2013 16:17, Simon Pickert escreveu: Hi all, what are the placeholders for string operations/modifications? Is there a placeholder for numbers, which would allow me to easily replace all numbers in a string? Something like text1 - c(this is a number 23%) text2 - c(this is not a number bla%) newtext1 - gsub(#%, [percentagevalue], text) newtext2 - gsub(#%, [percentagevalue], text) newtext1 should be this is a number [percentagevalue] newtext2 should be this is not a number 23% I figured there is * ? . but I can't find a source that explains their use and lists other placeholders.. Appreciate your help! Thanks Simon __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Permuting friendship nominations in a social network
Holly, I don't know of a clever way to do this, but I can think of a brute force way, which might only be feasible if you have a small data set (as in your example). You could permute every possible set of connections, then choose from that collection only the ones that meet your criteria. Using your example, there are c=21 possible connections among the n=7 unique individuals, c = n*(n-1)/2. Your example shows a total of 8 connections (16 rows / 2). So you could generate all permutations of choose(21, 8) = 203,490 ways to have 8 connections. Then subset the ones that have individual totals the same as your example (1 connection for Alicia and Beth, 2 for Kerry and Kim, 3 for James and John, and 4 for Rachel). Jean On Tue, Sep 3, 2013 at 1:01 PM, hollymaya hollym...@gmail.com wrote: I have a dataset of dyads (an edgelist) representing friendship nominations between egos and their nominated alters. The network is undirected so if ego is connected to alter, then there is a separate observation in the dataset for the reverse. I would like to randomly permute the friendships so that 1.) the total degree for each individual remains the same, i.e. each individual ends up with the same number of friendships they had in the original undirected dataset and 2.) there are no self loops, so individuals are not connected to themselves. Any suggestions on this would be greatly appreciated. Example Observed data: Ego Alter Alicia James BethKim James John James Rachel James Alicia JohnKerry JohnRachel JohnJames Kerry Rachel Kerry John Kim Rachel Kim Beth RachelKim RachelJames RachelKerry RachelJohn Permuted data: Ego Alter Alicia Rachel Beth James James Beth James John James Kim John Rachel John Kerry John James Kerry Rachel Kerry John Kim Rachel Kim James Rachel Kim Rachel John Rachel Alicia Rachel Kerry Thank you in advance, Holly hollym...@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. [[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] mean
-Original Message- When I try to apply mean to a list, I get the answer : argument is not numeric or logical: returning NA Example: l4 - list(1:4) class(l4) #not numeric or logical ... mean(l4) #same error #a list is not a number, a logical (TRUE/FALSE) or a vector or array of either of those. So mean() can't handle it unaided and tells you what it needs. #But if your list is a list of numeric objects, unlist will often work. unlist(l4) #a numeric vector mean( unlist(l4) ) #no problem l.some - list(matrix(1:4, ncol=2), 3:7) l.some unlist(l.some) #a numeric vector mean( unlist(l.some) ) #works #But a) magic has limits and b) if you want averages, maybe you should not be using a list? A vector would save hassle if it fits ... S Ellison *** This email and any attachments are confidential. Any use...{{dropped:8}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] would you give me hints in r?
Thanks Sarah and Rui, It worked now. I don't know why it was not working before. I again restarted R and then it worked. I really appreciated your help. Cheers, KG Date: Wed, 4 Sep 2013 10:20:39 -0400 Subject: Re: [R] would you give me hints in r? From: sarah.gos...@gmail.com To: kristi.glo...@hotmail.com CC: r-help@r-project.org Rui's suggestion and your reproducible example work for me. Can you give us more information about what you did, including the output of sessionInfo() ? library(dismo) ex-structure(list(env1 = c(182, 163.33, 443.02, 1240.16), env2 = c(1134, 550, 2111, 2523), env3 = c(24.53, 24.93, 24.71, 21.05), env4 = c(0.05, 0, 0, 0)), .Names = c(env1, env2, env3, env4), row.names = c(NA, -4L), class = data.frame) mod-bioclim(ex) pred-predict(mod, ex) On Wed, Sep 4, 2013 at 10:02 AM, Kristi Glover kristi.glo...@hotmail.com wrote: Hi Rui, Thanks for the message. i used dismo package. I changed the argument as you suggested, still did not work. Error in UseMethod(predict) : no applicable method for 'predict' applied to an object of class data.frame Thanks KG Date: Wed, 4 Sep 2013 14:57:45 +0100 From: ruipbarra...@sapo.pt To: kristi.glo...@hotmail.com CC: r-help@r-project.org Subject: Re: [R] would you give me hints in r? Hello, Where does the function bioclim come from? What package? If it's from package dismo, then you should try predict() with the arguments reversed: pred - predict(mod, ex) Hope this helps, Rui Barradas Em 04-09-2013 13:48, Kristi Glover escreveu: Dear R User, Would you give me some hints on why I could not predict using data. format' data. Here is the example: ex-structure(list(env1 = c(182, 163.33, 443.02, 1240.16), env2 = c(1134, 550, 2111, 2523), env3 = c(24.53, 24.93, 24.71, 21.05), env4 = c(0.05, 0, 0, 0)), .Names = c(env1, env2, env3, env4), row.names = c(NA, -4L), class = data.frame) mod-bioclim(ex) pred-predict(ex,mod) Error in UseMethod(predict) : no applicable method for 'predict' applied to an object of class data.frame Thanks for your help KG Sarah Goslee http://www.functionaldiversity.org [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] would you give me hints in r?
Hi Rui, Thanks for the message. i used dismo package. I changed the argument as you suggested, still did not work. Error in UseMethod(predict) : no applicable method for 'predict' applied to an object of class data.frame Thanks KG Date: Wed, 4 Sep 2013 14:57:45 +0100 From: ruipbarra...@sapo.pt To: kristi.glo...@hotmail.com CC: r-help@r-project.org Subject: Re: [R] would you give me hints in r? Hello, Where does the function bioclim come from? What package? If it's from package dismo, then you should try predict() with the arguments reversed: pred - predict(mod, ex) Hope this helps, Rui Barradas Em 04-09-2013 13:48, Kristi Glover escreveu: Dear R User, Would you give me some hints on why I could not predict using data. format' data. Here is the example: ex-structure(list(env1 = c(182, 163.33, 443.02, 1240.16), env2 = c(1134, 550, 2111, 2523), env3 = c(24.53, 24.93, 24.71, 21.05), env4 = c(0.05, 0, 0, 0)), .Names = c(env1, env2, env3, env4), row.names = c(NA, -4L), class = data.frame) mod-bioclim(ex) pred-predict(ex,mod) Error in UseMethod(predict) : no applicable method for 'predict' applied to an object of class data.frame Thanks for your help KG [[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] would you give me hints in r?
Hello, Where does the function bioclim come from? What package? If it's from package dismo, then you should try predict() with the arguments reversed: pred - predict(mod, ex) Hope this helps, Rui Barradas Em 04-09-2013 13:48, Kristi Glover escreveu: Dear R User, Would you give me some hints on why I could not predict using data. format' data. Here is the example: ex-structure(list(env1 = c(182, 163.33, 443.02, 1240.16), env2 = c(1134, 550, 2111, 2523), env3 = c(24.53, 24.93, 24.71, 21.05), env4 = c(0.05, 0, 0, 0)), .Names = c(env1, env2, env3, env4), row.names = c(NA, -4L), class = data.frame) mod-bioclim(ex) pred-predict(ex,mod) Error in UseMethod(predict) : no applicable method for 'predict' applied to an object of class data.frame Thanks for your help KG [[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] Random products of rows in a matrix
Actually you have two loops, the for() loop you created and the loop that is hidden inside apply(). You can hide the first loop with lapply() or sapply(): B - do.call(rbind, lapply(1:N, function(x) colSums(A[sample.int(nrow(A), M, replace=TRUE),]))) Or B - t(sapply(1:N, function(x) colSums(A[sample.int(nrow(A), M, replace=TRUE),]))) You could eliminate the apply() loop by taking log(A), using colSums(), and then converting back with exp(). - David L Carlson Associate Professor of Anthropology Texas AM University College Station, TX 77840-4352 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Edouard Hardy Sent: Wednesday, September 4, 2013 2:59 AM To: R help Subject: [R] Random products of rows in a matrix Hello everybody, Without any loop and any package, I would like to return N products of M rows in a matrix A : Today, I managed to do it with a loop : B - matrix(NA, ncol = ncol(A), nrow = 0) for (i in 1 : N) B - rbind(B, apply(A[sample(1 : nrow(A), M, replace = T), ], 2, prod)) Do you have a solution ? Thank you in advance ! [[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] would you give me hints in r?
Rui's suggestion and your reproducible example work for me. Can you give us more information about what you did, including the output of sessionInfo() ? library(dismo) ex-structure(list(env1 = c(182, 163.33, 443.02, 1240.16), env2 = c(1134, 550, 2111, 2523), env3 = c(24.53, 24.93, 24.71, 21.05), env4 = c(0.05, 0, 0, 0)), .Names = c(env1, env2, env3, env4), row.names = c(NA, -4L), class = data.frame) mod-bioclim(ex) pred-predict(mod, ex) On Wed, Sep 4, 2013 at 10:02 AM, Kristi Glover kristi.glo...@hotmail.com wrote: Hi Rui, Thanks for the message. i used dismo package. I changed the argument as you suggested, still did not work. Error in UseMethod(predict) : no applicable method for 'predict' applied to an object of class data.frame Thanks KG Date: Wed, 4 Sep 2013 14:57:45 +0100 From: ruipbarra...@sapo.pt To: kristi.glo...@hotmail.com CC: r-help@r-project.org Subject: Re: [R] would you give me hints in r? Hello, Where does the function bioclim come from? What package? If it's from package dismo, then you should try predict() with the arguments reversed: pred - predict(mod, ex) Hope this helps, Rui Barradas Em 04-09-2013 13:48, Kristi Glover escreveu: Dear R User, Would you give me some hints on why I could not predict using data. format' data. Here is the example: ex-structure(list(env1 = c(182, 163.33, 443.02, 1240.16), env2 = c(1134, 550, 2111, 2523), env3 = c(24.53, 24.93, 24.71, 21.05), env4 = c(0.05, 0, 0, 0)), .Names = c(env1, env2, env3, env4), row.names = c(NA, -4L), class = data.frame) mod-bioclim(ex) pred-predict(ex,mod) Error in UseMethod(predict) : no applicable method for 'predict' applied to an object of class data.frame Thanks for your help KG Sarah Goslee http://www.functionaldiversity.org __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] remove rows with infinite/nan values from a zoo dataset
Hi, This is confusing because the error message suggests that you were not able to read the csv file. Then how did you removed the Inf values?. I guess this should be a different dataset. From your previous email: prices=read.zoo(C:\\Users\\Desktopawc_au.csv,header=TRUE,sep=,,format=%Y-%m-%d ) Try: read.zoo(, fill=TRUE) From my first reply: dat1- read.zoo(text=2009-07-15,#N/A N/A,#N/A N/A,18.96858 2009-07-16,20.30685,20.40664,#N/A N/A 2009-07-17,20.78813,20.03991,20.40664 2009-07-20,21.41278,21.41278,20.03991 2009-07-21,22.9963,22.98397,21.41278 2009-07-22,23.06443,23.01112,22.98397 2009-07-23,23.45905,24.72232,23.01112 2009-07-24,24.89291,25.56603,24.72232 2009-07-27,25.38929,24.80535,25.56603 2009-07-28,25.26712,25.65566,24.80535 2009-07-29,25.83884,24.98163,25.65566 2009-07-30,#N/A N/A,#N/A N/A,24.98163 2009-08-03,25.25553,25.93297,#N/A N/A 2009-08-04,26.02464,25.49159,25.93297 ,sep=,,header=FALSE,FUN=as.Date,format=%Y-%m-%d) #Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings, : # line 1 did not have 4 elements dat1- read.zoo(text=2009-07-15,#N/A N/A,#N/A N/A,18.96858 2009-07-16,20.30685,20.40664,#N/A N/A 2009-07-17,20.78813,20.03991,20.40664 2009-07-20,21.41278,21.41278,20.03991 2009-07-21,22.9963,22.98397,21.41278 2009-07-22,23.06443,23.01112,22.98397 2009-07-23,23.45905,24.72232,23.01112 2009-07-24,24.89291,25.56603,24.72232 2009-07-27,25.38929,24.80535,25.56603 2009-07-28,25.26712,25.65566,24.80535 2009-07-29,25.83884,24.98163,25.65566 2009-07-30,#N/A N/A,#N/A N/A,24.98163 2009-08-03,25.25553,25.93297,#N/A N/A 2009-08-04,26.02464,25.49159,25.93297 ,sep=,,header=FALSE,FUN=as.Date,format=%Y-%m-%d,fill=TRUE)##works. A.K. Thank you A.K. The infinite values are removed but how about the NA values in a csv file? I got error message like Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings, : line 1356 did not have 4 elements How could I ignore the rows with NA value when read a csv file? Thank you. R.L - Original Message - From: arun smartpink...@yahoo.com To: R help r-help@r-project.org Cc: Sent: Tuesday, September 3, 2013 11:49 AM Subject: Re: remove rows with infinite/nan values from a zoo dataset Hi, No problem. In my previous post, I showed how to dput() your example dataset. Please use dput() in the future. vec1- c(3.369247e-04,0.00e+00,9.022183e-04,0.00e+00,-1.105819e-04,-Inf,1.191271e-04,1.681718e-04,NaN,1.150126e-04,1.031037e-03,2.710993e-04) indx-seq(as.Date(2009-09-01),as.Date(2009-09-17),by=1) indx1-indx[-c(5:7,12:13)] library(zoo) z1- zoo(vec1,order.by=indx1) sum(z1,na.rm=TRUE) #without removing the Inf. #[1] -Inf sum(z1[is.finite(z1)],na.rm=TRUE) #[1] 0.002833009 #or just sum(z1[is.finite(z1)]) #[1] 0.002833009 A.K. Thank you for your reply A.K. Sorry for my misleading -- the first question should be removing #N/A N/A values when reading a csv file. So the example provided in the original post was dragged from a csv spreadsheet directly. (which I used the code prices=read.zoo(C:\\Users\\Desktopawc_au.csv,header=TRUE,sep=,,format=%Y-%m-%d ) Then the following up question is removing from a zoo data set. After some calculation, the new zoo data set is as following: 2009-09-01 2009-09-02 2009-09-03 2009-09-04 2009-09-08 2009-09-09 3.369247e-04 0.00e+00 9.022183e-04 0.00e+00 -1.105819e-04 -Inf 2009-09-10 2009-09-11 2009-09-14 2009-09-15 2009-09-16 2009-09-17 1.191271e-04 1.681718e-04 NaN 1.150126e-04 1.031037e-03 2.710993e-04 I need to sum them up so I used sum(Z, na.rm=TRUE) to remove the NaN values but not for the Inf/-Inf. Hope it is clear to you. Cheers, R.L - Original Message - From: arun smartpink...@yahoo.com To: R help r-help@r-project.org Cc: Sent: Tuesday, September 3, 2013 2:47 AM Subject: Re: remove rows with infinite/nan values from a zoo dataset Hi, Please dput() the example dataset. When I read from the one shown below, it looks a bit altered. library(zoo) dat1- read.zoo(text=2009-07-15,#N/A N/A,#N/A N/A,18.96858 2009-07-16,20.30685,20.40664,#N/A N/A 2009-07-17,20.78813,20.03991,20.40664 2009-07-20,21.41278,21.41278,20.03991 2009-07-21,22.9963,22.98397,21.41278 2009-07-22,23.06443,23.01112,22.98397 2009-07-23,23.45905,24.72232,23.01112 2009-07-24,24.89291,25.56603,24.72232 2009-07-27,25.38929,24.80535,25.56603 2009-07-28,25.26712,25.65566,24.80535 2009-07-29,25.83884,24.98163,25.65566 2009-07-30,#N/A N/A,#N/A N/A,24.98163 2009-08-03,25.25553,25.93297,#N/A N/A 2009-08-04,26.02464,25.49159,25.93297 ,sep=,,header=FALSE,FUN=as.Date,format=%Y-%m-%d,fill=TRUE) dput(dat1) ### structure(c(NA, 20.30685, 20.78813, 21.41278, 22.9963, 23.06443, 23.45905, 24.89291, 25.38929, 25.26712, 25.83884, NA, 25.25553, 26.02464, NA, 20.40664, 20.03991, 21.41278, 22.98397, 23.01112, 24.72232, 25.56603, 24.80535,
Re: [R] Memory usage bar plot
HI, May be this helps. input- readLines(textConnection( Private + Shared = RAM used Program 84.0 KiB + 14.5 KiB = 98.5 KiB sleep 108.0 KiB + 11.5 KiB = 119.5 KiB klogd 124.0 KiB + 15.0 KiB = 139.0 KiB hidd 128.0 KiB + 12.5 KiB = 140.5 KiB gpm 116.0 KiB + 28.5 KiB = 144.5 KiB hald-addon-storage 120.0 KiB + 28.0 KiB = 148.0 KiB acpid 128.0 KiB + 25.0 KiB = 153.0 KiB dbus-launch 128.0 KiB + 31.5 KiB = 159.5 KiB hald-addon-acpi 144.0 KiB + 19.0 KiB = 163.0 KiB sdpd 152.0 KiB + 16.5 KiB = 168.5 KiB irqbalance 140.0 KiB + 28.5 KiB = 168.5 KiB pam_timestamp_check 152.0 KiB + 20.0 KiB = 172.0 KiB init 148.0 KiB + 26.0 KiB = 174.0 KiB mapping-daemon 152.0 KiB + 25.5 KiB = 177.5 KiB gnome-keyring-daemon 152.0 KiB + 26.5 KiB = 178.5 KiB portmap 164.0 KiB + 16.0 KiB = 180.0 KiB syslogd 168.0 KiB + 24.5 KiB = 192.5 KiB atd 180.0 KiB + 18.5 KiB = 198.5 KiB brcm_iscsiuio 188.0 KiB + 37.0 KiB = 225.0 KiB rpc.statd 208.0 KiB + 26.0 KiB = 234.0 KiB audispd 208.0 KiB + 39.5 KiB = 247.5 KiB hald-runner 244.0 KiB + 23.5 KiB = 267.5 KiB smartd 240.0 KiB + 35.5 KiB = 275.5 KiB hpiod 244.0 KiB + 35.0 KiB = 279.0 KiB hcid 228.0 KiB + 73.0 KiB = 301.0 KiB hald-addon-keyboard (2) 328.0 KiB + 32.5 KiB = 360.5 KiB gam_server 336.0 KiB + 31.5 KiB = 367.5 KiB xinetd 364.0 KiB + 28.5 KiB = 392.5 KiB auditd 420.0 KiB + 78.0 KiB = 498.0 KiB mingetty (6) 552.0 KiB + 19.5 KiB = 571.5 KiB udevd 532.0 KiB + 56.0 KiB = 588.0 KiB rpc.idmapd 544.0 KiB + 51.5 KiB = 595.5 KiB ssh-agent 372.0 KiB + 225.0 KiB = 597.0 KiB sh (2) 612.0 KiB + 28.0 KiB = 640.0 KiB crond 484.0 KiB + 175.0 KiB = 659.0 KiB avahi-daemon (2) 744.0 KiB + 74.5 KiB = 818.5 KiB automount 756.0 KiB + 186.5 KiB = 942.5 KiB gnome-vfs-daemon 736.0 KiB + 295.0 KiB = 1.0 MiB dbus-daemon (2) 988.0 KiB + 61.5 KiB = 1.0 MiB pcscd 824.0 KiB + 231.5 KiB = 1.0 MiB pam-panel-icon 1.0 MiB + 26.0 KiB = 1.1 MiB nmon 864.0 KiB + 229.5 KiB = 1.1 MiB bt-applet 712.0 KiB + 402.0 KiB = 1.1 MiB nm-system-settings 1.0 MiB + 63.0 KiB = 1.1 MiB nmbd 996.0 KiB + 131.0 KiB = 1.1 MiB bonobo-activation-server 740.0 KiB + 398.5 KiB = 1.1 MiB escd 868.0 KiB + 375.0 KiB = 1.2 MiB bash (2) 1.1 MiB + 212.5 KiB = 1.3 MiB gnome-screensaver 796.0 KiB + 621.5 KiB = 1.4 MiB gdm-rh-security-token-helper 1.2 MiB + 387.5 KiB = 1.6 MiB gnome-session 916.0 KiB + 749.5 KiB = 1.6 MiB gdm-binary (2) 1.4 MiB + 225.0 KiB = 1.6 MiB cupsd 1.3 MiB + 443.5 KiB = 1.8 MiB notification-area-applet 2.1 MiB + 68.0 KiB = 2.2 MiB xfs 1.8 MiB + 545.5 KiB = 2.3 MiB eggcups 2.2 MiB + 86.5 KiB = 2.3 MiB gconfd-2 1.9 MiB + 492.5 KiB = 2.4 MiB gnome-settings-daemon 2.0 MiB + 421.5 KiB = 2.4 MiB gnome-power-manager 1.9 MiB + 570.0 KiB = 2.5 MiB trashapplet 1.7 MiB + 1.0 MiB = 2.7 MiB smbd (2) 2.6 MiB + 422.0 KiB = 3.0 MiB iscsid (2) 2.7 MiB + 350.0 KiB = 3.0 MiB sendmail.sendmail (2) 3.2 MiB + 72.0 KiB = 3.2 MiB hald 2.0 MiB + 1.3 MiB = 3.3 MiB sshd (3) 2.7 MiB + 651.0 KiB = 3.4 MiB clock-applet 2.5 MiB + 1.4 MiB = 3.9 MiB nm-applet 3.4 MiB + 728.5 KiB = 4.1 MiB metacity 3.4 MiB + 853.0 KiB = 4.3 MiB wnck-applet 4.4 MiB + 376.5 KiB = 4.8 MiB Xorg 4.3 MiB + 718.5 KiB = 5.0 MiB mixer_applet2 4.5 MiB + 809.5 KiB = 5.3 MiB gnome-panel 5.3 MiB + 251.5 KiB = 5.6 MiB hpssd.py 6.2 MiB + 4.1 MiB = 10.3 MiB httpd (18) 10.5 MiB + 869.0 KiB = 11.3 MiB gdmgreeter 12.8 MiB + 1.1 MiB = 13.8 MiB Xvnc 13.7 MiB + 515.5 KiB = 14.2 MiB yum-updatesd 16.3 MiB + 1.6 MiB = 17.9 MiB nautilus 20.8 MiB + 1.4 MiB = 22.2 MiB puplet 1.5 GiB + 441.0 KiB = 1.5 GiB java - 1.7 GiB = Private + Shared = RAM used Program 108.0 KiB + 11.5 KiB = 119.5 KiB klogd 124.0 KiB + 15.0 KiB = 139.0 KiB hidd 128.0 KiB + 12.5 KiB = 140.5 KiB gpm 116.0 KiB + 29.5 KiB = 145.5 KiB hald-addon-storage 120.0 KiB + 28.0 KiB = 148.0 KiB acpid 128.0 KiB + 25.0 KiB = 153.0 KiB dbus-launch 128.0 KiB + 31.5 KiB = 159.5 KiB hald-addon-acpi 144.0 KiB + 20.0 KiB = 164.0 KiB sdpd 140.0 KiB + 26.5 KiB = 166.5 KiB pam_timestamp_check 152.0 KiB + 16.5 KiB = 168.5 KiB irqbalance 152.0 KiB + 20.0 KiB = 172.0 KiB init 148.0 KiB + 26.0 KiB = 174.0 KiB mapping-daemon 152.0 KiB + 25.5 KiB = 177.5 KiB gnome-keyring-daemon 152.0 KiB + 27.5 KiB = 179.5 KiB portmap 164.0 KiB + 18.0 KiB = 182.0 KiB syslogd 168.0 KiB + 24.5 KiB = 192.5 KiB atd 180.0 KiB + 18.5 KiB = 198.5 KiB
Re: [R] outliers for Likert scale data
El día 01/09/2013 a las 15:13, Helen Sawaya helensaw...@hotmail.com escribió: Dear R experts, I have data from a questionnaire that I would like to factor analyse. It is in a likert scale form (0-3). I would like to check first for univariate and multivariate outliers but the most common ways of doing so assume the data is continuous and normal- neither of which is the case here. I found an article discussing this (Outlier Detection in Test and Questionnaire Data by Wobbe P. Zijlstra, L. Andries van der Ark, and Klaas Sijtsma), but I was wondering if I could get the exact R code on how to implement the outlier detection analyses. I have not found an exact implementation of that article, but one of its authors (van den Ark) has published the mokken package with some methods referred to in it: https://sites.google.com/a/tilburguniversity.edu/avdrark/mokken The ESD method for identifying outliers, also used in the paper to handle outlier scores, is implemented (together with others) in the package parody: http://www.bioconductor.org/packages/release/bioc/html/parody.html Hope it helps Helios De Rosario INSTITUTO DE BIOMECÁNICA DE VALENCIA Universidad Politécnica de Valencia • Edificio 9C Camino de Vera s/n • 46022 VALENCIA (ESPAÑA) Tel. +34 96 387 91 60 • Fax +34 96 387 91 69 www.ibv.org Antes de imprimir este e-mail piense bien si es necesario hacerlo. En cumplimiento de la Ley Orgánica 15/1999 reguladora de la Protección de Datos de Carácter Personal, le informamos de que el presente mensaje contiene información confidencial, siendo para uso exclusivo del destinatario arriba indicado. En caso de no ser usted el destinatario del mismo le informamos que su recepción no le autoriza a su divulgación o reproducción por cualquier medio, debiendo destruirlo de inmediato, rogándole lo notifique al remitente. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Placeholders for String Operations
Hi Simon, What you need are regular expressions. The help for gsub says this, but in such a way that if you didn't know that's what you were looking for, you wouldn't learn it there: See the help pages on regular expression for details of the different types of regular expressions. The See Also section has a better clue: regular expression (aka ‘regexp’) for the details of the pattern specification. ?regexp has a fairly terse explanation. I'd look at some of the many guides to regular expressions online, and use ?regexp mainly for how the R implementation differs from standard (mostly in the use of \). The help page does list all the groups, which is what you wanted. Sarah On Wed, Sep 4, 2013 at 11:17 AM, Simon Pickert simon.pick...@t-online.de wrote: Hi all, what are the placeholders for string operations/modifications? Is there a placeholder for numbers, which would allow me to easily replace all numbers in a string? Something like text1 - c(this is a number 23%) text2 - c(this is not a number bla%) newtext1 - gsub(#%, [percentagevalue], text) newtext2 - gsub(#%, [percentagevalue], text) newtext1 should be this is a number [percentagevalue] newtext2 should be this is not a number 23% I figured there is * ? . but I can't find a source that explains their use and lists other placeholders.. Appreciate your help! Thanks Simon -- Sarah Goslee http://www.functionaldiversity.org __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] 'snow' package -- parallel process
Hi R-community: I heard 'snow' package is a good tool to parallelize processes and speed them up. I tried to use it but was not successful. Could someboy point where I was wrong? Thanks. I want to read a HUGE file to R and hope 'snow' helps me to speed it up. Here are codes: library(snow) iFile = 'BIG.FILE.txt' numCluster = 4; readFile = function(file) { orig_d = read.delim(file); orig_d; } cl = makeCluster(numCluster, type = SOCK); x = clusterApply(cl, readFile, iFile); I got the error Error in x[[i]] : object of type 'closure' is not subsettable I also tried to read multiple files once filenames = rep(iFile, numCluster); x = clusterApply(cl, readFile, filenames); stopCluster(cl); and got the same error Thanks you for your help. HXD [[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] Permuting friendship nominations in a social network
Jean, Thank you for the suggestion. Actually the dataset is quite large so that method might be unmanageable. Holly hollym...@gmail.com On Sep 4, 2013, at 10:14 AM, Adams, Jean jvad...@usgs.gov wrote: Holly, I don't know of a clever way to do this, but I can think of a brute force way, which might only be feasible if you have a small data set (as in your example). You could permute every possible set of connections, then choose from that collection only the ones that meet your criteria. Using your example, there are c=21 possible connections among the n=7 unique individuals, c = n*(n-1)/2. Your example shows a total of 8 connections (16 rows / 2). So you could generate all permutations of choose(21, 8) = 203,490 ways to have 8 connections. Then subset the ones that have individual totals the same as your example (1 connection for Alicia and Beth, 2 for Kerry and Kim, 3 for James and John, and 4 for Rachel). Jean On Tue, Sep 3, 2013 at 1:01 PM, hollymaya hollym...@gmail.com wrote: I have a dataset of dyads (an edgelist) representing friendship nominations between egos and their nominated alters. The network is undirected so if ego is connected to alter, then there is a separate observation in the dataset for the reverse. I would like to randomly permute the friendships so that 1.) the total degree for each individual remains the same, i.e. each individual ends up with the same number of friendships they had in the original undirected dataset and 2.) there are no self loops, so individuals are not connected to themselves. Any suggestions on this would be greatly appreciated. Example Observed data: Ego Alter Alicia James BethKim James John James Rachel James Alicia JohnKerry JohnRachel JohnJames Kerry Rachel Kerry John Kim Rachel Kim Beth RachelKim RachelJames RachelKerry RachelJohn Permuted data: Ego Alter Alicia Rachel Beth James James Beth James John James Kim John Rachel John Kerry John James Kerry Rachel Kerry John Kim Rachel Kim James Rachel Kim Rachel John Rachel Alicia Rachel Kerry Thank you in advance, Holly hollym...@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. [[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] 'snow' package -- parallel process
On 04/09/2013 18:57, Hui Du wrote: Hi R-community: I heard 'snow' package is a good tool to parallelize processes and speed them up. I tried to use it but was not successful. Could someboy point where I was wrong? Thanks. I want to read a HUGE file to R and hope 'snow' helps me to speed it up. Here are codes: Why are you not using package 'parallel'? But read the help for clusterApply: you have the arguments wrong. And please do read the 'R Data Import/Export' manual and get read.delim working optimally first. library(snow) iFile = 'BIG.FILE.txt' numCluster = 4; readFile = function(file) { orig_d = read.delim(file); orig_d; } cl = makeCluster(numCluster, type = SOCK); x = clusterApply(cl, readFile, iFile); I got the error Error in x[[i]] : object of type 'closure' is not subsettable I also tried to read multiple files once filenames = rep(iFile, numCluster); x = clusterApply(cl, readFile, filenames); stopCluster(cl); and got the same error Thanks you for your help. HXD [[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. -- Brian D. Ripley, rip...@stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Histogram
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.
Re: [R] Histogram
We can just ask hist(): ? hist . . . breaks one of: a vector giving the breakpoints between histogram cells, a function to compute the vector of breakpoints, a single number giving the number of cells for the histogram, = a character string naming an algorithm to compute the number of cells (see 'Details'), a function to compute the number of cells. In the last three cases the number is a suggestion only. In this case hist has decided to ignore you. You can overrule by specifying the breaks: hist(1:10, 0:10+.5) - David L Carlson Associate Professor of Anthropology Texas AM University College Station, TX 77840-4352 -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 1:34 PM To: r-help@R-project.org Subject: [R] Histogram 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. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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
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. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Linear Regression line equation
First of I am new to using R. I have a dataset that I plotted using R, I created a scatter plot and used abline to create the line, what I need is to find the equation of the line. Below is the script I have used up until this point. young400_1-read.csv(Z:\\SOFTEL\\North Key Largo project\\Canopy_Height\\random_age_strat\\young400_1.csv) attach(young400_1) names(young400_1) plot(Ground_Elevation,Canopy_Height,pch=16) abline(lm(Canopy_Height~Ground_Elevation), col='red', main='Check the axis labels') This is where I'm stuck I don't know how to go about getting the equation to the line. My dataset is called young400_1 and it consist of 400 rows with 5 columns, I am only using 2 of the columns for the scatter plot; Ground_Elevation on the x axis and Canopy_Height on the y axis. Thanks in advance. -- View this message in context: http://r.789695.n4.nabble.com/Linear-Regression-line-equation-tp4675375.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Histogram
On 04/09/2013 4:02 PM, philippe massicotte wrote: 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. R is behaving as documented. You suggested 10 bins, but it finds for some datasets that a smaller or larger number gives better results. If you really want exactly 10 bins, then specify where you want them. Duncan Murdoch 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.
Re: [R] Histogram
On Wed, Sep 4, 2013 at 4:02 PM, philippe massicotte pmassico...@hotmail.com wrote: 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. It depends on the range of x. If you look at the definition of the hist function (just type hist.default at the prompt) you will find that when breaks are specified as a single number they are calculated using pretty(range(x), n = breaks) see ?pretty for details. Best, Ista 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.
Re: [R] Histogram
Hi, replicate(100,length(hist(10,0:10)$counts)) # [1] 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 #[26] 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 #[51] 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 #[76] 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 set.seed(56) a1- rnorm(100) bins- seq(min(a1),max(a1)+1,by=0.2) replicate(100,length(hist(a1,breaks=bins)$counts)) # [1] 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 #[26] 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 #[51] 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 #[76] 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 #May be this is what you are looking for: library(Rlab) set.seed(56) replicate(100,length(hplot(rnorm(100),nclass=10)$counts)) # [1] 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 #[26] 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 #[51] 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 #[76] 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 A.K. - Original Message - From: philippe massicotte pmassico...@hotmail.com To: Rui Barradas ruipbarra...@sapo.pt Cc: r-help@R-project.org r-help@r-project.org Sent: Wednesday, September 4, 2013 4:02 PM 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.
Re: [R] Attribute Length Error when Trying plm Regression
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-Regression-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. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Console Output Formatting
Depending on the OS you are working with awk or gawk are great utilities for stripping columns from files. Also if you use a spreadsheet it is quite easy to drop a column. On Sep 4, 2013 5:59 PM, Noah Silverman noahsilver...@ucla.edu wrote: Hi, Working with R, I often want to copy and paste some values somewhere else. (Its not worth saving a CSV file for a dozen or so entries.) Or, I may want to copy all the names of an object into some code. R, rather nicely, wraps output with an index number on the left side. For example: [1] -1.07781972 -1.12157840 1.79303276 1.53313388 -1.30854455 0.45641730 0.23866722 -1.96265084 [9] -1.90779578 -0.68418936 -2.04910282 0.12008358 -1.71072687 -0.36707605 -0.36939204 -2.02799948 [17] 0.36466562 -1.34204214 -0.45100125 -0.60483154 0.42208268 -0.89535576 -1.09398009 -2.07257728 [25] -0.04615273 -0.23659570 0.27232736 1.28432538 -2.17042948 -0.45364579 1.52957528 0.39838320 [33] 0.64923323 -1.01651051 -0.36287974 -0.73787761 0.48088199 -1.19539814 -0.80079095 -1.02507331 While this is great to read on screen, it is a pain to have to edit out all the index numbers. Is there a simple way to just back the values, or even a comma separated list of the values? Thanks! -- Noah Silverman, M.S., C.Phil UCLA Department of Statistics 8117 Math Sciences Building Los Angeles, CA 90095 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Console Output Formatting
On 04/09/2013 22:56, Noah Silverman wrote: Hi, Working with R, I often want to copy and paste some values somewhere else. (Its not worth saving a CSV file for a dozen or so entries.) Or, I may want to copy all the names of an object into some code. R, rather nicely, wraps output with an index number on the left side. For example: [1] -1.07781972 -1.12157840 1.79303276 1.53313388 -1.30854455 0.45641730 0.23866722 -1.96265084 [9] -1.90779578 -0.68418936 -2.04910282 0.12008358 -1.71072687 -0.36707605 -0.36939204 -2.02799948 [17] 0.36466562 -1.34204214 -0.45100125 -0.60483154 0.42208268 -0.89535576 -1.09398009 -2.07257728 [25] -0.04615273 -0.23659570 0.27232736 1.28432538 -2.17042948 -0.45364579 1.52957528 0.39838320 [33] 0.64923323 -1.01651051 -0.36287974 -0.73787761 0.48088199 -1.19539814 -0.80079095 -1.02507331 While this is great to read on screen, it is a pain to have to edit out all the index numbers. Is there a simple way to just back the values, or even a comma separated list of the values? There are many. Here I usually use write(x, ). The file = trick works in many other functions. Using dput() and removing c( and ) is also often useful when comma separation is needed. -- Brian D. Ripley, rip...@stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Read a Google Spreadsheet?
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 -- Spencer Graves, PE, PhD President and Chief Technology Officer Structure Inspection and Monitoring, Inc. 751 Emerson Ct. San José, CA 95126 ph: 408-655-4567 web: www.structuremonitoring.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] Console Output Formatting
print(1:100) [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 [27] 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 [53] 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 [79] 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 cat(1:100)1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 On Wed, Sep 4, 2013 at 3:09 PM, Prof Brian Ripley rip...@stats.ox.ac.ukwrote: On 04/09/2013 22:56, Noah Silverman wrote: Hi, Working with R, I often want to copy and paste some values somewhere else. (Its not worth saving a CSV file for a dozen or so entries.) Or, I may want to copy all the names of an object into some code. R, rather nicely, wraps output with an index number on the left side. For example: [1] -1.07781972 -1.12157840 1.79303276 1.53313388 -1.30854455 0.45641730 0.23866722 -1.96265084 [9] -1.90779578 -0.68418936 -2.04910282 0.12008358 -1.71072687 -0.36707605 -0.36939204 -2.02799948 [17] 0.36466562 -1.34204214 -0.45100125 -0.60483154 0.42208268 -0.89535576 -1.09398009 -2.07257728 [25] -0.04615273 -0.23659570 0.27232736 1.28432538 -2.17042948 -0.45364579 1.52957528 0.39838320 [33] 0.64923323 -1.01651051 -0.36287974 -0.73787761 0.48088199 -1.19539814 -0.80079095 -1.02507331 While this is great to read on screen, it is a pain to have to edit out all the index numbers. Is there a simple way to just back the values, or even a comma separated list of the values? There are many. Here I usually use write(x, ). The file = trick works in many other functions. Using dput() and removing c( and ) is also often useful when comma separation is needed. -- Brian D. Ripley, rip...@stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~**ripley/http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __** R-help@r-project.org mailing list https://stat.ethz.ch/mailman/**listinfo/r-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.
[R] xyplot and lwd
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) 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] Console Output Formatting
Hi, You could use ?cat() For ex: vec1-1:100 cat(vec1) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 cat(vec1,sep=,) 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100 #or write(vec1,,sep=,) 1,2,3,4,5 6,7,8,9,10 11,12,13,14,15 16,17,18,19,20 21,22,23,24,25 26,27,28,29,30 31,32,33,34,35 36,37,38,39,40 41,42,43,44,45 46,47,48,49,50 51,52,53,54,55 56,57,58,59,60 61,62,63,64,65 66,67,68,69,70 71,72,73,74,75 76,77,78,79,80 81,82,83,84,85 86,87,88,89,90 91,92,93,94,95 96,97,98,99,100 A.K. - Original Message - From: Noah Silverman noahsilver...@ucla.edu To: R help r-help@r-project.org Cc: Sent: Wednesday, September 4, 2013 5:56 PM Subject: [R] Console Output Formatting Hi, Working with R, I often want to copy and paste some values somewhere else. (Its not worth saving a CSV file for a dozen or so entries.) Or, I may want to copy all the names of an object into some code. R, rather nicely, wraps output with an index number on the left side. For example: [1] -1.07781972 -1.12157840 1.79303276 1.53313388 -1.30854455 0.45641730 0.23866722 -1.96265084 [9] -1.90779578 -0.68418936 -2.04910282 0.12008358 -1.71072687 -0.36707605 -0.36939204 -2.02799948 [17] 0.36466562 -1.34204214 -0.45100125 -0.60483154 0.42208268 -0.89535576 -1.09398009 -2.07257728 [25] -0.04615273 -0.23659570 0.27232736 1.28432538 -2.17042948 -0.45364579 1.52957528 0.39838320 [33] 0.64923323 -1.01651051 -0.36287974 -0.73787761 0.48088199 -1.19539814 -0.80079095 -1.02507331 While this is great to read on screen, it is a pain to have to edit out all the index numbers. Is there a simple way to just back the values, or even a comma separated list of the values? Thanks! -- Noah Silverman, M.S., C.Phil UCLA Department of Statistics 8117 Math Sciences Building Los Angeles, CA 90095 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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
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 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) 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 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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.
[R] Console Output Formatting
Hi, Working with R, I often want to copy and paste some values somewhere else. (Its not worth saving a CSV file for a dozen or so entries.) Or, I may want to copy all the names of an object into some code. R, rather nicely, wraps output with an index number on the left side. For example: [1] -1.07781972 -1.12157840 1.79303276 1.53313388 -1.30854455 0.45641730 0.23866722 -1.96265084 [9] -1.90779578 -0.68418936 -2.04910282 0.12008358 -1.71072687 -0.36707605 -0.36939204 -2.02799948 [17] 0.36466562 -1.34204214 -0.45100125 -0.60483154 0.42208268 -0.89535576 -1.09398009 -2.07257728 [25] -0.04615273 -0.23659570 0.27232736 1.28432538 -2.17042948 -0.45364579 1.52957528 0.39838320 [33] 0.64923323 -1.01651051 -0.36287974 -0.73787761 0.48088199 -1.19539814 -0.80079095 -1.02507331 While this is great to read on screen, it is a pain to have to edit out all the index numbers. Is there a simple way to just back the values, or even a comma separated list of the values? Thanks! -- Noah Silverman, M.S., C.Phil UCLA Department of Statistics 8117 Math Sciences Building Los Angeles, CA 90095 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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
Good question. It turns out that the manual page does not tell the whole story. 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.
Re: [R] for loop of a geometric sequence
So look at the examples found in ?Control and give it a try. -- Don MacQueen Lawrence Livermore National Laboratory 7000 East Ave., L-627 Livermore, CA 94550 925-423-1062 On 8/30/13 9:57 AM, BJN1417 bjn1...@uncw.edu wrote: so I have to create a for loop of the geometric sequence h(x,n)=1+x+x^2+x^3^4...x^n. I know that it would be easier to simply vectorize the sequence to x^(0:n), but I am required to make the loop, and I can't wrap my brain around how to loop it because the equation is so simple. -- View this message in context: http://r.789695.n4.nabble.com/for-loop-of-a-geometric-sequence-tp4675035.h tml 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] 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] 14945 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-Regression-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.
Re: [R] Linear Regression line equation
summary(lm(Canopy_Height~Ground_Elevation, data=young400_1)) #use data= instead of attach! Or even mylm - lm(Canopy_Height~Ground_Elevation, data=young400_1) mylm summary(mylm) coefficients(mylm) Most intro to R guides cover the basics of modeling; you might benefit from reading one of them. Sarah On Wed, Sep 4, 2013 at 1:35 PM, jfrei006 jfrei...@fiu.edu wrote: First of I am new to using R. I have a dataset that I plotted using R, I created a scatter plot and used abline to create the line, what I need is to find the equation of the line. Below is the script I have used up until this point. young400_1-read.csv(Z:\\SOFTEL\\North Key Largo project\\Canopy_Height\\random_age_strat\\young400_1.csv) attach(young400_1) names(young400_1) plot(Ground_Elevation,Canopy_Height,pch=16) abline(lm(Canopy_Height~Ground_Elevation), col='red', main='Check the axis labels') This is where I'm stuck I don't know how to go about getting the equation to the line. My dataset is called young400_1 and it consist of 400 rows with 5 columns, I am only using 2 of the columns for the scatter plot; Ground_Elevation on the x axis and Canopy_Height on the y axis. Thanks in advance. -- Sarah Goslee http://www.functionaldiversity.org __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Random products of rows in a matrix
Hi Edouard, In terms of speed, your new solution may not be that much different from the old one: #large matrix M- 10 N- 1e3 set.seed(249) A- matrix(sample(1:10,1e5*4,replace=TRUE),1e5,4) B- matrix(NA,ncol=ncol(A),nrow=0) system.time({ set.seed(54) for (i in 1 : N) B - rbind(B, apply(A[sample(1 : nrow(A), M, replace = T),], 2, prod)) }) # user system elapsed # 0.240 0.048 0.290 system.time({ set.seed(54) res- do.call(rbind,lapply(1:N,function(x) {A1-A[sample.int(nrow(A),M,replace=TRUE),]; tapply(as.vector(A1),list(rep(seq_len(ncol(A1)),each=nrow(A1))),prod)})) }) # user system elapsed # 0.300 0.000 0.302 dimnames(res)- dimnames(B) identical(res,B) #[1] TRUE B1- matrix(NA,ncol=ncol(A),nrow=0) system.time({ set.seed(54) for(i in 1:N) { A1-A[sample.int(nrow(A),M,replace=TRUE),] B1- rbind(B1,tapply(as.vector(A1),list(rep(seq_len(ncol(A1)),each=nrow(A1))),prod)) } }) # user system elapsed # 0.312 0.008 0.318 system.time({ set.seed(54) l-tapply(rep(M,N),1:N,function(x){A[sample(1:nrow(A), M, replace = T), ]}) B2-t(sapply(l,apply,2,prod)) }) # user system elapsed # 0.156 0.136 0.290 dimnames(B1)- dimnames(B2) identical(B1,B2) #[1] TRUE library(matrixStats) system.time({ set.seed(54) B3-do.call(rbind, lapply(1:N, function(x) colProds(A[sample.int(nrow(A), M, replace=TRUE),]))) }) # user system elapsed # 0.152 0.000 0.155 dimnames(B3)- dimnames(B2) all.equal(B2,B3) #[1] TRUE A.K. From: Edouard Hardy hardy.edou...@gmail.com To: arun smartpink...@yahoo.com Sent: Wednesday, September 4, 2013 1:31 PM Subject: Re: [R] Random products of rows in a matrix I am not allowed to. I found a solution : l-tapply(rep(M,N),1:N,function(x){A[sample(1 : nrow(A), M, replace = T), ]}) t(sapply(l,apply,2,prod)) Edouard Hardy On Wed, Sep 4, 2013 at 5:38 PM, arun smartpink...@yahoo.com wrote: No problem. Can I know the reason? Tx. From: Edouard Hardy hardy.edou...@gmail.com To: arun smartpink...@yahoo.com Cc: dcarl...@tamu.edu dcarl...@tamu.edu Sent: Wednesday, September 4, 2013 11:32 AM Subject: Re: [R] Random products of rows in a matrix Hello and thank you for your help. Unfortunately, I cannot use any package... Edouard Hardy On Wed, Sep 4, 2013 at 4:52 PM, arun smartpink...@yahoo.com wrote: HI Edouard, Is there any limitations in installing a package? Using David's solution, if you could install, library(matrixStats) set.seed(28) A- matrix(sample(1:10,5*4,replace=TRUE),5,4) B - matrix(NA, ncol = ncol(A), nrow = 0) N- 3 M- nrow(A) set.seed(54) for (i in 1 : N) B - rbind(B, apply(A[sample(1 : nrow(A), M, replace = T), ], 2, prod)) set.seed(54) B1- do.call(rbind, lapply(1:N, function(x) colProds(A[sample.int(nrow(A), M, replace=TRUE),]))) all.equal(B,B1) #[1] TRUE A.K. - Original Message - From: David Carlson dcarl...@tamu.edu To: 'Edouard Hardy' hardy.edou...@gmail.com; 'R help' r-help@r-project.org Cc: Sent: Wednesday, September 4, 2013 10:34 AM Subject: Re: [R] Random products of rows in a matrix Actually you have two loops, the for() loop you created and the loop that is hidden inside apply(). You can hide the first loop with lapply() or sapply(): B - do.call(rbind, lapply(1:N, function(x) colSums(A[sample.int(nrow(A), M, replace=TRUE),]))) Or B - t(sapply(1:N, function(x) colSums(A[sample.int(nrow(A), M, replace=TRUE),]))) You could eliminate the apply() loop by taking log(A), using colSums(), and then converting back with exp(). - David L Carlson Associate Professor of Anthropology Texas AM University College Station, TX 77840-4352 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Edouard Hardy Sent: Wednesday, September 4, 2013 2:59 AM To: R help Subject: [R] Random products of rows in a matrix Hello everybody, Without any loop and any package, I would like to return N products of M rows in a matrix A : Today, I managed to do it with a loop : B - matrix(NA, ncol = ncol(A), nrow = 0) for (i in 1 : N) B - rbind(B, apply(A[sample(1 : nrow(A), M, replace = T), ], 2, prod)) Do you have a solution ? Thank you in advance ! [[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
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] Console Output Formatting
On 13-09-04 5:56 PM, Noah Silverman wrote: Hi, Working with R, I often want to copy and paste some values somewhere else. (Its not worth saving a CSV file for a dozen or so entries.) Or, I may want to copy all the names of an object into some code. Besides the other suggestions, the data editor in R can be a source for cut and paste to a spreadsheet, at least in Windows and Mac OSX. This is useful for matrices and dataframes. Duncan Murdoch R, rather nicely, wraps output with an index number on the left side. For example: [1] -1.07781972 -1.12157840 1.79303276 1.53313388 -1.30854455 0.45641730 0.23866722 -1.96265084 [9] -1.90779578 -0.68418936 -2.04910282 0.12008358 -1.71072687 -0.36707605 -0.36939204 -2.02799948 [17] 0.36466562 -1.34204214 -0.45100125 -0.60483154 0.42208268 -0.89535576 -1.09398009 -2.07257728 [25] -0.04615273 -0.23659570 0.27232736 1.28432538 -2.17042948 -0.45364579 1.52957528 0.39838320 [33] 0.64923323 -1.01651051 -0.36287974 -0.73787761 0.48088199 -1.19539814 -0.80079095 -1.02507331 While this is great to read on screen, it is a pain to have to edit out all the index numbers. Is there a simple way to just back the values, or even a comma separated list of the values? Thanks! -- Noah Silverman, M.S., C.Phil UCLA Department of Statistics 8117 Math Sciences Building Los Angeles, CA 90095 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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
Thank you everyone for your help. Date: Wed, 4 Sep 2013 20:00:02 -0400 From: murdoch.dun...@gmail.com To: dcarl...@tamu.edu CC: pmassico...@hotmail.com; ruipbarra...@sapo.pt; 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. [[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 a Google Spreadsheet?
Hi Spencer, Why don't you want to install 64bit Java? 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 -- Spencer Graves, PE, PhD President and Chief Technology Officer Structure Inspection and Monitoring, Inc. 751 Emerson Ct. San José, CA 95126 ph: 408-655-4567 web: www.structuremonitoring.com __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Read a Google Spreadsheet?
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.
[R] optim evils
Sometimes one has to really read the manual carefully. If non-trivial bounds are supplied, this method will be selected, with a warning. (re L-BFGS-B) Several of us have noted problems occasionally with this code. You might want to look at the box constrained codes offered in optimx package through other packages (bobyqa, nmkb, Rvmmin, Rcgmin) JN On 13-09-04 06:00 AM, r-help-requ...@r-project.org wrote: Message: 67 Date: Wed, 4 Sep 2013 16:34:54 +0800 (SGT) From: Michael Meyerspyqqq...@yahoo.com To:r-help@r-project.org r-help@r-project.org Subject: [R] optim evils Message-ID: 1378283694.77272.yahoomail...@web193402.mail.sg3.yahoo.com Content-Type: text/plain It would take some effort to extract selfcontained code from the mass of code wherein this optimization is embedded. Moreover I would have to obtain permission from my employer to do so. This is not efficient. However some things are evident from the trace log which I have submitted: (a) L-BFGS-B does not identify itself even though it was called overriding the method parameter in optim. (b) Optim reports as final converged minimum value a function value that is much larger than others computed during the optimization. I think we can agree on calling this a bug. [[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 a Google Spreadsheet?
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.
[R] Question about R2 in pls package
Hi, I have questions about R2 used in pls (or multivariate analysis). Is R2 same with the square of the PCC (Pearson Correlation Coefficient)? I found the following description from wiki (Coefficient of determination) Similarly, in linear least squares regression with an estimated intercept term, R2 equals the square of the Pearson correlation coefficient between the observed and modeled (predicted) data values of the dependent variable. - If so, Q2 (R2 of cross validation) should range between 0 and 1. But it doesn't. I got negative values of Q2 when running my dataset. Of course, from the definition of Q2, Q2 can be negative when my model is not at all predictive. My question is what the relationship between R2 and pcc^2 is. 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] Poly Correlations
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. 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. 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. 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] New Version of R 3.0.1 problems with installing Rcmdr
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. -- 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.
Re: [R] Question about R2 in pls package
On Sep 4, 2013, at 10:39 PM, Euna Jeong wrote: Hi, I have questions about R2 used in pls (or multivariate analysis). Is R2 same with the square of the PCC (Pearson Correlation Coefficient)? I found the following description from wiki (Coefficient of determination) Similarly, in linear least squares regression with an estimated intercept term, R2 equals the square of the Pearson correlation coefficient between the observed and modeled (predicted) data values of the dependent variable. - If so, Q2 (R2 of cross validation) should range between 0 and 1. But it doesn't. I got negative values of Q2 when running my dataset. Of course, from the definition of Q2, Q2 can be negative when my model is not at all predictive. My question is what the relationship between R2 and pcc^2 is. Adjusted R-squareds can become negative when the adjustment for the added number of predictors overwhelms the increased model fit on the scale of adjustment. Do a search of the archives for negative r-squared. Here's just one of many: http://r-project.markmail.org/search/?q=list%3Aorg.r-project.r-help%20%20negative%20r-squared#query :list%3Aorg.r-project.r-help%20%20negative%20r-squared+page:1+mid:rhiqm5bcm4maxnef+state:results -- 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] Permuting friendship nominations in a social network
It might be, but with appropriate indexes a SQL engine (via sqldf or RODBC for example) might be able to do it that way anyway. --- Jeff NewmillerThe . . Go Live... DCN:jdnew...@dcn.davis.ca.usBasics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/BatteriesO.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --- Sent from my phone. Please excuse my brevity. hollymaya hollym...@gmail.com wrote: Jean, Thank you for the suggestion. Actually the dataset is quite large so that method might be unmanageable. Holly hollym...@gmail.com On Sep 4, 2013, at 10:14 AM, Adams, Jean jvad...@usgs.gov wrote: Holly, I don't know of a clever way to do this, but I can think of a brute force way, which might only be feasible if you have a small data set (as in your example). You could permute every possible set of connections, then choose from that collection only the ones that meet your criteria. Using your example, there are c=21 possible connections among the n=7 unique individuals, c = n*(n-1)/2. Your example shows a total of 8 connections (16 rows / 2). So you could generate all permutations of choose(21, 8) = 203,490 ways to have 8 connections. Then subset the ones that have individual totals the same as your example (1 connection for Alicia and Beth, 2 for Kerry and Kim, 3 for James and John, and 4 for Rachel). Jean On Tue, Sep 3, 2013 at 1:01 PM, hollymaya hollym...@gmail.com wrote: I have a dataset of dyads (an edgelist) representing friendship nominations between egos and their nominated alters. The network is undirected so if ego is connected to alter, then there is a separate observation in the dataset for the reverse. I would like to randomly permute the friendships so that 1.) the total degree for each individual remains the same, i.e. each individual ends up with the same number of friendships they had in the original undirected dataset and 2.) there are no self loops, so individuals are not connected to themselves. Any suggestions on this would be greatly appreciated. Example Observed data: Ego Alter Alicia James BethKim James John James Rachel James Alicia JohnKerry JohnRachel JohnJames Kerry Rachel Kerry John Kim Rachel Kim Beth RachelKim RachelJames RachelKerry RachelJohn Permuted data: Ego Alter Alicia Rachel Beth James James Beth James John James Kim John Rachel John Kerry John James Kerry Rachel Kerry John Kim Rachel Kim James Rachel Kim Rachel John Rachel Alicia Rachel Kerry Thank you in advance, Holly hollym...@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. [[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.