Re: [R] Efficient Way to gather data from various files
File operations are not vectorizable. About the only thing you can do for the iterating through files part might be to use lapply instead of a for loop, but that is mostly a style change. Once you have read the dbf files there will probably be vector functions you can use (quantile). Off the top of my head I don't know a function that tells you which value corresponds to a particular quantile, but you can probably sort the data with order(), find the value whose ecdf is just below your target with which.max, and look at the row number of that value. x - rnorm(11) names(x) - seq(x) xs - x[order(x)] Row90 - as.numeric(names (xs)[0.9=seq(xs)/length(xs))]) --- 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. Sam Asin asin@gmail.com wrote: Hello, Sorry if this process is too simple for this list. I know I can do it, but I always read online about how when using R one should always try to avoid loops and use vectors. I am wondering if there exists a more R friendly way to do this than to use for loops. I have a dataset that has a list of IDs. Let's call this dataset Master Each of these IDs has an associated DBF file. The DBF files each have the same title, and they are each located in a directory path that includes, as one of the folder names, the ID. These DBF files have 2 columns of interest. One is the run number the other is the statistic. I'm interested in the median and 90th percentile of the statistic as well as their corresponding run numbers. Ultimately, I want a table that consists of ID Run_50th Stat_50 Run_90 Stat_90 1AB 5102010 3 144376 1AC 399 6 9 etc. Where I currently have a dataset that has ID 1AB 1AC etc. And there are several DBF files that are in folders i.e. folder1/1AC/folder2/blah.dbf This dbf looks like run Stat 1 10 2 10 3 99 4 1000 5 1 6 99 7 1 8 10 9 10 1010 11 100 I know i could do this with a loop, but I can't see the efficient, R way. I was hoping that you experienced R programmers could give me some pointers on the most efficient way to achieve this result. Sam [[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] patch download?
That is silly. The primary difference is that certain bugfix patches have been applied. A side-effect of this first patched status is that unintentional bugs may have been introduced, so unless you have already encountered a bug that was patched there then you are likely better off sticking with the standard release. That said, I have had no qualms about using a patched version when I encountered a bug that got fixed. --- 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. Poggio, John jpog...@ku.edu wrote: Is the primary difference between the current version download (e.g., 2.15.1) and the patched download of these R files that the patched files have NOT been verified? Please confirm and 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] Get Cran R to use system proxy settings
Off-topic here. Try https://stat.ethz.ch/mailman/listinfo/r-sig-debian. I also strongly recommend that you be more specific about what you have tried and how it didn't work as you expected when you post there. --- 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. Sachinthaka Abeywardana sachin.abeyward...@gmail.com wrote: Hi all, I am using Ubuntu and I am having quite a bit of difficulty trying to get R to use the system proxy settings. Any suggestions? Thanks, Sachin __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Text to Speech In R
Why do you think this is something R should be able to do? --- 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. Alex Zhang alex.zh...@ymail.com wrote: Dear all, Excuse me for my searching skills: I just couldn't figure out how to do any simple text to speech in R�console. What I want to do is, out put simple English words or sentences to speaker as voice. No fanciness. For example, I want the R console to speak Hello world or Howdy. Do you know of any related function/package? Thanks, - Alex [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Text to Speech In R
Please don't shout. Speech synthesis is associated in my mind with sound generation, which is rather platform-specific. R is a platform agnostic research tool. R can be interfaced with many kinds of external libraries, so many things are possible. However, they aren't necessarily simple, and hiding operating system differences can take a lot of work. Your expectation that this be simple is what seems unwarranted to me. --- 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. Alex Zhang alex.zh...@ymail.com wrote: Jeff - so, do you mean that you are sure it can NOT AND SHOULD NOT? Thanks, - Alex From: Jeff Newmiller jdnew...@dcn.davis.ca.us To: Alex Zhang alex.zh...@ymail.com; Alex Zhang alex.zh...@ymail.com; r-help@r-project.org r-help@r-project.org Sent: Thursday, October 4, 2012 8:46 AM Subject: Re: [R] Text to Speech In R Why do you think this is something R should be able to do? --- Jeff Newmiller The . . Go Live... DCN:jdnew...@dcn.davis.ca.us Basics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/Batteries O.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --- Sent from my phone. Please excuse my brevity. Alex Zhang alex.zh...@ymail.com wrote: Dear all, Excuse me for my searching skills: I just couldn't figure out how to do any simple text to speech in R�console. What I want to do is, out put simple English words or sentences to speaker as voice. No fanciness. For example, I want the R console to speak Hello world or Howdy. Do you know of any related function/package? Thanks, - Alex [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] (no subject)
Please use a relevant subject line. You can easily download source code for all CRAN packages and read it yourself. --- 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. Chia-Yi Chiu chia-yi.c...@gse.rutgers.edu wrote: Hi I would like to learn how the R function hclust deals with ties. It is written in Fortran, so I cannot access the code. 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] what exactly is the dim of data set yarn in package pls?
Perhaps what is wrong is that you need to learn when to use the str() function. str(yarn) --- 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. C W tmrs...@gmail.com wrote: Hi list, I am looking at the data yarn in package, I don't understand what is dimension of this data set. I did the following: library(pls) data(yarn) dim(yarn) [1] 28 3 head(yarn) NIR.1 NIR.2 NIR.3 NIR.4 NIR.5 NIR.6 NIR.7 NIR.8 NIR.9 NIR.10 NIR.11 1 3.06630 3.08610 3.10790 3.09720 2.99790 2.82730 2.62330 2.40390 2.19310 2.00580 1.83790 2 3.06750 3.08570 3.09580 3.06920 2.98180 2.84080 2.67600 2.50590 2.35060 2.22300 2.11920 3 3.07500 3.09660 3.09160 3.02880 2.88490 2.68850 2.47640 2.26940 2.08240 1.91950 1.77470 4 3.08280 3.09730 3.10100 3.07350 2.99130 2.87090 2.73920 2.61020 2.5 2.42370 2.37740 5 3.10290 3.10340 3.08480 3.02280 2.89270 2.71590 2.53840 2.37640 2.23970 2.13460 2.05340 6 3.08150 3.08490 3.04870 2.93050 2.73230 2.50890 2.29440 2.09950 1.93280 1.79250 1.66930 There were 270 columns, I only copy pasted the first 11 columns. But either way, this is NOT 3 columns. Could anyone let me know what is wrong here? Thanks in advance, Mike [[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] Robust regression for ordered data
This does not appear to be a question about R. You should post in a list or forum dedicated to discussing statistics theory, such as stats.stackoverflow.com. --- 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. Eiko Fried tor...@gmail.com wrote: I have two regressions to perform - one with a metric DV (-3 to 3), the other with an ordered DV (0,1,2,3). Neither normal distribution not homoscedasticity is given. I have a two questions: (1) Some sources say robust regression take care of both lack of normal distribution and heteroscedasticity, while others say only of normal distribution. What is true? (2) Are there ways of using robust regressions with ordered data, or is that only possible for metric DVs? Thanks Torvon [[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] Robust regression for ordered data
I don't know about the topic of your question. Have you used the RSiteSearch function to research it yourself? --- 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. Eiko Fried tor...@gmail.com wrote: Thank you Jeff! Please ignore the first of my two questions then, and apologies for not making it clear that my second question was about R. (2) Are there ways of using robust regressions with ordered data ... in R? Thank you On 7 October 2012 18:26, Jeff Newmiller jdnew...@dcn.davis.ca.us wrote: This does not appear to be a question about R. You should post in a list or forum dedicated to discussing statistics theory, such as stats.stackoverflow.com. --- 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. Eiko Fried tor...@gmail.com wrote: I have two regressions to perform - one with a metric DV (-3 to 3), the other with an ordered DV (0,1,2,3). Neither normal distribution not homoscedasticity is given. I have a two questions: (1) Some sources say robust regression take care of both lack of normal distribution and heteroscedasticity, while others say only of normal distribution. What is true? (2) Are there ways of using robust regressions with ordered data, or is that only possible for metric DVs? Thanks Torvon [[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] Removing header from a matrix
You need to clarify what you have and what you want. Please use the dput() function to create a reproducible example that we can enter into R to make suggestions about. [1] There are a couple of possible things that could be going on here, and what you have given so far is ambiguous. [1] http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example --- 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. Dereje Bacha d_ba...@yahoo.com wrote: I have three column vectors (X1, X2, X3).� ��� X1� X2� X3 �� 20�� 25� 40 �� 100 90� 80 I want to put them as one matrix of dimention 2 by 3, �but remove headers(X1,X2,X3) from the matrix. I wrote as follows U-cbind (X1,X2,X3) the headers are there. I need help please. Thanks Dereje [[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] other way of making a table?
Use factors? --- 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. Jessica Streicher j.streic...@micromata.de wrote: I'm making tables for prediction results of classifiers (2 classes) that show the usual numbers, true positives, false positives, etc I used the command table(predictedLabels,realLabels) to make those. I just had a case though ,where one of the label vectors had only one class in it. This will result in only half a table. Compare: x-c(1,1,1,0,0) y-c(1,1,1,0,1) table(x,y) to x-c(1,1,1,0,0) y-c(1,1,1,1,1) table(x,y) I want the second one to still have all 4 cases (second column all zeros then). Any easy solutions? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to write out this regression equation in R?
But sprintf is itself vectorized. If you give it vectors, it returns vectors. So you could obtain that apply-result more efficiently by passing a bunch of column vectors of data. There happens to be a convenient object called a data frame that holds a bunch of similar-length vectors. DF - data.frame( m=c(1,2), b=c(-3,4) ) result - sprintf( y=(%d)*x+(%d), DF$m, DF$b) cat(paste(result, collapse=\n)) --- 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. S Ellison s.elli...@lgcgroup.com wrote: How to make R write out: Balance = 2 + 3 * IntGDP + 5 * IntUnemployment + 0.3 * d1 from the table below: Balance Intercept IntGDP GDPNum IntUnemployment IntInflationd1 d2 d3 3 2 3 5 0.3 0 0 Maybe ?sprintf would help? And if you wrap that in a function that takes a vector, using apply() on the table would give you one string per row, *** 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. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] RGL package surface plot
You should help us per the posting guide reproducible sample data, code you have tried that you thought would work, why you think it did not, output of sessionInfo function... Note that you can learn a lot by doing this exercise, your problem may not be where you think it is (or where we might guess it is) See http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example --- 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. ariklee eric.kra...@respec.com wrote: I'm completely new at R... I have sinkhole survey data (lat, long, and elevation) and have been trying to plot a rotatable 3d plot for several hours... cannot get it right. Examples I see tend to be grid data (one elevation value per grid cell); however, my data are more random (known elevations at known (but random) x-y positions). Data format is tab separated, i.e.: lat long elev 3443 2 36.832.54 6.2 ...etc... please help! arik -- View this message in context: http://r.789695.n4.nabble.com/RGL-package-surface-plot-tp4645642.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] Optimx Package Error
This is operator error. Do not attempt to optimize over an infinite range. --- 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. nserdar snes1...@hotmail.com wrote: estimate- optimx(init.par,Linn,gr=NULL,method= L-BFGS-B, hessian=TRUE, control = list(trace=1),lower=c(0,0,0,-Inf,-Inf,-Inf,-Inf,-Inf,-Inf,-Inf),upper=c(1,1,1,Inf,Inf,Inf,Inf,Inf,Inf,Inf)) fn is Linn Function has 10 arguments par[ 1 ]: 0 ? 0 ? 1 In Bounds par[ 2 ]: 0 ? 0 ? 1 In Bounds In Bounds par[ 3 ]: 0 ? 0 ? 1 In Bounds In Bounds In Bounds par[ 4 ]: -Inf ? 1 ? Inf In Bounds In Bounds In Bounds In Bounds par[ 5 ]: -Inf ? 1 ? Inf In Bounds In Bounds In Bounds In Bounds In Bounds par[ 6 ]: -Inf ? 1 ? Inf In Bounds In Bounds In Bounds In Bounds In Bounds In Bounds par[ 7 ]: -Inf ? 1 ? Inf In Bounds In Bounds In Bounds In Bounds In Bounds In Bounds In Bounds par[ 8 ]: -Inf ? 1 ? Inf In Bounds In Bounds In Bounds In Bounds In Bounds In Bounds In Bounds In Bounds par[ 9 ]: -Inf ? 1 ? Inf In Bounds In Bounds In Bounds In Bounds In Bounds In Bounds In Bounds In Bounds In Bounds par[ 10 ]: -Inf ? 1 ? Inf In Bounds In Bounds In Bounds In Bounds In Bounds In Bounds In Bounds In Bounds In Bounds In Bounds Error in optimx(init.par, Linn, gr = NULL, method = L-BFGS-B, hessian = TRUE, : Cannot evaluate function at initial parameters Please let me know how to deal with this problem. Regards, Serdar -- View this message in context: http://r.789695.n4.nabble.com/Optimx-Package-Error-tp4645669.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] Contacting Delphi ??
Its suddenness is only as sudden as your input that triggered it. Its oblique nature is a reflection of the nature of your input. http://lmgtfy.com/?q=R+contacting+Delphi+oracle+is+unavailable --- 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. Christian Hoffmann c-w.hoffm...@sunrise.ch wrote: What does the sudden appearance of Contacting Delphi ..the oracle is unavailable. We apologize for any inconvenience. mean? A bug? It appears at plotting. Thanks Christian __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Converting factors to bounded random numerical data
Please don't double post. --- 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. KoopaTrooper ncoop...@tulane.edu wrote: I have a data set (a) with three columns (X,Y,Z). The first 2 columns are numeric. The third (Z) is a factor with three levels A,B,C. I want to turn each A into a different random number between 1 and 4, each B into a different random number between 5 and 8, etc. I tried this: a$Z-ifelse(a$Z==L,sample(1:4,1),ifelse(a$Z==M,sample(5:9,1),ifelse(a$Z==U,sample(10:12,1),) and it almost worked but changed all the A's into the same random number. I need a different random number for each A. Ideas? Thanks, -- View this message in context: http://r.789695.n4.nabble.com/Converting-factors-to-bounded-random-numerical-data-tp4645801.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] Columns and rows
Data frames don't have unequal column or row lengths within a single object. Your terminology is obscuring your intent. Perhaps you should read the posting guide for guidance on posting here and then generate a reproducible example. Since you seem to be having difficulty with the how, at least provide sample input and desired output following the recommendations here: http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example Are you aware of ?cbind ?rbind ?merge ? --- 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. Santana Sarma aimanusa...@gmail.com wrote: Hi, Could you please advice some easy way to do the following for a dataframe (header=F) having unequal column- row- length. 1. Combine/stack/join contents from - a) multiple rows into one column. b) multiple columns into one row. 2. Stack contents from multiple columns (or, rows) into one column (or, row). Thank you. Cheers, Santana [[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] Columns and rows
Better, but you didn't do your reading. Seriously... learn to make it reproducible... you will get quicker help from more skilled R users. Also, post in text, not HTML. Note that data frames are not really the right data structure for doing the kinds of operations you are describing below, since you assume that rows and columns are essentially interchangeable. Lists of vectors might be, but only if you were reading from a data format like XML that reflected that structure. Matrices have a uniform 2d structure with a transpose operation defined, and can contain NA values. Also, vectors are not described as column or row vectors in R ... that is Matlab-speak. Vectors have no direction, just sequence. Matrices are folded vectors (vectors with row and column dimension attributes). The as.vector() function forgets the row and column attributes of a matrix (or other object). The matrix() function adds those attributes, effectively folding the vector up into 2d. Data frames are lists of vectors with the same length, where each vector can have a different type of data (e.g. string, numeric, logical, factor). They are printed, read from files and written to files with the vectors as columns (even though vectors themselves have no notion of being columns). Thus, working with one row at a time is much slower than working with one column at a time, and since each element of a row can be a different type of data it doesn't make sense to mash them up the way you want to. I suggest you print and use the str() function liberally on the objects and expressions below to understand how they work. #reproducible data DF - read.csv( text= Names,'Col x','Col y','Col z' rowName1,A,E,H rowName2,B,F,I rowName3,C,G,J rowName4,D,,K , header=TRUE, row.names=1, as.is=TRUE, quote=', na.strings= ) #solution mat - as.matrix( DF ) v1 - as.vector( na.omit( as.vector( t( mat ) ) ) ) v2 - as.vector( na.omit( as.vector( mat ) ) ) ans1a - matrix( v1, ncol=1 ) ans1b - matrix( v2, nrow=1 ) ans2a - matrix( v2, ncol=1 ) ans2b - matrix( v1, nrow=1 ) On Fri, 12 Oct 2012, Santana Sarma wrote: Hi, Trying to give an example here. Say, I have read in a .csv file using read.csv (), and the file contains the following info. Names Col x Col y Col z rowName1 A E H rowName2 B F I rowName3 C G J rowName4 D K Now, this is what is required: 1. Combine/stack/join contents from - a) multiple rows into one column. That is: A E H B F I C G J D K b) multiple columns into one row. A B C D E F G H I J K 2. Stack contents from A) multiple columns into one column. A B C D E F G H I J K B) Multiple rows into one row. A E H B F I C G J D Thank you. Cheers, Santana On Fri, Oct 12, 2012 at 1:32 PM, David Winsemius dwinsem...@comcast.net wrote: On Oct 11, 2012, at 5:55 PM, Santana Sarma wrote: Hi, Could you please advice some easy way to do the following for a dataframe (header=F) having unequal column- row- length. 1. Combine/stack/join contents from - a) multiple rows into one column. b) multiple columns into one row. 2. Stack contents from multiple columns (or, rows) into one column (or, row). Could _you_ please produce an example. Dataframes do not have headers. They do have column names and column names are required. -- David Winsemius, MD Alameda, CA, USA --- 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 ---__ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 which function
See R FAQ 7.31. --- 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. max u...@maxmetzger.de wrote: Hej, i need the which() funktion to find the positions of an entry in a matrix. the entries i'm looking for are : seq(begin,end,0.01) and there are no empty spaces i'm searching in the right range. so i was looking for the results R can find and i recieved this answer. for (l in 1:length(qr)){print(c(l,nstu[l,1],nsto[l,1],nsto[l,1]-nstu[l,1],(nsto[l,1]-nstu[l,1])*100,which(sp1[,1]==nstu[l,1]),(nsto[l,1]-nstu[l,1])*100+which(sp1[,1]==nstu[l,1]),which(r[,1]==nstu[l,1]),(nsto[l,1]-nstu[l,1])*100+which(r[,1]==nstu[l,1])))} [1] 1 0 0 0 0 [1] 2 0 0 0 0 [1] 3 0 0 0 0 [1]4.00 87.34 87.970.63 63.00 2491.00 2554.00 2491.00 2554.00 [1]5.00 86.73 88.461.73 173.00 2430.00 2603.00 [1]6.00 86.22 88.772.55 255.00 2379.00 2634.00 [1]7.00 85.77 89.013.24 324.00 2334.00 2658.00 [1]8.00 85.36 89.223.86 386.00 2293.00 2679.00 [1]9.0 85.0 89.44.4 440.0 2257.0 2697.0 [1] 10.00 84.68 89.574.89 489.00 2225.00 2714.00 2225.00 2714.00 [1] 11.00 84.38 89.735.35 535.00 2195.00 2730.00 [1] 12.00 84.11 89.885.77 577.00 2168.00 2745.00 [1] 13.00 83.86 90.026.16 616.00 2143.00 2759.00 [1] 14.00 83.64 90.156.51 651.00 2121.00 2772.00 [1] 15.00 83.43 90.286.85 685.00 2100.00 2785.00 2100.00 2785.00 [1] 16.00 83.24 90.407.16 716.00 2081.00 2797.00 [1] 17.00 83.07 90.52 7.45 745.00 [1] 18.00 82.91 90.637.72 772.00 2048.00 2820.00 [1] 19.00 82.76 90.757.99 799.00 2033.00 2832.00 [1] 20.00 82.62 90.868.24 824.00 2019.00 2843.00 2019.00 2843.00 [1] 21.00 82.49 90.978.48 848.00 2006.00 2854.00 [1] 22.00 82.37 91.088.71 871.00 1994.00 2865.00 1994.00 2865.00 [1] 23.00 82.26 91.198.93 893.00 1983.00 2876.00 [1] 24.00 82.16 91.319.15 915.00 1973.00 2888.00 [1] 25.00 82.07 91.429.35 935.00 1964.00 2899.00 [1] 26.00 81.98 91.539.55 955.00 1955.00 2910.00 [1] 27.00 81.90 91.649.74 974.00 1947.00 2921.00 1947.00 2921.00 [1] 28.00 81.83 91.759.92 992.00 1940.00 2932.00 [1] 29.00 81.76 91.87 10.11 1011.00 1933.00 2944.00 [1] 30.00 81.69 91.98 10.29 1029.00 1926.00 2955.00 [1] 31.00 81.63 92.09 10.46 1046.00 1920.00 2966.00 [1] 32.00 81.57 92.20 10.63 1063.00 [1] 33.00 81.50 92.31 10.81 1081.00 1907.00 2988.00 [1] 34.00 81.44 92.43 10.99 1099.00 1901.00 3000.00 [1] 35.00 81.38 92.54 11.16 1116.00 1895.00 3011.00 [1] 36.00 81.31 92.65 11.34 1134.00 1888.00 3022.00 [1] 37.00 81.25 92.76 11.51 1151.00 1882.00 3033.00 [1] 38.00 81.18 92.87 11.69 1169.00 1875.00 3044.00 1875.00 3044.00 [1] 39.00 81.12 92.98 11.86 1186.00 1869.00 3055.00 1869.00 3055.00 [1] 40.00 81.05 93.10 12.05 1205.00 1862.00 3067.00 [1] 41.00 80.99 93.21 12.22 1222.00 1856.00 3078.00 [1] 42.00 80.92 93.32 12.40 1240.00 1849.00 3089.00 [1] 43.00 80.86 93.43 12.57 1257.00 1843.00 3100.00 [1] 44.00 80.79 93.54 12.75 1275.00 [1] 45.00 80.73 93.66 12.93 1293.00 1830.00 3123.00 [1] 46.00 80.66 93.77 13.11 1311.00 1823.00 3134.00 [1] 47.00 80.60 93.88 13.28 1328.00 1817.00 3145.00 [1] 48.00 80.53 93.99 13.46 1346.00 1810.00 3156.00 [1] 49.00 80.47 94.10 13.63 1363.00 1804.00 3167.00 [1] 50.00 80.40 94.22 13.82 1382.00 1797.00 3179.00 1797.00 3179.00 [1] 51.00 80.34 94.33 13.99 1399.00 1791.00 3190.00 1791.00 3190.00 [1] 52.00 80.27 94.44 14.17 1417.00 1784.00 3201.00 [1] 53.00 80.20 94.55 14.35 1435.00 1777.00 3212.00 [1] 54.00 80.14 94.66 14.52 1452.00 1771.00 3223.00 [1] 55.00 80.07 94.77 14.70 1470.00 1764.00 3234.00 [1] 56.00 80.01 94.89 14.88 1488.00 1758.00 3246.00 [1] 57.00 79.94 95.00 15.06 1506.00 1751.00 3257.00 [1] 58.00 79.87 95.11 15.24 1524.00 1744.00 3268.00 1744.00 3268.00 [1] 59.00 79.81 95.22 15.41 1541.00 1738.00 3279.00 [1] 60.00 79.74 95.32 15.58 1558.00 1731.00 3289.00 [1] 61.00 79.67 95.43 15.76 1576.00 1724.00 3300.00 [1] 62.00 79.61 95.54 15.93 1593.00 1718.00 3311.00 [1] 63.00 79.54 95.65 16.11 1611.00 [1] 64.00 79.47 95.76 16.29 1629.00 1704.00 .00 [1] 65.00 79.41 95.87 16.46 1646.00 1698.00
Re: [R] Filtering few column from one data frame based on another data frame
I suggest you go back to the Introduction to R document supplied with the software and read about indexing. In particular, pay attention to indexing into a matrix or data frame using data1[rowspec,columnspec] syntax. There are three kinds of row and column specification types, and any of the the three can be used to solve your problem. --- 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. siddu479 onlyfordigitalst...@gmail.com wrote: Dear R-Users and experts, This is my first post in this forum. I have two csv files file1 and file2. file1(many rows and columns) is read into dataframe *data1* File2 is read into dataframe *data2* which have only one column of data which contains the column names that need to be removed from dataframe *data1*columns and update the *data1 *data frame. Example: data1 -read.csv(file1...,header=T) Sno,Data_1,Data_2,Data_3 1,2,3,4 data2- read.csv(file2,..header=F) Data_2 Data_3 The output *data1.new* data frame should be like this Sno,Data_1 1,2 So I request the R code to accomplish this task. Regards Sidda -- View this message in context: http://r.789695.n4.nabble.com/Filtering-few-column-from-one-data-frame-based-on-another-data-frame-tp4646072.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] stop at error point in for-loop
options(error = recover) --- 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. mrzung mrzun...@gmail.com wrote: hi all: Following is simple example, for(i in 1:1000){ a-function(i){ #some function that has an error } } What I want to know is the way to find the error point in for-loop, What i makes the error. is there any way to solve it instead of debugging and finding an error manually? Thanks, -- View this message in context: http://r.789695.n4.nabble.com/stop-at-error-point-in-for-loop-tp4646115.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] transforming a .csv file column names as per a particular column rows using R code
Not clear to me what your successive rows indicate in your output. However, you may get something similar to what you want using the reshape2 library: library(reshape2) dta1 - read.csv( text= Tool,Step_Number,Data1,Data2 A,1,0,1 A,2,3,2 A,3,2,3 B,1,3,2 B,2,1,2 B,3,3,2 ) # put into long form dta1l - melt(dta1,c(Tool,Step_Number)) # re-cast to wide form # assuming first row is for tool A, second row is for tool B, etc. dta2 - dcast(dta1l,Tool~variable+Step_Number) On Sun, 14 Oct 2012, siddu479 wrote: Hello all, I have a .csv file like below. Tool,Step_Number,Data1,Data2... etc up to 100 columns. A,1,0,1 A,2,3,1 A,3,2,1 . . B,1,3,2 B,2,1,2 B,3,3,2 . . .. so on upto 50 rows where the column *Tool* has distinct steps in second column *Step_Number*,but both have same entries in Step_Number column. I want the output like below. Tool_1,Data1_1,Data2_1,Tool_2,Data1_2,Data2_2,Tool_3,Data1_3,Data2_3... so on A,0,1,A,3,1,A,2,1 B,3,2,B,1,2,B,3,2 .. so on. basically I am transposing entire data based on a specific column row values and renaming the column headers. I have a shell script based on awk which can do this task, but the script is taking exceptionally higher processing time. So I am looking for a script in R which can save the time. Please revert to me if the problem description is not clear. Regards Sidda - Sidda Business Analyst Lead Applied Materials Inc. -- View this message in context: http://r.789695.n4.nabble.com/transforming-a-csv-file-column-names-as-per-a-particular-column-rows-using-R-code-tp4646137.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. --- 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 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] how to show iterations
Optimization is not something R does... this is something implemented by specific functions that may be in the base install or in add-on packages, but you have not indicated how you are currently approaching your problem. If you are using the optim() function, then I refer you to the fine manual under the control argument. Type ?optim at the R command line. For advice on how to communicate clearly on the topic of R, I recommend that you also read http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example before posting again. On Sun, 14 Oct 2012, sffarooqi wrote: Hi, I am new to R, and am working on some optimization problems - I was wondering if there was a way that I could show all the iterations in R -i.e. showing for each iteration, what the iteration is, how much the function is, what the norm of the gradient would be... Any help is greatly appreciated! thank you!! -- View this message in context: http://r.789695.n4.nabble.com/how-to-show-iterations-tp4646133.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. --- 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 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Date Math
There are a few ways. The xts package has a lag function. So does zoo. Pay careful attention to the conventions used for specifying relative time in these various packages. You can also infill your missing data to create a regularly-spaced time series. There is no shortage of web information about this topic... you can start at the Time Series task view on CRAN or just use a search engine. On Sun, 14 Oct 2012, Noah Silverman wrote: Hello, I have a time series object (xts) that I iterate over in a loop. Works fine. My challenge is that I want to be able to reference other entries in the series by math. i.e. For today's observation, what were the last 5 observations? If indexed numerically, it is trivial, but I can figure out how to do this with dates. This is slightly more difficult as there may not be an observation for every day. So I might want the last 5 that exist in the table, not the last 5 calendar days. ideally, it would be something like this. observations[ index(today)-5:today, ] However that obviously fails. Ideas? -- Noah Silverman, M.S. 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. --- 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 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Is there any R package that contains Rusboost based on Adaboost.m2?
May I suggest you use a more appropriate tool for your search: RSiteSearch(multiclass classification) On Sun, 14 Oct 2012, Carlos Andrade wrote: Hi, I have been searching everywhere for an implementation of those algorithms, but I have only observed them in Matlab and on the literature. I noticed a package called 'ada' in CRAN but it is not for multi class. I would be happy with just Adaboost.m2, Smoteboost over adaboost.m2 or any other combination that could account for imbalanced multiclass classification problems. Thanks! Carlos Andrade http://carlosandrade.co [[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. --- 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 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Is there any R package that contains Rusboost based on Adaboost.m2?
Asking questions and giving answers about R is what this mailing list is about. It is not really a theory list. If you understand the theory you can search among the libraries yourself. But when the first search I make brings up what to me looks like the answer to your question, then you either did not search before posting or you did not clarify what you were really looking for properly. --- 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. Carlos Andrade carlosvia...@gmail.com wrote: Dear Jeff Newmiller, Thanks for the suggestion I did not know the website but the problem is more dry than simple multiclass classification. In fact, there are even few papers addressing the problem. I was in hope that if not yet available in CRAN someone from the R community could point out any 'pre release' version of it. I hope it is inappropriate to ask such questions here. Thanks, Carlos Andrade http://carlosandrade.co 2012/10/14 Jeff Newmiller jdnew...@dcn.davis.ca.us May I suggest you use a more appropriate tool for your search: RSiteSearch(multiclass classification) On Sun, 14 Oct 2012, Carlos Andrade wrote: Hi, I have been searching everywhere for an implementation of those algorithms, but I have only observed them in Matlab and on the literature. I noticed a package called 'ada' in CRAN but it is not for multi class. I would be happy with just Adaboost.m2, Smoteboost over adaboost.m2 or any other combination that could account for imbalanced multiclass classification problems. Thanks! Carlos Andrade http://carlosandrade.co [[alternative HTML version deleted]] __** 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. --**--** --- 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 --**--** --- __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Date Math
?embed --- 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. Noah Silverman noahsilver...@ucla.edu wrote: Jeff, My understanding is that the lag command will lag an entire time series. That isn't what I'm looking for. I just want, for example, today, and 5 entries back. for exmple: iter - '2011-05-18' observations[iter] # works fine, returns the row at that date. index(observations[iter[) # just returns the iter back index(observations[iter]) - 5 # returns 2011-05-17 23:59:57 PDT, so it subtracted 3 seconds. really, I want to find: iter- 5 days. -- Noah Silverman Smart Media Corp. On Oct 14, 2012, at 10:29 AM, Jeff Newmiller jdnew...@dcn.davis.ca.us wrote: There are a few ways. The xts package has a lag function. So does zoo. Pay careful attention to the conventions used for specifying relative time in these various packages. You can also infill your missing data to create a regularly-spaced time series. There is no shortage of web information about this topic... you can start at the Time Series task view on CRAN or just use a search engine. On Sun, 14 Oct 2012, Noah Silverman wrote: Hello, I have a time series object (xts) that I iterate over in a loop. Works fine. My challenge is that I want to be able to reference other entries in the series by math. i.e. For today's observation, what were the last 5 observations? If indexed numerically, it is trivial, but I can figure out how to do this with dates. This is slightly more difficult as there may not be an observation for every day. So I might want the last 5 that exist in the table, not the last 5 calendar days. ideally, it would be something like this. observations[ index(today)-5:today, ] However that obviously fails. Ideas? -- Noah Silverman, M.S. 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. --- 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 --- -- Noah Silverman, M.S. 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] Chopping a two column data frame by rows into a three dimensional array.
aperm(array(dat,c(10,10,2)),c(1,3,2)) --- 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. Hans Thompson hans.thomps...@gmail.com wrote: If I have a two column data frame like: dat - cbind(x=c(1:100),y=c(100:1)) How can I create an array that splits every ten rows of that data frame into a third dimension of an array so that: newarray[,,1] ,,1 x y 1 100 2 99 3 98 ... ... 10 91 ,,2 xy 11 90 12 89 ... ... ... 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] time extraction and normalization
There are multiple ways. For lack of your example, I would suggest multiplying by 24. Please post the previous context of the thread if you must post from Nabble. --- 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. york8866 yu_y...@hotmail.com wrote: Thanks, The code gives the numbers in days, how can I adjust the code to directly get the numbers in hours? I tried units but it did not work. Thanks1 -- View this message in context: http://r.789695.n4.nabble.com/time-extraction-and-normalization-tp4646275p4646298.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] Windows 7 R (32/64bit) running under cygwin: package not found
Probably because when you run it from Cygwin the R_LIBS variable does not point to the user and install library directories. I don't know how Rgui knows where they are (registry?) but you can look in the .Library and .Library.site variables to see the results. In a case like this, posting your sessionInfo() for each case is highly recommended. --- 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. Aldi Kraja a...@wustl.edu wrote: Hi, Using R 2.15.1 on Windows 7. Have installed both versions 32 and 64bit. In both of them among others I have installed a package rgenoud When I open R gui of 32bit and write library(rgenoud) it responds by showing a functional rgenoud version 5.7-8. The same it does on Rgui 64bit. Now I am working in cygwin (v. 1.12.4.0) with xwin. Normally before when I had installed a package, I only had to call the library with the name of the package and R will find the right one to load. Now when I apply R CMD BATCH script1.R out1.txt, under cygwin the first thing it reports: R version 2.15.1 (2012-06-22) -- Roasted Marshmallows After some generalities it reports library(rgenoud) Error in library(rgenoud) : there is no package called 'rgenoud' Execution halted So my question is why under cygwin in a batch mode, it does not find the installed package, which is already installed in my laptop's R? Thank you in advance, Aldi __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] how to concatenate factor vectors?
mood - factor(c(blue, sunny)) skycolor - factor(c(azure,blue,teal) If factors are not defined with levels specifications, automatic merging should never be allowed. The fact that read.table automatically generates factors using default levels is why I nearly always import using as.is=TRUE, perform QC and combining of sources using strings, and only then convert to factor. If you HAVE defined your factors using explicit levels definitions, you should have no trouble combining them. --- 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. Sam Steingold s...@gnu.org wrote: * Bert Gunter thagre.ore...@trar.pbz [2012-10-17 23:21:44 -0700]: However, Is level 5 in 'a' the same as level 5 in 'b' ? yes, of course. would anyone want to _different_ factors with identical string representations?! __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] system.time question
You asked several questions. Elapsed: yes User + System = CPU: yes Finally: You have to look at the load and/or cpu core count. Unless you setup your code to take advantage of multiple cores, R runs on a single core. Also: Do you really need to ask that question? --- 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. Mark Leeds marklee...@gmail.com wrote: Hi : I looked at the help for system.time but I still have the following question. Can someone explain the output following output of system.time : user system elapsed 12399.681 5632.352 56935.647 Here's my take based on the fact that I was doing ps -aux | grep R off and on and the total amount of CPU minutes that got allotted before the job ended was about 5 hours and the total actual time that the job took was about 15 hours. Does elapsed = total actual time job taken ? That seems to be the case or a strange coincidence. Does user + system = CPU time from ps -aux | grep R ? That seems to be the case also or a weird coincidence. Finally, why can't the CPU get a higher percentage ? It's seems like it's always around 30% which would make sense since 5 is ~ 30% of 15 hours. Also, assuming my take above is correct, when talking about timing of algorithms, in this case, does one say the job took 5 hours or 15 hours ? I'm trying to see how fast an algorithm is compared to others and I'm not sure what the standard is. I'm on fedora 16.0 and using R 2.15. 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 integrate(integrand, 0, Inf) : non-finite function value
That is an intrinsic part of nonlinear optimization. Choose your starting point wisely. --- 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. stats12 ska...@gmail.com wrote: Hi, Thank you for your comment. I worked on the code again and was able to make it work. The only problem I am having right now is that nlm depends on the initial value. When the initial value is 1, I get the following estimates 0.1230414 19.6271029 when it is 2, I get the following 29.46874 20.01679 d-matrix(c(1,1,0,0,0,0,0,0,2,1,0,0,1,1,0,1,2,2,1,0),nrow=10,ncol=2) h-matrix(runif(20,0,1),10) delta-matrix(c(2,1,0,1,0,1,0,0,2,1,0,0,1,1,1,1,0,2,1,0),nrow=10,ncol=2) out-vector(numeric,length(1:2)) integ-vector(numeric,length(1:10)) for (k in 1:2){ ll-function(p){ cmh-delta[,k]*(h[,k]*log(0.5))+p*log(gamma(1+1/p)) for(s in 1:10){ integrand-function(x) x^d[s,k]*exp(-x*gamma(1+1/p))^p*p*x^(p-1)*exp(-x*h[s,k]) integ-integrate(integrand,0,Inf)$value return(integ) } lik-sum(cmh+log(integ)) -lik } initial-c(1) t-nlm(ll,initial) out[k]-t$estimate } est-as.vector(out) -- View this message in context: http://r.789695.n4.nabble.com/Error-in-integrate-integrand-0-Inf-non-finite-function-value-tp4646868p4646896.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] [Vars] package: impulse response function
Read the posting guide. We have no way to know what you are doing unless you show the list readers with sample data and code. If you are wondering about Vector Autoregressive models, I don't claim any specific experience with them, but [1] says they are linear, and I do know that linear models respond in proportion to the magnitude of the input so you don't learn anything useful by changing the magnitude of the input. I have used the Kronecker delta (impulse) function before, and I have never heard of anyone trying to ascribe a standard deviation to it... only impulse magnitude. [1] http://en.m.wikipedia.org/wiki/Vector_autoregression --- 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. Maria Grigoryeva mm.grigory...@gmail.com wrote: Hello, I'm doing a research on the impulse responses in VAR models and I'm having troubles in interpretation of R results. My question is what is the shock of impulse variable that is produced to obtain the response? Is it one-standard-deviation positive shock? If it is so how can I obtain the responses on other types of shocks, say, 10% negative shock? Thanks a lot, Marion [[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] daylight
library(maptools) ?sunriset --- 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. bambus sonja_...@hotmail.com wrote: hi there, does anyone know how to calculate the amount of daylight on every day of the year in R? I mean the time between sunrise and sunset. thanks -- View this message in context: http://r.789695.n4.nabble.com/daylight-tp4647213.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] incomplete final line found by readTableHeader
Keep in mind that this is NOT a homework support list... you are supposed to use the support provided by your educational institution if you are in a course. Read the posting guide mentioned in the footer of every email. FWIW, as described your problem is with Excel, and this is not an Excel support list either. I suggest that you edit the csv file with a text editor (e.g. NotePad) to make sure the correct number of commas are on each line of the data file. --- 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. Shane2012 wenbo...@live.cn wrote: Hello, I am trying to read in an Excel file that I saved as a .csv so I can analyze my assignment data! I am getting really frustrated because this is what I keep getting: Warning message: In read.table(CityData.CSV, sep = /, header = T) : incomplete final line found by readTableHeader on 'CityData.CSV' I have open the file and make sure click return after the last line, then save the file. I try to use kinds of read data frame methods, such as read.table read.csv or my.files - list.files(path) for(i in my.files) { nam - paste(CityData, substr(i, 14, 15), sep ='') assign(nam, read.csv(i)) } - They all failed. Can anyone offer some help? Thanks a lot! -- View this message in context: http://r.789695.n4.nabble.com/incomplete-final-line-found-by-readTableHeader-tp4647259.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] Results not dispalying in R console
wow. That sounds like a problem. For a more constructive response, read the posting guide and post specific examples and explain how the output you get is not what you expect. Also, the output of sessionInfo() is likely to be helpful, and if you use a Mac, or Debian/other Linux, one of the platform-specific email lists might be a more appropriate forum. --- 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. arunkumar akpbond...@gmail.com wrote: Hi I'm not getting any results in R console when i run commands. I reinstalled R but the results are same - Thanks in Advance Arun -- View this message in context: http://r.789695.n4.nabble.com/Results-not-dispalying-in-R-console-tp4647271.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] Merge matrices with different column names
If they have the same number of rows, you can use cbind() to create one object to write out. --- 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. Charles Determan Jr deter...@umn.edu wrote: A general question that I have been pursuing for some time but have set aside. When finishing some analysis, I can have multiple matrices that have specific column names. Ideally, I would like to combine these separate matrices for a final output as a csv file. A generic example: Matrix 1 var1A var1B var1C x x x x x x Matrix 2 var2A var2B var2C x x x x x x I would like a final exportable matrix or dataframe or whichever format is most workable. Matrix 3 var1A var1B var1C x x x x x x var2A var2B var2C x x x x x x However, no matter which function I try reports an error that the column names are not the same. Any insights would be appreciated. Thanks as always, Charles [[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] SQL via RODBC
That would be very implementation-specific, and ODBC is generic in its own way. No, you must run one query at a time in general, and deal with the results using the procedural language. Keep in mind that you have to pick a back-end database to work with, and for creating the database you may have tools available that can directly process that sql file once. Then you can use a small number of queries from within R to retrieve data at will. If the file contains data queries whose output you want to process in R, they have to be handled one-by-one. --- 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. Dr. Alireza Zolfaghari ali.zolfagh...@gmail.com wrote: Hi list, Is there a way to use sqlQuery function where there is a sql file (ie. sample.sql)? I just want to mention that in my sql file there are some comment lines (starting with --). This means that if I paste all the lines in the sql file, I'll come up with a long string that most part of it is commneted (after commnet sign --). thanks Arvin [[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] asking about R Code
You seem to be quite lost. You should execute one statement at a time, and troubleshoot from there. I suspect that your attempts to get your file in the right place went wrong, or the file is the wrong type of file for that function (regardless of the name you gave it). As for giving you an explanation about read.pnm, I would rather not. There is documentation available on any library function using the ? command in R, e.g. ?read.pnm You should not have to replace files with other files in order to read them... you should be able to specify another name within the quotes. You may learn a bit about your current directory by using the getwd() function and the list.files() function. Once you have successfully read in the data, you can learn more about the object by following the useful hyperlinks in the documentation for read.pnm. I highly recommend reading the Introduction to R pdf that is supplied with your R software, and then reading the posting guide mentioned at the bottom of any email on this list. If your project is of an academic nature, the posting guide will remind you that this is not the place to ask homework questions... that is for you to obtain from your educational institution. --- 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. Ellen Praman ellen.praman...@yahoo.com wrote: Hi, my name is Ellen. I want to ask you about R Code. I got a code for extracting a pixel value, but I can't compile it..� It is said Error in is.data.frame(x) : object 'lena' not found Here is the original full code: library(pixmap) lena - read.pnm(oldlennablur.pgm) write.table(lena@grey,mylenna, quote=FALSE, row.names = FALSE, col.names= FALSE) plot(pixmapGrey(as.matrix(read.table(mylenn do you know why i got the error? i have change the�oldlennablur.pgm with the one i have and also with the specified path on my computer..| And would you like give me an explanation about read.pnm. I need to know what result will i get using this syntax. Does this syntax give us a 256x256 matrix if we input the 256x256 pixels image? I will use the data for my project, so I need to know how and what the data i would get.. Thank you very much..� [[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] Openbugs- Array Index
You seem to be lost. Try http://mathstat.helsinki.fi/openbugs/community/CommBBS.html --- 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. SuzieK suzanne.f.ke...@hotmail.co.uk wrote: Hi, I'm working on the codes below however every time I run them when they get to OpenBUGS I keep getting the error message: array index is greater than array upper bound for hab. Any help would be greatly appreciated, Suzie Codes: ungulate - read.csv(file.choose ()) #ungulate ungulate - as.matrix(ungulate);colnames(ungulate)-NULL;rownames(ungulate)-NULL habitat - read.csv(file.choose ()) #ungulate habitat habitat - habitat[,3] site.data - read.csv(file.choose ()) #ungulate site site - site.data$SiteId visit - site.data$visit date - site.data$date date - matrix(date,nrow=4,ncol=5,byrow=TRUE) S - dim(ungulate)[1] # set dimension forungulate i.e. number of species m - 6 # number of augmented species G - read.csv(file.choose ()) # ungulate group G - G[,2] g - rep(NA,length=m) G - c(G,g) g - length(table(G))# number of groups # habitat id Hab - cbind(seq(1,4),habitat) hab - matrix(NA,nrow=3,ncol=2) #make a matrix with 4 rows and two colums for the four sites with 2 different habitat types has NA values?? for(i in 1:2){ hab[i,] - Hab[habitat==i,1] } # arrange bird data S - dim(ungulate)[1]# number of collected species in our case Y - array(NA,dim=c(S,4,5)) for(i in 1:S){ Y[i,,] - matrix(ungulate[i,],nrow=4,ncol=5,byrow=TRUE) } AY - array(NA,dim=c((S+m),4,5))# Y of augmented for(i in 1:4){ y - matrix(0,nrow=m,ncol=5) AY[,i,] - rbind(Y[,i,],y) } ## bugs code library(R2OpenBUGS) sink(ungulate.txt) cat( model{ # hyperparameters # habitat effects for each functional group for(i in 1:g){ # number of functional group for(j in 1:2){ # number of habitat type mu.h[i,j] ~ dnorm(0,0.0001) I(-2,2) # filling mu.h with values based on a random distribution sigma.h[i,j] ~ dunif(0,6) tau.h[i,j] - 1/(sigma.h[i,j]*sigma.h[i,j]) } } # detectability mu.r ~ dnorm(0,0.0001) I(-3,3) sigma.r ~ dunif(0,6) tau.r - 1/(sigma.r*sigma.r) psi ~ dunif(0,1)# inclusion rate that generates wi # proportion of number of species among groups for(i in 1:g){ prop[i] ~ dgamma(1,1) prob[i] - prop[i]/sum(prop[]) } for(i in 1:(S+m)){ r[i] ~ dnorm(mu.r,tau.r) I(-2,2)# generating parameters related to detectability p[i] - 1/(1+exp(-(r[i])))# individual-level detection probability w[i] ~ dbern(psi)# indicator variable whether each species is exposed to sampling or not G[i] ~ dcat(prob[1:g])# group identity for(h in 1:2){# habitat effects habitat.eff[i,h] ~ dnorm(mu.h[G[i],h],tau.h[G[i],h]) I(-2,2) } for(j in 1:4){# fitting process # ecological process model lambda[i,j] - exp(habitat.eff[i,habitat[j]]) Z[i,j] ~ dpois(lambda[i,j])# latent abundance of each species at each site at each visit A[i,j] - Z[i,j]*w[i]# latent abundance only for species exposed to sampling for(v in 1:5){ # detection process model AY[i,j,v] ~ dbin(p[i],A[i,j]) } } # group identity (indicator variable) G1[i] - equals(G[i],1) G2[i] - equals(G[i],2) } for(i in 1:(S+m)){ for(j in 1:4){ A1[i,j] - A[i,j]*G1[i] A2[i,j] - A[i,j]*G2[i] O[i,j] - step(A[i,j]-1)# latent occupancy of each species for each site O1[i,j] - O[i,j]*G1[i] O2[i,j] - O[i,j]*G2[i] } } for(j in 1:4){ AB0[j] - sum(A[,j]) AB1[j] - sum(A1[,j]) AB2[j] - sum(A2[,j]) SpR0[j] - sum(O[,j]) SpR1[j] - sum(O1[,j]) SpR2[j] - sum(O2[,j]) } for(i in 1:2){ for(j in 1:4){ HabAB0[i,j] - AB0[hab[i,j]] HabAB1[i,j] - AB1[hab[i,j]] HabAB2[i,j] - AB2[hab[i,j]] HabSpR0[i,j] - SpR0[hab[i,j]] HabSpR1[i,j] - SpR1[hab[i,j]] HabSpR2[i,j] - SpR2[hab[i,j]] } HAB0[i] - mean(HabAB0[i,]) HAB1[i] - mean(HabAB1[i,]) HAB2[i] - mean(HabAB2[i,]) HSpR0[i] - mean(HabSpR0[i,]) HSpR1[i] - mean(HabSpR1[i,]) HSpR2[i] - mean(HabSpR2[i,]) } R - sum(w[1:(S+m)])# estimating unknown number of species that occupy any sites } ,fill=TRUE) sink() data - list(m,S, habitat, G,g, #date, hab, AY) inits - function()list( mu.h=matrix(rnorm(g*2),nrow=2),sigma.h=matrix(runif(g*2),nrow=2), mu.r=rnorm(1),sigma.r=runif(1), r=rnorm(S+m), prop=runif(n=g,min=0,max=5), Z=array(rpois(n=(S+m)*4,lambda=2),dim=c((S+m),4)), w=rep(1,(S+m)),psi=runif(1)) parameters - c( mu.h,sigma.h, habitat.eff, mu.r,sigma.r, r, R,psi, A, O, HAB0,HAB1,HAB2, HSpR0,HSpR1,HSpR2 ) out - bugs(data,inits,parameters,ungulate.txt
Re: [R] using match-type function to return correctly ordered data from a dataframe
Have you actually read ?%in% ? Although a valuable tool, not all answers are most effectively obtained by Googling. Also, your repeated assertions that the answers are not maintained in order are poorly framed. They DO stay in order according to the zipcode database order. That said, your desire for numeric indexes is only as far away as your help file. --- 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. Markus Weisner r...@themarkus.com wrote: I am regularly running into a problem where I can't seem to figure out how maintain correct data order when selecting data out of a dataframe. The below code shows an example of trying to pull data from a dataframe using ordered zip codes. My problem is returning the pulled data in the correct order. This is a very simple example, but it illustrates a regular problem that I am running into. In the past, I have used fairly complicated solutions to pull this off. There has got to be a more simple and straightforward method ... probably some function that I missed in all my googling. Thanks in advance for anybody's help figuring this out. ~Markus ### Function Definitions ### # FUNCTION #1 (returns wrong order) getLatitude1 = function(myzips) { # load libraries and data library(zipcode) data(zipcode) # get latitude values mylats = zipcode[zipcode$zip %in% myzips, latitude] #problem is that this code does not maintain order # return data return(mylats) } # FUNCTION #2 (also returns wrong order) getLatitude2 = function(myzips) { # load libraries and data library(zipcode) data(zipcode) # convert myzips to DF myzips = as.data.frame(as.character(myzips)) # merge in zipcode data based on zip results = merge(myzips, zipcode[,c(zip, latitude)], by.x = as.character(myzips), by.y=zip, all.x=TRUE) # return data return(results$latitude) } ### Code ### # specify a set of zip codes myzips = c(74432, 72537, 06026, 01085, 65793) # create a DF myzips.df = data.frame(zip=myzips, latitude=NA, longitude=NA) # look at data to determine what should be returned and in what order library(zipcode) data(zipcode) zipcode[zipcode$zip %in% myzips,] # test function #1 (function definition below) myzips.df$latitude = getLatitude1(myzips.df$zip) #returns wrong order # test function #2 (function definition below) myzips.df$latitude = getLatitude2(myzips.df$zip) #also returns wrong order # need myzips %in% zipcode$zip to return array/df indices rather than logical [[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] help install RExcel
For RExcel support, see http://rcom.univie.ac.at, where they have various support options including a mailing list. --- 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. tt tiziano.fiore_1...@libero.it wrote: Hello, I just installed RExcel but I have some problems. I am writing you the set of commands that I used: install.packages(RExcelInstaller, rcom, rsproxy) library(rcom) comRegisterRegistry() library(RExcelInstaller) installstatconnDCOM() installRExcel() But when I select RStart from add-ins I see this written No R server configured. Please set Rserver to work with RExcel. I am using excel 2010. Can you help me? Thanks -- View this message in context: http://r.789695.n4.nabble.com/help-install-RExcel-tp4647653.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] keep average values and delete duplicate rows
Please read the posting guide... this is not a homework help line. --- 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. fuckecon iamsta...@gmail.com wrote: Hello experts, I am sorry that my subject line is confusing, because I am confused as nuts. Let me take a shot at explaining what I am trying to do. I have a data set of log GDP, education, democracy index, and a whole bunch of variables for every country from 1950 to 2000. Each country accounts for 10 observations with each observation representing the mean GDP for each 5 year interval. Example: Country log GDP yr Canada 9.115211 1950 Canada 9.205848 1955 Canada 9.247975 1960 Canada 9.429002 1965 Canada 9.554069 1970 Canada 9.719351 1975 Canada 9.851376 1980 Canada 9.937892 1985 Canada 10.01457 1990 Canada 10.04093 1995 Canada 10.20005 2000 USA 9.278241950 USA 9.389681955 USA 9.415136 1960 USA 9.594625 1965 USA 9.702071970 USA 9.800418 1975 USA 9.968131980 USA 10.07001 1985 USA 10.18331 1990 USA 10.25446 1995 USA 10.41312000 For log GDP: I want to create a new object in R with one line for each country and the average log GDP from the 10 5yr interval observations. With the subset I want to then create a table with 3 columns and 4 rows. (I have no idea how to write the codes to create the new object. Friend said something about conditional median.) Columns 1) All countries 2) High income countries 3) Low income countries Rows 1) Democracy index 2) Log GDP 3) Obs 4) Countries To create a high and low income columns, I am using the median as the boundary. (i.e. high income for gdp median of the mean for each country, low income for gdp = median of the mean for each country.) I hope someone can understand what I am writing here and help me out with it. Thanks so much! -- View this message in context: http://r.789695.n4.nabble.com/keep-average-values-and-delete-duplicate-rows-tp4647677.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] Having some Trouble Data Structures
Search on ragged array. My preferred approach is to use a data frame with one row per effector that repeats the per-ID information. If that occupies too much memory, you can setup another data frame with one row per ID and refer to that information as using lapply and subset the effectors data as needed. The plyr package is also useful for such processing. --- 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. Benjamin Ward (ENV) b.w...@uea.ac.uk wrote: Hi All, I'm trying to run a simulation of host-pathogen evolution based around individuals. What I need to have is a dataframe or table of some description - describing all the individuals of a pathogen population (so far I've implemented this as a matrix): ID No_of_Effectors Effectors (Sequences) [1,] 0001 3 ## 3 Random Numbers ## There will be many such rows for many individuals. They have something called effectors, the number of which is randomly generated, so say you get 3 in the No_of_Effectors column. Then I make R generate 3 numbers from between 1 and 10,000, this gives me three numerical representations of genes. These numbers will be compared to a similar data structure of the host individuals who have their immune genes with similar numbers. My problem is that obviously I can't stick 3 numbers in one cell of the matrix (I've tried) : Pathogen_Individuals[1,3] - c(2,3,4) Error in Pathogen_Individuals[1, 3] - c(345, 567, 678) : number of items to replace is not a multiple of replacement length In future I'm also going to have more variables such as whether a gene is expressed. Such information may require a matrix in itself - something like: Effector ID Sequence Expressed? [1,] 0001 345,567,678 1 (or 0). Is there a way then I can put more than one value in the cell like a list of values, or a way to put objects in a cell of a data frame, matrix or table etc. Almost an inception deal - data structures nested in a data structure? If I search for things like insert list into matrix I get results like how to turn one into another, which is not what I think I need to be doing. I have been considering having several data structures not nested in each other, something like for every individual create a new matrix object with the name Effectors_[Individual_ID] and some how get my simulation loops operating on those objects but I find it hard to see how to tell R all of those matrices are to be included in an operation, as you can all lines of a data frame for example with for loops. This is strange for me because this model was written in a macro-code for another program which handles data in a different format and layout to R. My problem is I think, each individual in the model has many variables - in this case representations of genes. So I'm having trouble getting my head about this. Hopefully someone more experienced will be able to offer advice or a solution, it will be very appreciated. Many Thanks, Ben Ward (ENV, UEA The Sainsbury Lab, JIC). P.S. I have searched previous queries to the list, and I'm not sure but this may be useful for relevant: Have you thought of using a list? a - matrix(1:10, nrow=2) b - 1:5 x - list(a=a, b=b) x $a [,1] [,2] [,3] [,4] [,5] [1,]13579 [2,]2468 10 $b [1] 1 2 3 4 5 x$a [,1] [,2] [,3] [,4] [,5] [1,]13579 [2,]2468 10 x$b [1] 1 2 3 4 5 oliveoil and yarn datasets have been mentioned. [[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] PROBLEMS INSTALLING LIFEMETRICS
If your goal is to use Excel with R, or if you are having difficulty getting Lifehacker to work with Excel, perhaps you should go to http://rcom.univie.ac.at/. You don't need Lifehacker to use Excel with R, though (as you stated your problem). That just needs Statconn (which is off topic here). --- 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. mary marisa_cipri...@hotmail.it wrote: I am trying to install lifemetrics to use excel with R. Is there anyone who knows lifemetrics and can help me to install it? -- View this message in context: http://r.789695.n4.nabble.com/PROBLEMS-INSTALLING-LIFEMETRICS-tp4647717.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] find the Best-ticker
This is not a question about R, but rather about quantitative financial analysis theory that could be applied using any of many different computational tools. As such this question is off-topic here. --- 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. sheenmaria sheenmar...@gmail.com wrote: i need to find the best ticker from the group of some tickers.? i also need to know on what basis we calculate the best ticker? i have some idea about the if the risk rate low, or the market price high we can say the ticker is best. but i dont know is it true. Anyone can help me . Thank you -- View this message in context: http://r.789695.n4.nabble.com/find-the-Best-ticker-tp4647734.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] changing date by +/- days
I try to use difftimes as much as possible. For example, oneday - as.difftime( 24, units=hours ) sometime - 10 * oneday You might also find the lubridate package useful. --- 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. chuck.01 charliethebrow...@gmail.com wrote: got it, sorry! structure(1243792800, class = c(POSIXct, POSIXt), tzone = GMT)-(60*60*24*10) chuck.01 wrote Hi, Let say I have a date variable like this: structure(1243792800, class = c(POSIXct, POSIXt), tzone = GMT) [1] 2009-05-31 18:00:00 GMT How can I make it 10 days prior, so: [1] 2009-05-21 18:00:00 GMT I'm randomly selecting dates from a list and want a second value a set # of days either before or after. Thanks ahead of time. -- View this message in context: http://r.789695.n4.nabble.com/changing-date-by-days-tp4647803p4647804.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] Interaction
I thought addition was commutative. I am puzzled by your question. --- 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. Silvano Cesar da Costa silv...@uel.br wrote: Hi, I'm fitting a model with 3 variables: A, B and SNP. The response variable is Y. I would like fit the following model, in this order: Y ~ A + B + A*B + SNP In general, the R sets of the form: Y ~ A + B + SNP + A*B How do this? - Silvano Cesar da Costa Universidade Estadual de Londrina Centro de Ciências Exatas Departamento de Estatística Fone: (43) 3371-4346 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 unary operator
a) not reproducible, read the posting guide b) there is actually a forum dedicated to ggplot2 where you would get better answers c) I have not had luck providing an expression as the data argument to ggplot. --- 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. Jean Jang jeanwaij...@gmail.com wrote: Hi R - listers, I am receiving an error. Does anyone know what this means? J ggplot(subset(foo, Rayos != Rayos.NA), aes(x=HTL, y=DevelopIndex, colour=TotalEggs)) +geom_point() +geom_jitter() + facet_grid(Aeventexhumed ~ Rayos) + geom_smooth(method=lm, fill=NA) + ylim(c(0, 7)) Error in +geom_smooth(method = lm, fill = NA) : invalid argument to unary operator [[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] box() doesnt work
Not without reproducible code and data. --- 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. penguins cat...@bas.ac.uk wrote: Hi, when plotting a graphic i find that the surrounding box disappears if I adjust the margins with par(mar=..). Ive tried reassigning it with box() but it doesnt seem to make any difference. Does anyone know a way to overcome this? Thanks in advance -- View this message in context: http://r.789695.n4.nabble.com/box-doesnt-work-tp4647909.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] sqlFetch doesn't read the whole objects.
Not reproducible, not even close. Other than saying 600 is not a magic limit in R, not much help can be given. --- 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. happyji e...@bcm.edu wrote: Hi everyone, I connected a data in FileMaker server with odbcConnect. When I call the data CANCERS using sqlFetch, it looks okay. However, the number of obs was different with the actual number. If I read the same data from Microsoft Access, there are 656 obs. in it but srt() shows me 600 obs. Does anyone know why this happened and how to read all obs. from R? Thank you in advance. EJ psb-odbcConnect(PSB,uid=XXX,pwd=XXX) cancers-sqlFetch(psb,CANCERS) str(cancers) 'data.frame': 600 obs. of 5 variables: $ study_id : int 7 152 11 12 3 14 16 22 23 24 ... $ cancer_type: Factor w/ 121 levels Breast cancer ,..: 15 24 65 NA 45 16 73 46 23 66 ... $ cancer_age : Factor w/ 70 levels 17,1968,1983,..: NA 14 31 NA 58 NA NA 38 NA 35 ... $ cancer_recs: num 656 656 656 656 656 656 656 656 656 656 ... $ cancer_year: Factor w/ 43 levels 1/2003,12/05,..: 34 34 NA 34 NA 34 26 NA 34 34 ... -- View this message in context: http://r.789695.n4.nabble.com/sqlFetch-doesn-t-read-the-whole-objects-tp4647943.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] POSIXct date missing time component
Rather than altering your data, it is better to use the same date time format at all times, and specify it explicitly when converting to or from character. --- 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. chuck.01 charliethebrow...@gmail.com wrote: I did not read that close enough; thanks again. arun kirshna wrote Hi, ?as.POSIXct() format: character string giving a date-time format as used by ‘strptime’. ?strptime() format: A character string. The default for the ‘format’ methods is ‘%Y-%m-%d %H:%M:%S’ if any component has a time component which is not midnight, and ‘%Y-%m-%d’ otherwise. If ‘options(digits.secs)’ is set, up to the specified number of digits will be printed for seconds. So, may be it is better to add a sec and later subtract it. dates.mine2-dates.mine+1 dates.mine2[3] #[1] 2009-05-22 00:00:01 GMT dates.mine3-dates.mine2-1 dates.mine3[3] #[1] 2009-05-22 GMT A.K. - Original Message - From: chuck.01 lt; CharlieTheBrown77@ gt; To: r-help@ Cc: Sent: Tuesday, October 30, 2012 5:21 PM Subject: Re: [R] POSIXct date missing time component Um, OK. My dates have times, they are 00:00:00 (i.e. midnight) I'll just add a fraction of a second my dates and go with it. Thanks for the reply. arun kirshna wrote HI, Please check this link (http://rss.acs.unt.edu/Rdoc/library/base/html/as.POSIXlt.html). Dates without times are treated as being at midnight UTC. May be you can try this (if it doesn't create additional problems): dates.mine2-dates.mine+1 dates.mine2 #[1] 2009-05-21 23:30:01 GMT 2009-05-21 23:45:01 GMT #[3] 2009-05-22 00:00:01 GMT 2009-05-22 00:15:01 GMT dates.mine2[3] #[1] 2009-05-22 00:00:01 GMT str(dates.mine2) #POSIXct[1:4], format: 2009-05-21 23:30:01 2009-05-21 23:45:01 ... A.K. -- View this message in context: http://r.789695.n4.nabble.com/POSIXct-date-missing-time-component-tp4647932p4647939.html Sent from the R help mailing list archive at Nabble.com. __ R-help@ mailing list https://stat.ethz.ch/mailman/listinfo/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@ mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- View this message in context: http://r.789695.n4.nabble.com/POSIXct-date-missing-time-component-tp4647932p4647963.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] mergeing a large number of large .csvs
I would first confirm that you need the data in wide format... many algorithms are more efficient in long format anyway, and rbind is way more efficient than merge. If you feel this is not negotiable, you may want to consider sqldf. Yes, you need to learn a bit of SQL, but it is very well integrated into R. --- 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. Benjamin Caldwell btcaldw...@berkeley.edu wrote: Dear R help; I'm currently trying to combine a large number (about 30 x 30) of large .csvs together (each at least 1 records). They are organized by plots, hence 30 X 30, with each group of csvs in a folder which corresponds to the plot. The unmerged csvs all have the same number of columns (5). The fifth column has a different name for each csv. The number of rows is different. The combined csvs are of course quite large, and the code I'm running is quite slow - I'm currently running it on a computer with 10 GB ram, ssd, and quad core 2.3 ghz processor; it's taken 8 hours and it's only 75% of the way through (it's hung up on one of the largest data groupings now for an hour, and using 3.5 gigs of RAM. I know that R isn't the most efficient way of doing this, but I'm not familiar with sql or C. I wonder if anyone has suggestions for a different way to do this in the R environment. For instance, the key function now is merge, but I haven't tried join from the plyr package or rbind from base. I'm willing to provide a dropbox link to a couple of these files if you'd like to see the data. My code is as follows: #multmerge is based on code by Tony cookson, http://www.r-bloggers.com/merging-multiple-data-files-into-one-data-frame/; The function takes a path. This path should be the name of a folder that contains all of the files you would like to read and merge together and only those files you would like to merge. multmerge = function(mypath){ filenames=list.files(path=mypath, full.names=TRUE) datalist = try(lapply(filenames, function(x){read.csv(file=x,header=T)})) try(Reduce(function(x,y) {merge(x, y, all=TRUE)}, datalist)) } #this function renames files using a fixed list and outputs a .csv merepk - function (path, nf.name) { output-multmerge(mypath=path) name - list(x, y, z, depth, amplitude) try(names(output) - name) write.csv(output, nf.name) } #assumes all folders are in the same directory, with nothing else there merge.by.folder - function (folderpath){ foldernames-list.files(path=folderpath) n- length(foldernames) setwd(folderpath) for (i in 1:n){ path-paste(folderpath,foldernames[i], sep=\\) nf.name - as.character(paste(foldernames[i],.csv, sep=)) merepk (path,nf.name) } } folderpath - yourpath merge.by.folder(folderpath) Thanks for looking, and happy friday! *Ben Caldwell* PhD Candidate University of California, Berkeley [[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] mergeing a large number of large .csvs
On the absence of any data examples from you per the posting guidelines, I will refer you to the help files for the melt function in the reshape2 package. Note that there can be various mixtures of wide versus long... such as a wide file with one date column and columns representing all stock prices and all trade volumes. The longest format would be what melt gives (date, column name, and value) but an in-between format would have one distinct column each for dollar values and volume values with a column indicating ticker label and of course another for date. If your csv files can be grouped according to those with similar column types, then as you read them in you can use cbind( csvlabel=somelabel, csvdf) to distinguish it and then rbind those data frames together to create an intermediate-width data frame. When dealing with large amounts of data you will want to minimize the amount of reshaping you do, but it would require knowledge of your data and algorithms to say any more. --- 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. Benjamin Caldwell btcaldw...@berkeley.edu wrote: Jeff, If you're willing to educate, I'd be happy to learn what wide vs long format means. I'll give rbind a shot in the meantime. Ben On Nov 2, 2012 4:31 PM, Jeff Newmiller jdnew...@dcn.davis.ca.us wrote: I would first confirm that you need the data in wide format... many algorithms are more efficient in long format anyway, and rbind is way more efficient than merge. If you feel this is not negotiable, you may want to consider sqldf. Yes, you need to learn a bit of SQL, but it is very well integrated into R. --- 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. Benjamin Caldwell btcaldw...@berkeley.edu wrote: Dear R help; I'm currently trying to combine a large number (about 30 x 30) of large .csvs together (each at least 1 records). They are organized by plots, hence 30 X 30, with each group of csvs in a folder which corresponds to the plot. The unmerged csvs all have the same number of columns (5). The fifth column has a different name for each csv. The number of rows is different. The combined csvs are of course quite large, and the code I'm running is quite slow - I'm currently running it on a computer with 10 GB ram, ssd, and quad core 2.3 ghz processor; it's taken 8 hours and it's only 75% of the way through (it's hung up on one of the largest data groupings now for an hour, and using 3.5 gigs of RAM. I know that R isn't the most efficient way of doing this, but I'm not familiar with sql or C. I wonder if anyone has suggestions for a different way to do this in the R environment. For instance, the key function now is merge, but I haven't tried join from the plyr package or rbind from base. I'm willing to provide a dropbox link to a couple of these files if you'd like to see the data. My code is as follows: #multmerge is based on code by Tony cookson, http://www.r-bloggers.com/merging-multiple-data-files-into-one-data-frame/ ; The function takes a path. This path should be the name of a folder that contains all of the files you would like to read and merge together and only those files you would like to merge. multmerge = function(mypath){ filenames=list.files(path=mypath, full.names=TRUE) datalist = try(lapply(filenames, function(x){read.csv(file=x,header=T)})) try(Reduce(function(x,y) {merge(x, y, all=TRUE)}, datalist)) } #this function renames files using a fixed list and outputs a .csv merepk - function (path, nf.name) { output-multmerge(mypath=path) name - list(x, y, z, depth, amplitude) try(names(output) - name) write.csv(output, nf.name) } #assumes all folders are in the same directory, with nothing else there merge.by.folder - function (folderpath){ foldernames-list.files(path=folderpath) n- length(foldernames) setwd(folderpath) for (i in 1:n){ path-paste(folderpath,foldernames[i], sep
Re: [R] Having some Trouble Data Structures
Please keep mail threads on the mailing list. Please follow the posting guidelines and provide a sample of data and desired outcome. --- 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. Benjamin Ward (ENV) b.w...@uea.ac.uk wrote: Hi, Thank you very much for your reply - how you prefer, is how my supervisor implemented the layout in Minitab, however I was unsure of how to get R to do this repeating ID behaviour and how to know that in a for loop going through individual 1 to say 10, I want it to: Randomly sample a number from a distribution for the number of effectors (I can do this but with runif), Then put one value in a cell of the Effector column and repeat the ID for each effector row. I'm also then left wondering when I do for loops then that use ID, will it go and apply operations row by row, or ID by ID - for example in the immunology part I would need a loop to check individual by individual if any of the effectors it has means death in the host, in which case all instances of - say ID 1 would need to be deleted. Would you be able to provide an example chunk of how you accomplish this with your preferred approach, if you have the time? Thanks, Ben W. From: Jeff Newmiller [jdnew...@dcn.davis.ca.us] Sent: 28 October 2012 15:27 To: Benjamin Ward (ENV); r-help@r-project.org Subject: Re: [R] Having some Trouble Data Structures Search on ragged array. My preferred approach is to use a data frame with one row per effector that repeats the per-ID information. If that occupies too much memory, you can setup another data frame with one row per ID and refer to that information as using lapply and subset the effectors data as needed. The plyr package is also useful for such processing. --- 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. Benjamin Ward (ENV) b.w...@uea.ac.uk wrote: Hi All, I'm trying to run a simulation of host-pathogen evolution based around individuals. What I need to have is a dataframe or table of some description - describing all the individuals of a pathogen population (so far I've implemented this as a matrix): ID No_of_Effectors Effectors (Sequences) [1,] 0001 3 ## 3 Random Numbers ## There will be many such rows for many individuals. They have something called effectors, the number of which is randomly generated, so say you get 3 in the No_of_Effectors column. Then I make R generate 3 numbers from between 1 and 10,000, this gives me three numerical representations of genes. These numbers will be compared to a similar data structure of the host individuals who have their immune genes with similar numbers. My problem is that obviously I can't stick 3 numbers in one cell of the matrix (I've tried) : Pathogen_Individuals[1,3] - c(2,3,4) Error in Pathogen_Individuals[1, 3] - c(345, 567, 678) : number of items to replace is not a multiple of replacement length In future I'm also going to have more variables such as whether a gene is expressed. Such information may require a matrix in itself - something like: Effector ID Sequence Expressed? [1,] 0001 345,567,678 1 (or 0). Is there a way then I can put more than one value in the cell like a list of values, or a way to put objects in a cell of a data frame, matrix or table etc. Almost an inception deal - data structures nested in a data structure? If I search for things like insert list into matrix I get results like how to turn one into another, which is not what I think I need to be doing. I have been considering having several data structures not nested in each other, something like for every individual create a new matrix object with the name Effectors_[Individual_ID] and some how get my simulation loops operating on those objects but I find it hard to see how to tell R all of those matrices are to be included in an operation
Re: [R] Excluding fixed number of rows from calculation while summarizing using ddply() function.
This is not a free do-my-work-for-me forum, this is a help-you-learn-R forum. If you study the solution you have been given until you understand how it works, and combine that with an understanding of indexing from the Introduction to R document that comes with R, you should be able to complete your code the way you want it. Don't abuse the generosity of your helpers. --- 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. siddu479 onlyfordigitalst...@gmail.com wrote: Hi Arun, Thanks for your reply but your script is removing only one row( first row and last row) for each Unique and StepNo combination and calculating mean for the rest of rows. For below data , your script removing the #'s rows perfectly. But in reality I may need to ignore *say first 10 rows and last 20 rows for each Unique and StepNo combination. * for statistics calculation. Unique StepNo Data1 Data2 1 A 1 4 5 #Your script removing this row successfully. 2 A 1 5 6 3 A 1 7 8 4 A 1 3 4 5 A 1 1 1 #Your script removing this row successfully. 6 B 1 2 4 #Your script removing this row successfully. 7 B 1 3 5 8 B 1 4 5 9 B 1 5 6 10B 1 6 7 #Your script removing this row successfully. Can you modify your script to get my requirement like below (making it generic, here *N=2*, removing first 2 lines and last 2 lines.. *sometimes I may have two numbers N1 N2 (no.of rows need to be removed from and top and bottom respectively*) Unique StepNo Data1 Data2 1 A 1 4 5 #Ignore this 2 A 1 5 6 #Ignore this 3 A 1 7 8 4 A 1 3 4 #Ignore this 5 A 1 1 1 #Ignore this 6 B 1 2 4 #Ignore this 7 B 1 3 5 #Ignore this 8 B 1 4 5 9 B 1 5 6 #Ignore this 10B 1 6 7 #Ignore this and then calculate the statistics using ddply. I hope my problem statement is much clear now. - Sidda Business Analyst Lead Applied Materials Inc. -- View this message in context: http://r.789695.n4.nabble.com/Excluding-fixed-number-of-rows-from-calculation-while-summarizing-using-ddply-function-tp4648406p4648447.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] Aggregate data frame across columns
The best way to get an answer is to provide sample data and desired results (computed by hand or by any other available means). See http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example. In the vague question begets a vague answer department, I would use melt from the reshape package, and make some columns that contain unique key values for each time interval, and then use aggregate or ddply from the plyr package. --- 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. Keith Weintraub kw1...@gmail.com wrote: Folks, I have a data frame with columns 200401, 200402, ..., 201207, 201208. These represent years/months. What would be the best way to sum these columns by year? What about by quarter? Thanks for your time, KW -- [[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] save/load and package namespaces
Stop being surprised. Loaded packages are not part of envir (whatever that is), nor are they part of the global environment. You have to reload any packages needed separately from the load call. --- 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. Jamie Olson inspired2apa...@gmail.com wrote: Could someone explain to me what namespaces are loaded/saved when objects are saved? Specifically, I'm using this: save(list = ls(all.names = TRUE, envir = envir), file = name, envir = envir) to save out everything from an environment. Later, loading it on another machine, I'm surprised to see the load failing for being unable to load certain packages. Could anyone help me understand why this happens? Jamie Olson [[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] date and time coding question
I stand by my previous statement: you should avoid thinking of difftime objects as having units. At the point when you learn to regard the units argument as being associated with the numeric values you pass TO as.difftime or that you extract FROM a difftime object with as.numeric, then you will understand POSIXct arithmetic. --- 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. MacQueen, Don macque...@llnl.gov wrote: The difftime() function has a units argument, so it seems kind of obvious to me to think of objects of class 'difftime' as having units. And indeed they do, stored as an attribute: str(difftime( Sys.time()+3700, Sys.time(), units='min')) Class 'difftime' atomic [1:1] 61.7 ..- attr(*, units)= chr mins str(difftime( Sys.time()+3700, Sys.time(), units='sec')) Class 'difftime' atomic [1:1] 3700 ..- attr(*, units)= chr secs The numeric values are already in the specified units, prior to any printing or other further use of the result. ?difftime says, -quote- If 'units = auto', a suitable set of units is chosen, the largest possible (excluding 'weeks') in which all the absolute differences are greater than one. -end quote- So it's pretty clear that the units are chosen when the difference is calculated, not later. Inspection of the difftime() function source code confirms this. One can also inspect print.difftime() and see that the numeric value is used as is, without any unit conversion. Which returns me to my original point: when using diff() on a POSIXt object, I don't know how to specify the units, whereas with difftime() I do. If there is a way to specify units using diff(), I'd love to know about it! -Don __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Comma separated vector
You are wrong... since the SQL query you wish to create is itself a string. Of course, you cannot send a SQL fragment such as you used as an example, so be sure to form a complete, syntactically correct SQL statement before giving it to your database query function. Oh, and if you need more assistance with this topic, then you should probably post in the R-sig-DB mailing list. Please also keep in mind that the actual SQL syntax used for your specific database is basically off-topic in any R forum, so you may need other help resources as well. --- 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. Manta mantin...@libero.it wrote: Hi all, I have a vector of numbers, and to be able to pass it to RMySQL and use the IN clause I need to have this vector to be a single list numeric and comma separated. I saw the post below but it is about strings, which I do not need (I cannot pass strings in this SQL query, I need something like ' where ASSETT in (1,2,3,4,5)' http://stackoverflow.com/questions/6347356/creating-a-comma-separated-vector Any clue? -- View this message in context: http://r.789695.n4.nabble.com/Comma-separated-vector-tp4667340.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] as.vector with mode=list and POSIXct
I don't know what you plan to do with this list, but lists are quite a bit less efficient than fixed-mode vectors, so you are likely losing a lot of computational speed by using this list. I don't hesitate to use simple data frames (lists of vectors), but processing lists is on par with for loops, not vectorized computation. It may still support a simpler model of computation, but that is an analyst comprehension benefit rather than a computational efficiency benefit. --- 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. Alexandre Sieira alexandre.sie...@gmail.com wrote: I was trying to convert a vector of POSIXct into a list of POSIXct, However, I had a problem that I wanted to share with you. Works fine with, say, numeric: v = c(1, 2, 3) v [1] 1 2 3 str(v) num [1:3] 1 2 3 l = as.vector(v, mode=list) l [[1]] [1] 1 [[2]] [1] 2 [[3]] [1] 3 str(l) List of 3 $ : num 1 $ : num 2 $ : num 3 If you try it with POSIXct, on the other hand… v = c(Sys.time(), Sys.time()) v [1] 2013-05-20 18:02:07 BRT 2013-05-20 18:02:07 BRT str(v) POSIXct[1:2], format: 2013-05-20 18:02:07 2013-05-20 18:02:07 l = as.vector(v, mode=list) l [[1]] [1] 1369083728 [[2]] [1] 1369083728 str(l) List of 2 $ : num 1.37e+09 $ : num 1.37e+09 The POSIXct values are coerced to numeric, which is unexpected. The documentation for as.vector says: The default method handles 24 input types and 12 values of type: the details of most coercions are undocumented and subject to change. It would appear that treatment for POSIXct is either missing or needs adjustment. Unlist (for the reverse) is documented to converting to base types, so I can't complain. Just wanted to share that I ended up giving up on vectorization and writing the two following functions: unlistPOSIXct - function(x) { retval = rep(Sys.time(), length(x)) for (i in 1:length(x)) retval[i] = x[[i]] return(retval) } listPOSIXct - function(x) { retval = list() for (i in 1:length(x)) retval[[i]] = x[i] return(retval) } Is there a better way to do this (other than using *apply instead of for above) that better leverages vectorization? Am I missing something here? Thanks! -- Alexandre Sieira CISA, CISSP, ISO 27001 Lead Auditor The truth is rarely pure and never simple. Oscar Wilde, The Importance of Being Earnest, 1895, Act I __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Lattice, ggplot, and pointsize
That is like complaining that your hammer does not fit these newfangled Philips screws. These are different tools. Do not expect them to interoperate. --- 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. Milan Bouchet-Valat nalimi...@club.fr wrote: Le mardi 21 mai 2013 à 23:30 +1000, Duncan Mackay a écrit : Hi See par.settings in xyplot Things are also controlled by trellis.par.get() to see values trellis.par.set() eg xyplot(~Freq|Year, data = sheep2, groups = farm, par.settings = list(strip.background = list(col = transparent), axis.text = list(cex = 0.75), par.xlab.text = list(cex = 0.80), par.ylab.text = list(cex = 0.80)) , ...) HTH Thanks, but that's not really my question. I've already found the way to change text size. What I'm wondering is whether something could be done so that the pointsize argument that is passed to graphical devices has an effect on Lattice and ggplot2 plots. Regards Duncan Duncan Mackay Department of Agronomy and Soil Science University of New England Armidale NSW 2351 Email: home: mac...@northnet.com.au At 21:18 21/05/2013, you wrote: Hi! When inserting R plots into a document using odfWeave, I fought for a while to get Lattice plots use the same text size as base plots. I eventually discovered that specifying a point size via e.g. svg(pointsize=10) has no effect on Lattice plots. One needs to adjust the size manually via: trellis.par.set(fontsize=list(text=10, points=8)) This is also developed for both Lattice and ggplot2 by this blog post: http://gforge.se/2013/03/exporting-plain-lattice-or-ggplot/ So I am wondering whether is a by-design limitation or whether this could be improved. I find it very useful to be able to adapt text size to the output device instead of changing plotting parameters for each plotting system (especially when you change the resolution of PNG output, or move from one output device to another). Thanks in advance __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] as.vector with mode=list and POSIXct
I recommend that you not plan on waiting for the hash package to be redesigned to meet your expectations. Also, your response to discovering this feature of the hash package seems illogical. From a computer science perspective, the hash mechanism is an implementation trick that is intended to improve lookup speed. It does not actually represent a fundamental data structure like a vector or a set does. You can always put your keys in a vector and search through them (e.g. vector indexing by string) to get an equivalent data retrieval. If the hash package is not improving the speed of your data access, adding an extra layer of data structure is hardly an appropriate solution. Why are you not using normal vectors or data frames and accessing with string or logical indexing? If you are avoiding vectors because they seem slow in loops, perhaps you just need to preallocate the vectors you will store your results in before your loop to regain acceptable speed. Or, perhaps the duplicated() or merge() functions could save you from this mess of incremental data processing. --- 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. Alexandre Sieira alexandre.sie...@gmail.com wrote: You are absolutely right. I am storing POSIXct objects into a hash (from the hash package). However, if I try to get them out as a vector using the values() function, they are unclassed. And that breaks my (highly vectorized) code. Take a look at this: h = hash() h[[a]] = Sys.time() str(h[[a]]) POSIXct[1:1], format: 2013-05-20 16:54:28 str(values(h)) Named num 1.37e+09 - attr(*, names)= chr a I have reported this to the hash package maintainers. In the meantime, however, I am storing, for each key, a list containing a single POSIXct. Then, when I extract all using values(), I get a list containing all POSIXct entries with class preserved. h = hash() h[[a]] = list( Sys.time() ) h[[b]] = list( Sys.time() ) h[[c]] = list( Sys.time() ) values(h) $a [1] 2013-05-21 09:54:03 BRT $b [1] 2013-05-21 09:54:07 BRT $c [1] 2013-05-21 09:54:11 BRT str(values(h)) List of 3 $ a: POSIXct[1:1], format: 2013-05-21 09:54:03 $ b: POSIXct[1:1], format: 2013-05-21 09:54:07 $ c: POSIXct[1:1], format: 2013-05-21 09:54:11 However, the next thing I need to do is a min() over that list, so I need to convert the list into a vector again. I agree completely with you that this is horrible for performance, but it is a temporary workaround until values() is fixed. -- Alexandre Sieira CISA, CISSP, ISO 27001 Lead Auditor The truth is rarely pure and never simple. Oscar Wilde, The Importance of Being Earnest, 1895, Act I On 20 de maio de 2013 at 19:40:14, Jeff Newmiller (jdnew...@dcn.davis.ca.us) wrote: I don't know what you plan to do with this list, but lists are quite a bit less efficient than fixed-mode vectors, so you are likely losing a lot of computational speed by using this list. I don't hesitate to use simple data frames (lists of vectors), but processing lists is on par with for loops, not vectorized computation. It may still support a simpler model of computation, but that is an analyst comprehension benefit rather than a computational efficiency benefit. --- Jeff Newmiller The . . Go Live... DCN:jdnew...@dcn.davis.ca.us Basics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/Batteries O.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --- Sent from my phone. Please excuse my brevity. Alexandre Sieira alexandre.sie...@gmail.com wrote: I was trying to convert a vector of POSIXct into a list of POSIXct, However, I had a problem that I wanted to share with you. Works fine with, say, numeric: v = c(1, 2, 3) v [1] 1 2 3 str(v) num [1:3] 1 2 3 l = as.vector(v, mode=list) l [[1]] [1] 1 [[2]] [1] 2 [[3]] [1] 3 str(l) List of 3 $ : num 1 $ : num 2 $ : num 3 If you try it with POSIXct, on the other hand… v = c(Sys.time(), Sys.time()) v [1] 2013-05-20 18:02:07 BRT 2013-05-20 18:02:07 BRT str(v) POSIXct[1:2], format: 2013-05-20 18:02:07 2013-05-20 18:02:07 l = as.vector(v, mode=list) l [[1]] [1] 1369083728 [[2]] [1] 1369083728 str(l) List of 2 $ : num 1.37e+09 $ : num 1.37e+09
Re: [R] as.vector with mode=list and POSIXct
My perception of illogic was in your addition of more data structure complexity when faced with this difficulty. R has best performance when calculations are pushed into simple typed vectors where precompiled code can handle the majority of the work. These are simpler structures, not more complex structures. It seems like you are fighting the natural paradigm for working in R and holding fast to your ideas about how things should be rather than dealing with how they are by introducing lists rather than working with vectors or data frames. --- 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. Alexandre Sieira alexandre.sie...@gmail.com wrote: Hi, Jeff. Thanks for your thoughtful suggestions. I do not plan to wait for the hash package to be redesigned to meet my expectations. As a matter of fact, I have: a) Submitted a report of unexpected behavior in hash::values, which the package maintainer quickly replied to and said would examine. b) Designed (with the help of this list) and implemented a workaround in the form of wrapping the POSIXct objects in lists, which has my program working correctly for now. If the hash package is updated and the workaround is no longer necessary, then I'll reverse this change. Otherwise, I'll look more deeply into my alternatives which might involve maintaining this workaround permanently, or analyzing alternative architectures. The hash package is a beautiful piece of code that is working perfectly for me in many situations. Even with the list wrapping around the POSIXct objects, it is meeting my performance requirements much better than the alternatives I tested. So I'd rather not completely re-engineer working complex code without a very good reason. However, I would like to respectfully disagree with you that my reaction to hash::values behavior was illogical. I don't want to start a flame war or anything, so let's try to keep the discussion civil. :) See, a hash table (or a queue, or a stack, or an R vector) is a data structure that works as a container. You insert objects and you get them back according to the specificities of each data structure (stacks will have a FILO ordering, queues will have FIFO ordering, hashes will maintain key/value pairs, and so). It is completely unreasonable to insert an object of class X into a container, and then get it back altered in a way that is not part of the 'contract' behind the data structure. If I assign X to key K on a hash, however I choose to ask the hash for the value associated with key K back, I should get exactly X as a response. I believe most computer scientists would agree that to be self-evident. And that is to be expected by reading hash::values documentation: Extract values from a hash object. This is a pseudo- accessor method that returns hash values (without keys) as a vector if possible, a list otherwise. Moreover, it has this to say about non-primitive types: If the values are of different types or of a complex class than a named list is returned. It never says it will unclass objects, or coerce them into primitive types. Hence the 'contract' implies I will get back what I inserted, unaltered, either in a vector or a list. And that is provably not what is happening. I would have been ok with a vector of POSIXct or a named list containing the POSIXct values, but instead I am getting a numeric vector. I understand R is based on S, and that OOP concepts were introduced later into its history. However, one of the key concepts in OOP is encapsulation - as an outside entity you do not get to see the internal implementation of a class, you interact with it exclusively through its published interface (method, public member variables, etc). I cannot find any justification as for why an object losing its class unintentionally is ever acceptable, as it violates the concept of encapsulation. That is essentially what's happening if I look up several keys using values(). So this violates the encapsulation of the POSIXct class, as I am exposed to its internal numeric value. Moreover, it breaks the method-dispatch of R functions that know to treat POSIXct values differently. All of a sudden, the POSIXct objects I inserted are being treated, for example, by format as numeric instead of being dispatched to format.Date as expected. So I don't think my reaction to this issue was illogical at all. Hope you'll agree now that I've explained myself a little better. :) -- Alexandre
Re: [R] group data based on row value
dat$group - cut( dat$Var, breaks=c(-Inf,0.1, 0.6,Inf)) levels(dat$group) - LETTERS[1:3] --- 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. Ye Lin ye...@lbl.gov wrote: hey, I want to divide my data into three groups based on the value in one column with group name. dat: Var 0 0.2 0.5 1 4 6 I tried: dat - cbind(dat, group=cut(dat$Var, breaks=c(0.1,0.6))) But it doesnt work, I want to group those 0.1 as group A, 0.1-0.6 as group B, 0.6 as group C Thanks for your help! [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] sample(c(0, 1)...) vs. rbinom
You seem to be building an elaborate structure for testing the reproducibility of the random number generator. I suspect that rbinom is calling the random number generator a different number of times when you pass prob=0.5 than otherwise. --- 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. Michael Hannon jm_han...@yahoo.com wrote: Greetings. My wife is teaching an introductory stat class at UC Davis. The class emphasizes the use of simulations, rather than mathematics, to get insight into statistics, and R is the mandated tool. A student in the class recently inquired about different approaches to sampling from a binomial distribution. I've appended some code that exhibits the idea, the gist of which is that using sample(c(0, 1), ...) and rbinom(...) should give equivalent results. The surprising (to me) result is that the two approaches DO give the same result, EXCEPT when the probability is exactly 0.5. See Appendix A for the code and Appendix B for the output. I don't think this issue is system-dependent, but I've put my session information in Appendix C. Another wrinkle in this is that if I omit the prob parameter from the call to sample, meaning to take the default value of 0.5, the two methods DO give the same result. Any thoughts about this? Thanks. --Mike Appendix A: some R code that exhibits the problem = ppp - seq(0, 1, by = 0.01) result - do.call(rbind, lapply(ppp, function(p) { set.seed(1) sampleRes - sample(c(0, 1), size = 1, replace = TRUE, prob=c(1-p, p)) set.seed(1) rbinomRes - rbinom(1, size = 1, prob = p) data.frame(prob = p, equivalent = all(sampleRes == rbinomRes)) })) result Appendix B: the output from the R code == prob equivalent 1 0.00 TRUE 2 0.01 TRUE 3 0.02 TRUE 4 0.03 TRUE 5 0.04 TRUE 6 0.05 TRUE 7 0.06 TRUE 8 0.07 TRUE 9 0.08 TRUE 10 0.09 TRUE 11 0.10 TRUE 12 0.11 TRUE 13 0.12 TRUE 14 0.13 TRUE 15 0.14 TRUE 16 0.15 TRUE 17 0.16 TRUE 18 0.17 TRUE 19 0.18 TRUE 20 0.19 TRUE 21 0.20 TRUE 22 0.21 TRUE 23 0.22 TRUE 24 0.23 TRUE 25 0.24 TRUE 26 0.25 TRUE 27 0.26 TRUE 28 0.27 TRUE 29 0.28 TRUE 30 0.29 TRUE 31 0.30 TRUE 32 0.31 TRUE 33 0.32 TRUE 34 0.33 TRUE 35 0.34 TRUE 36 0.35 TRUE 37 0.36 TRUE 38 0.37 TRUE 39 0.38 TRUE 40 0.39 TRUE 41 0.40 TRUE 42 0.41 TRUE 43 0.42 TRUE 44 0.43 TRUE 45 0.44 TRUE 46 0.45 TRUE 47 0.46 TRUE 48 0.47 TRUE 49 0.48 TRUE 50 0.49 TRUE 51 0.50 FALSE 52 0.51 TRUE 53 0.52 TRUE 54 0.53 TRUE 55 0.54 TRUE 56 0.55 TRUE 57 0.56 TRUE 58 0.57 TRUE 59 0.58 TRUE 60 0.59 TRUE 61 0.60 TRUE 62 0.61 TRUE 63 0.62 TRUE 64 0.63 TRUE 65 0.64 TRUE 66 0.65 TRUE 67 0.66 TRUE 68 0.67 TRUE 69 0.68 TRUE 70 0.69 TRUE 71 0.70 TRUE 72 0.71 TRUE 73 0.72 TRUE 74 0.73 TRUE 75 0.74 TRUE 76 0.75 TRUE 77 0.76 TRUE 78 0.77 TRUE 79 0.78 TRUE 80 0.79 TRUE 81 0.80 TRUE 82 0.81 TRUE 83 0.82 TRUE 84 0.83 TRUE 85 0.84 TRUE 86 0.85 TRUE 87 0.86 TRUE 88 0.87 TRUE 89 0.88 TRUE 90 0.89 TRUE 91 0.90 TRUE 92 0.91 TRUE 93 0.92 TRUE 94 0.93 TRUE 95 0.94 TRUE 96 0.95 TRUE 97 0.96 TRUE 98 0.97 TRUE 99 0.98 TRUE 100 0.99 TRUE 101 1.00 TRUE Appendix C: Session information === sessionInfo() R version 3.0.0 (2013-04-03) Platform: x86_64-redhat-linux-gnu (64-bit) locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 [7] LC_PAPER=C LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base
Re: [R] Could graph objects be stored in a two-dimensional list?
You could use lists of lists, and index them with vectors. a - list() a[[1]] - list() a[[2]] - list() a[[c(1,1)]] - g11 a[[c(1,2)]] - g12 a[[c(2,1)]] - g21 a[[c(2,2)]] - g22 print(a[[c(2,1)]]) but this seems like an inefficient use of memory because your indexed data is stored more compactly than the graph object is. I would index the data and generate the graph object on the fly when I wanted to see it. --- 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. jpm miao miao...@gmail.com wrote: Hi, I have a few graph objects created by some graphic package (say, ggplot2, which I use frequently). Because of the existent relation between the graphs, I'd like to index them in two dimensions as p[1,1], p[1,2], p[2,1], p[2,2] for convenience. To my knowledge, the only data type capable of storing graph objects (and any R object) is list, but unfortunately it is available in only one dimension. Could the graphs be stored in any two-dimensional data type? One remedy that comes to my mind is to build a function f so that f(1,1)=1 f(1,2)=2 f(2,1)=3 f(2,2)=4 With functions f and f^{-1} (inverse function of f) , the two-dimensional indices could be mapped to and from a set of one-dimensional indices, and the functions are exactly the way R numbers elements in a matrix. Does R have this built-in function for a m by n matrix or more generally, m*n*p array? (I know this function is easy to write, but just want to make sure whether it exists already) Thanks, Miao [[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] ggmap, hexbin and length distortion in Lat/long
I would suggest asking this on R-sig-geo. https://stat.ethz.ch/mailman/listinfo/r-sig-geo --- 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. Mike Bock mb...@environcorp.com wrote: I am working with spatial data in ggmap, generally with great success. I have a huge data set with the coordinates in NAD 83 UTM Zone 11 (meters). To map the data the coordinates were converted to Lat Long in GIS prior to use in R and ggmap/ggplot. I am using hexagonal binning to aggregate the data : #create bins and calculate stats hb-hexbin(DF$lon,DF$lat,xbins=80,IDs=TRUE) hb.avg-hexTapply(hb,DF$Res,mean,na.rm=TRUE) hb.mx-hexTapply(hb,DF$Res,max,na.rm=TRUE) hb.p80-hexTapply(hb,DF$Res,quantile,prob=0.80,na.rm=TRUE) #create df for ggplot hx_dat - data.frame(hcell2xy(hb), count = hb@count, xo = hb@xcm, yo = hb@ycm, Mean=hb.avg,Max=hb.mx, p80=hb.p80) #Base Map #BBox is the bounding box Base-get_map(BBox,source='google') m_hx-ggmap(Base,legend = bottom, base_layer=ggplot(aes(x=x,y=y),data=hx_dat)) #Map of means a-0.55 hc-'grey60' m_hx+geom_hex(aes(x = x, y = y, fill = Mean), color = hc, ,alpha=a,stat = identity) + scale_fill_gradientn(Mean,colours=rev(rainbow(4)),trans='sqrt') ...and so on for other stats I can also run statistical analyses on hx_dat. By creating hexbins based on lat/long it seems there will be distortion due to the differences in length of a degree at different locations on the earth's surface. What is the most efficient way to eliminate this distortion? Should I run hexbin in NAD83 and convert the x/y coordinates to Lat Long? Can I get ggmap to convert the baselayer to NAD84 and just do everything in NAD(my preferred option)? I have tried converting Lat Long to NAD84 and back but the coordinates are coming up in the eastern Pacific and not in California, so I am missing something and I am not sure that is the best way to solve the problem anyway. Thanks in advance, any help is greatly appreciated Mike Michael J. Bock, PhD | Senior Manager mb...@environcorp.com This message contains information that may be confidenti...{{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. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Parameters estimation for extreme value models
Well, then, you had better get busy and stop posting here. To learn why, read the Posting Guide. Some pointers: a) No homework help here. b) No posting in HTML. c) This list is for questions about R, not statements about your needs. --- 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. assaedi76 assaedi76 assaed...@yahoo.com wrote: Thanks in advance R users � I have time series data and I need to estimate the parameters involved in three different models for generalized extreme values � Model 1: �a, b, c�are constants. � Model 2:�a(t)=B0+B1 t, but� b, c�are constants � Model 3:�c(t)= Exp(B0+B1 t) �but�a, b�are constants � Where a, b�and�c�are location, scale and shape parameter respectively; t is time. Regards� [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] curiosity: next-gen x86 processors and FP32?
I am no HPC expert, but I have been computing for awhile. There are already many CPU-specific optimizations built into most compilers used to compile the R source code. Anyone sincerely interested in getting work done today should get on with their work and hope that most of the power of new processors gets delivered the same way. The reason single precision is so uncommon in many computing environments is that numerical errors propagate much faster with single precision. I don't expect the typical R user to want to perform detailed uncertainty analysis every time they set up a computation to decide whether it can be computed with sufficient accuracy using SP. Most speed problems I have encountered have been related to memory (swapping, fragmentation) and algorithm inefficiency, not CPU speed. --- 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. ivo welch ivo.we...@anderson.ucla.edu wrote: dear R experts: although my question may be better asked on the HPC R mailing list, it is really about something that average R users who don't plan to write clever HPC-optimized code would care about: is there a quantum performance leap on the horizon with CPUs? like most R average non-HPC users, I want to stick mostly to mainstream R, often with library parallel but that's it. I like R to be fast and effortless. I don't want to have to rewrite my code greatly to take advantage of my CPU. the CUDA forth-and-back on the memory which requires code rewrites makes CUDA not too useful for me. in fact, I don't even like setting up computer clusters. I run code only on my single personal machine. now, I am looking at the two upcoming processors---intel haswell (next month) and amd kaveri (end of year). does either of them have the potential to be a quantum leap for R without complex code rewrites? I presume that any quantum leaps would have to come from R using a different numerical vector engine. (I tried different compiler optimizations when compiling R (such as AVX) on the 1-year old i7-27*, but it did not really make a difference in basic R benchmarks, such as simple OLS calculations. I thought AVX would provide a faster vector engine, but something didn't really compute here. pun intended.) I would guess that haswell will be a nice small evolutionary step forward. 5-20%, perhaps. but nothing like a factor 2. [tomshardware details how intel FP32 math is 4 times as fast as double math on the i7 architecture. for most of my applications, a 4 times speedup at a sacrifice in precision would be worth it. R seems to use only doubles---even as.single is not even converting to single, much less inducing calculations to be single-precision. so I guess this is a no-go. correct?? ] kaveri's hUMA on the other hand could be a quantum leap. kaveri could have the GPU transparently offer common standard built-in vector operations that we use in R, i.e., improve the speed of many programs without the need for a rewrite, by a factor of 5? hard to believe, but it would seem that AMD actually beat Intel for R users. a big turnaround, given their recent deemphasis of FP on the CPU. (interestingly, the amd-built Xbox One and PS4 processors were also reported to have hUMA.) worth waiting for kaveri? anything I can do to drastically speed up R on intel i7 by going to FP32? regards, /iaw Ivo Welch (ivo.we...@gmail.com) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How sum all possible combinations of rows, given 4 matrices
I expect the answer to involve manipulating indices. But why do you need to do this? This looks suspiciously like homework, and there is a no-homework policy on this list (see the Posting Guide). --- 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. Estigarribia, Bruno estig...@email.unc.edu wrote: Hello all, I have 4 matrices with 3 columns each (different number of rows though). I want to find a function that returns all possible 3-place vectors corresponding to the sum by columns of picking one row from matrix 1, one from matrix 2, one from matrix 3, and one from matrix 4. So basically, all possible ways of picking one row from each matrix and then sum their columns to obtain a 3-place vector. Is there a way to use expand.grid and reduce to obtain this result? Or am I on the wrong track? Thank you, Bruno PS:I believe I have given all relevant info. I apologize in advance if my question is ill-posed or ambiguous. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] adding class attributes to strings: works in a loop, but not directly
a) You cannot assign attributes to literal values such as BICY. You must assign them to variables, as in x - BICY class(x) - AONmode b) You cannot give the separate elements of a vector their own separate attributes unless the vector is of mode list. Ordinarily, attributes apply to the whole vector. (When the vector is of mode list then each element may be a vector on its own with its own attributes.) y - c(FOOT,BICY) class(y) - AONmode z - vector( list, 2 ) z[[1]] - FOOT class( z[[1]] ) - AONmode z[[2]] - BICY class( z[[2]] ) - AONmode --- Jeff NewmillerThe . . Go Live... DCN:jdnew...@dcn.davis.ca.usBasics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/BatteriesO.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --- Sent from my phone. Please excuse my brevity. Franckx Laurent laurent.fran...@vito.be wrote: Dear all I try to assign class attributes to strings. Depending on the approach I use, it works (including method dispatch) or fails. Let me clarify with an example. Let: AONtptmodelist - c(FOOT,BICY) When I assign class attributes directly to these strings, it fails: class(BICY) - AONmode Error in class(BICY) - AONmode : target of assignment expands to non-language object However, when I assign the attributes in a loop, it does work: for(tptmode in AONtptmodelist) { + class(tptmode) - AONmode + cat(The value of is.object(tptmode) for , tptmode , is: , is.object(tptmode) , .\n) + cat(The class of , tptmode , is: , class(tptmode) , .\n) + } The value of is.object(tptmode) for FOOT is: TRUE . The class of FOOT is: AONmode . The value of is.object(tptmode) for BICY is: TRUE . The class of BICY is: AONmode . Moreover, within this loop, method dispatch works correctly. However, when I start a new loop over the same vector, I get: for(tptmode in AONtptmodelist) { + cat(The value of is.object(tptmode) for , tptmode , is: , is.object(tptmode) , .\n) + cat(The class of , tptmode , is: , class(tptmode) , .\n) + } The value of is.object(tptmode) for FOOT is: FALSE . The class of FOOT is: character . The value of is.object(tptmode) for BICY is: FALSE . The class of BICY is: character . I find this troublesome for two reasons. First, I do not understand the difference between the two approaches. Why can I assign a class attribute to a string when it is called in a loop, but not directly? And why is the class attribution not permanent? Second, the problem was concealed until now precisely because I assigned the attributes in a link. However, I would like to centralise my class definition in one single place in my code, thus outside the loop where the methods are called. Laurent Franckx, PhD VITO NV Boeretang 200, 2400 MOL, Belgium Tel. + 32 14 33 58 22 Skype: laurent.franckx laurent.fran...@vito.be Visit our website: www.vito.be/english and http://www.vito.be/transport [http://www.vito.be/e-maildisclaimer/vito.png] Ontdek hoe VITO de transitie naar een duurzame maatschappij op gang trekt: www.vito.be/duurzaamheidsverslag2012http://www.vito.be/duurzaamheidsverslag2012 VITO Disclaimer: http://www.vito.be/e-maildisclaimer __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] write table in ascii
I would bet the problem is end-of-line convention. This is a very old problem of text file conversion that has many solutions, none of which should be addressed by R. Rather, you should use any of the many standard file transfer mechanisms that understand EOL issues in text files, rather than transferring the data as if it were binary data. Email is one such mechanism, FTP is another. Many text editors can also fix this for you. It is possible to fix it in R, but that is a very bad approach. Google is your friend. --- 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. Gary Dong pdxgary...@gmail.com wrote: I am working in Windows system. But a software I am using requires data input in ascii (.dat, delimiters can be tabs or spaces). I was able to save the data into .dat (ascii) from SPSS, but it keeps causing problems. Thank you! Gary On Thu, May 30, 2013 at 3:51 PM, Sarah Goslee sarah.gos...@gmail.comwrote: On Thu, May 30, 2013 at 6:35 PM, Gary Dong pdxgary...@gmail.com wrote: Dear R users, I have a data set in .csv and I hope to convert it to .dat (ascii) so it can work in an UNIX environment. Anyone can help me? Thank you! Please expand. Why can't you work with csv in a UNIX environment? I do it all the time. Sarah -- 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. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Strange behaviour of R graphics copied to PowerPoint
I have not seen this particular problem, but I have seen other problems and I tend to export bitmaps or pdf files as a result. Note that a reproducible example is usually required to to obtain help on this list, and posting in HTML format is bad because it mutilates example code, so fix your email client. Please read the Posting Guide for more etiquette tips. --- 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. Erling Johan Frøysa erling.fro...@gmail.com wrote: Hello, I am using R to create graphics, especially to plot time series charts. These charts are then copied as metafiles (for best quality) to a PowerPoint presentation and then saved to PDF (via the Save As dialog). Attached is two pictures. The first picture shows how my chart looks like in the R Graphics window, and the second picture shows how the chart becomes after saving it to PDF. http://r.789695.n4.nabble.com/file/n4668522/R.png http://r.789695.n4.nabble.com/file/n4668522/Rppt.png As you can see. After saving the metafile to PDF via PowerPoint, some straight lines appears (it seems like all of the lines has the same origin in the upper left corner and ends somewhere on the times series line). This happens in both plot() and ggplot(). The problem appears more often when using daily data in my time series. With monthly data the problem don't exist. Have anyone experienced this before? Do you think the problem is related to R or to Powerpoint? Thanks all, E [[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 code from optim - NEW_X what does it mean?
Your email Is missing a reproducible example... very sub-optimal, likely to be ignored. --- 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. Adler, Avraham avraham.ad...@guycarp.com wrote: Hello. Does anyone know what the error code NEW_X means in optim? Here is what the return looks like: $counts function gradient 302 302 $convergence [1] 1 $message [1] NEW_X I have searched and found a couple of mentions without responses: https://stat.ethz.ch/pipermail/r-help/2011-September/290722.html September 2011 https://stat.ethz.ch/pipermail/r-devel/2013-May/066731.html Full disclosure, this is my (unanswered) question on R-devel I can only find one instance of the call in `optim.c` and I don't understand what it is doing. Thank you, Avraham Adler __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to write a loop in R to select multiple regression model and validate it ?
This doesn't look like a task you have acquired through a real-life problem... it looks like homework. There is a stated no-homework policy in the Posting Guide (please read it), since you should be using the resources provided along with your educational environment (teaching assistants, tutors, office hours...), and we don't know whether the help we provide would be considered cheating. --- 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. beginner pa...@nottingham.ac.uk wrote: I would like to run a loop in R. I have never done this before, so I would be very grateful for your help ! 1. I have a sample set: 25 objects. I would like to draw 1 object from it and use it as a test set for my future external validation. The remaining 24 objects I would like to use as a training set (to select a model). I would like to repeat this process until all 25 objects are used as a test set. 2. For each of the training sets I would like to run the following code: library(leaps) forward - regsubsets(Y ~.,data = training, method = forward, nbest=1) backward - regsubsets(Y ~.,data = training, method = backward, nbest=1) stepwise - regsubsets(Y ~., data = training, method = seqrep, nbest=1) exhaustive - regsubsets(Y ~.,data = training, method = forward, nbest=1) summary(forward) summary(backward) summary(stepwise) summary(exhaustive) I would like R programme to select the best model (with the highest adjusted R2) using each of the selection methods, so there are 4 final best models (e.g. the best model selected with forward selection, the best model selected with backward selection and so on...). Afterwards I would like to perform internal cross validation of all 4 selected models and choose 1 out of 4 which has the lowest average mean squared error (MSE). I used to do it using the code below: library(DAAG) val.daag-CVlm(df=training, m=1, form.lm=formula(Y ~ X1+X2+X3)) val.daag-CVlm(df=training, m=1, form.lm=formula(Y ~ X1+X2+X4)) val.daag-CVlm(df=training, m=1, form.lm=formula(Y ~ X3+X4+X5)) val.daag-CVlm(df=training, m=1, form.lm=formula(Y ~ X4+X5+X7)) For the best selected model (the lowest MSE) I would like to perform an external validation on 1 object left on the site at the beginning of the study (please refer to point 1.). 3. And loop again using different training and test set I hope that you could help me with this. If you have any suggestions how to select the best model and perform validation more efficiently, I would be happy to hear about that. Thank you ! -- View this message in context: http://r.789695.n4.nabble.com/How-to-write-a-loop-in-R-to-select-multiple-regression-model-and-validate-it-tp4668669.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] Loop FOR with histogram() from lattice
If you have read the Posting Guide, you will know that you should have read ALL the FAQs before posting your question. http://cran.r-project.org/doc/FAQ/R-FAQ.html That said, this particular FAQ applies to any library that depends on grid graphics, including lattice and ggplot2. --- 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. Xochitl CORMON xochitl.cor...@ifremer.fr wrote: Hi Jim, Thank you a lot. Is it a FAQ concerning lattice or FOR loop in general? Regards, Xochitl C. Le 05/06/2013 10:55, Jim Holtman a écrit : This is an FAQ. you have to explicitly 'print' the histogram: print(histogram(~ Mpool[[2]]$LngtClas | Mpool[[2]]$SpCode, type = count, col = lightgrey, xlab= LngtClas, main = paste(Length distribution per species for Mpool, 2, sep = _))) Sent from my iPad On Jun 5, 2013, at 4:37, Xochitl CORMONxochitl.cor...@ifremer.fr wrote: Hi all, I'm encountering a problem I do not understand on my data: library (lattice) Mpool1- Table[Table$Subarea %in% c(52E9, 51E9),] Mpool2- Table[Table$Subarea %in% c(53F0, 52F0),] Mpool3- Table[Table$Subarea %in% c(51F0, 50F0),] Mpool4- Table[Table$Subarea %in% c(51F1, 52F1),] Mpool- list(Mpool1, Mpool2, Mpool3, Mpool4) histogram(~ Mpool[[2]]$LngtClas | Mpool[[2]]$SpCode, type = count, col = lightgrey, xlab= LngtClas, main = paste(Length distribution per species for Mpool, 2, sep = _)) This part works perfectly and I obtain the graph reprensenting Mpool2 length class count per species. Now when I want to automatize this with a for loop nothing is plotted. for (i in c(2)){ windows() histogram(~ Mpool[[i]]$LngtClas | Mpool[[i]]$SpCode, type = count, col = lightgrey, xlab= LngtClas, main = paste(Length distribution per species for Mpool, i, sep = _)) print (i) } ### Running this loop I obtained windows filled grey (no plot drawn at all) but the print (i) print a 2 as expected. I really dont understand what's wrong with the loop. There is no error message and no notification in R. You can find enclosed my data in txt file. Thank you very much for any help, Xochitl C. Xochitl CORMON +33 (0)3 21 99 56 84 Doctorante en sciences halieutiques PhD student in fishery sciences IFREMER Centre Manche Mer du Nord 150 quai Gambetta 62200 Boulogne-sur-Mer Table.txt __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Fortunes nomination (was: colour coded dotchart)
Oh, Lord, give me strength, for I am about to read an R Help file! Give me insight, for I must parse the words of statisticians forced by R CMD check to follow the way of the Literate Programmer! And please, Oh Lord, give me the wisdom to recall these tribulations when I set foot upon that road, that I may mark the path I blaze clearly for the novitiate to follow yet my words not become as obscure as those I read! Commentary: There is both truth and fiction in Rolf's advice, and for the truth I applaud the nomination, but for the fiction I fear the picture it paints in the unsuspecting mind. On the one hand, it seems odd to ask that the R user believe that meaning is there because this is software, not the Bible. On the other hand, some people seem to think they should not have to study to use this tool properly, so perhaps some faith will help them dig a little harder. Writing documentation is hard, and R CMD check at least makes package developers write SOMETHING down. That doesn't mean that it verifies that it is complete or clearly written. You can drag the horse to water but you cannot make them drink. Fortunately, the author of the code often does write just what you need to use it... even if it is a bit terse. There is also a bit of transformation that happens as one learns how R code works, that makes the obscure documentation more intuitive. What the beginner does not seem to realize is that documentation that they would think is perfect would likely have to be customized to fit their specific set of educational holes, but would bore others who knew all that stuff. The solution is for certain conventions and shorthand to be used, and to let the user search as deep as they need to get their answer. Also, it is common for teenagers to say they will never be like their parents, yet later find themselves doing just that. It is worth reminding new users that the maintainer() function is the key to helping improve R documentation, since what beginners think of as R is not a monolithic product but rather is the product of many individuals. Having the package maintainer be the gateway for such changes is a bit random, since different maintainers have different time and skills for the job, but communicating with the right person (rather than expecting them to read every message on R- help) is in general the best practice for fixing problems in packages. (Faulty documentation is indeed a problem, but a constructive suggestion for fixing it is far more likely to bring about change than either throwing of stones or abasing oneself before the guru.) --- 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. Achim Zeileis achim.zeil...@uibk.ac.at wrote: On Sun, 9 Jun 2013, Duncan Murdoch wrote: On reading the help pages, Thanks, online on R-Forge now :-) Best, Z On 13-06-08 9:32 PM, Rolf Turner wrote: ... You need to get the hang of reading the online help. The information required is actually there in ?dotchart --- it's just tersely and obscurely expressed. A certain degree of optimism is required. You need to ***believe*** that the information is there; then ask yourself What could they possibly mean by what they have written that would tell me what I need to know?. Duncan Murdoch __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Fwd: Problem with ODBC connection
Given the resounding silence, I would venture to guess that no-one here is interested in troubleshooting ODBC connections to Excel. The problem is most likely in the ODBC driver for Excel (not in R or RODBC), and Excel is NOT a database (so any data format problem is unlikely to be detected). --- 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. Christofer Bogaso bogaso.christo...@gmail.com wrote: Any response please? Was my question not clear to the list? Please let me know. Thanks and regards, -- Forwarded message -- From: Christofer Bogaso bogaso.christo...@gmail.com Date: Sat, Jun 8, 2013 at 9:39 PM Subject: Re: Problem with ODBC connection To: r-help r-help@r-project.org Hello All, My previous post remains unanswered probably because the attachment was not working properly. So I am re-posting it again. My problem is in reading an Excel-2003 file through ODBC connection using RODBC package. Let say I have this Excel file: http://www.2shared.com/document/HS3JeFyW/MyFile.html I saved it in my F: drive and tried reading the contents using RODBC connection: library(RODBC) MyData - sqlFetch(odbcConnectExcel(f:/MyFile.xls), ) head(MyData, 30) However it looks that the second column (with header 's') is not read properly. Can somebody here explain this bizarre thing? Did I do something wrong in reading that? Really appreciate if someone could point out anything what might go wrong. Thanks and regards, On Fri, Jun 7, 2013 at 4:46 PM, Christofer Bogaso bogaso.christo...@gmail.com wrote: Hello again, I am having problem with ODBC connection using the RODBC package. I am basically trying to read the attached Excel-2003 file using RODBC package. Here is my code: head(sqlFetch(odbcConnectExcel(d:/1.xls), ), 30); odbcCloseAll() Criteria s d fd ffd1 f1fd2f2 fd3 f3 F12 F13 F14 F15 F16 F17 F18 F19 F20 1 a NA NA NA NA 0. 0.27755576 -0.00040332321NA NA NA NA NA NA NA NA NA NA NA NA 2 s NA 0 NA NA 0. 0. 0.000NA NA NA NA NA NA NA NA NA NA NA NA 3 d NA 0 NA NA 0.01734723 0.06938894 0.2775558 5.00 NA NA NA NA NA NA NA NA NA NA NA 4 f NA NA NA NA NA NA NA -4.25 NA NA NA NA NA NA NA NA NA NA NA 5 f NA 0 NA NA 0. 0. 0.000 -1.53 NA NA NA NA NA NA NA NA NA NA NA 6 f NA NA NA NA NA NA 0.000 0.00 NA NA NA NA NA NA NA NA NA NA NA 7 f NA NA NA NA NA NA 0.000NA NA NA NA NA NA NA NA NA NA NA NA 8 f NA 0 NA NA NA NA NANA NA NA NA NA NA NA NA NA NA NA NA 9 f NA 0 NA NA NA NA NANA NA NA NA NA NA NA NA NA NA NA NA 10f NA NA NA NA NA NA NANA NA NA NA NA NA NA NA NA NA NA NA 11f NA NA NA NA NA NA NANA NA NA NA NA NA NA NA NA NA NA NA 12f NA NA NA NA NA NA NANA NA NA NA NA NA NA NA NA NA NA NA 13f NA NA NA NA NA NA NANA NA NA NA NA NA NA NA NA NA NA NA Here you see the data in second column could not read at all. Can somebody point me if I did something wrong? Thanks and regards, [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide
Re: [R] Bytes to Numeric/Float conversion
I recommend the hexView package for setting up such conversions. --- 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. David Winsemius dwinsem...@comcast.net wrote: On Jun 11, 2013, at 9:01 AM, Bikash Agrawal wrote: Is there any packages available in R, that can convert Bytes array to Float. Using rJava we can do it. But it is kind of slow. Is there any R specific packages. I am having problem converting my bytes array to floating point. Could any one help me with this problem. There is a raw data type that is designed to hold bytes than can be indexed. ?raw `scan` can read files of type raw ?scan __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Big, complex, well-structured .R file for demonstration?
Just because you have an editor that can let you see the organization within the file does not mean the code itself is well-structured. If you do put a lot of code in one file, you will be more likely in your next project that builds on this one to load code you do not need (bloat), and that is a very practical defect in the structure of the current project. Regardless of any arguments you can think of to the contrary, that is why single large files with otherwise well-structured code are uncommon. --- 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. Thorsten Jolitz tjol...@gmail.com wrote: Greg Snow 538...@gmail.com writes: Some would argue that big and well structured are not compatible. Part of structuring a project well is knowing when and how to break it into smaller pieces, so those authors who are best at creating well structured R code will often split it between several small files rather than one big file. As Emacs Org-mode has proven for text files, this structuring into smaller pieces can be done in one single file too (that is structured as a hierarchical outline tree) an this can be even more convenient than to deal with many small files. But otherwise I agree with you, its much better to split a file up before it becomes a growing mess. On Tue, Jun 11, 2013 at 9:06 AM, Thorsten Jolitz tjol...@gmail.com wrote: Hi List, I'm looking for a rather big, but well structured R file that contains as much of R language features as possible (i.e. that uses a lot of the functionality described in the 'R Reference Card' and, if possible, S4 classes too). I want to check some code I wrote against such a file and use it for demonstration purposes. However, most .R files I find out there are rather short without much structure. Any links to candidate (open source) files would be appreciated. -- cheers, Thorsten __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Remove levels
Please read the Posting Guide, which among other things points out that you should be posting in plain text format, not HTML (which tends to corrupt example R code). Then please explain why your problem is not addressed by the below referenced section of the R Inferno. You may need to read [1] for advice on providing a reproducible example per the Posting Guide so we can follow your argument clearly. [1] http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example --- 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. Shane Carey careys...@gmail.com wrote: Nope, but thanks On Thu, Jun 13, 2013 at 1:11 PM, Albin Blaschka albin.blasc...@standortsanalyse.net wrote: Am 13.06.2013 14:02, schrieb Shane Carey: I have a dataframe consisting of factors in one column. Im trying to remove certain levels using the following code: toBeRemoved1-which(DATA$**UnitName_1==lake) DATA-DATA[-toBeRemoved1,] However it will not remove the level lake Hello! Is this a part of the R Inferno? See The R Inferno from Patrick Burns, specially Chapter 8.2.4 dropping factor levels , page 83 http://www.burns-stat.com/**pages/Tutor/R_inferno.pdfhttp://www.burns-stat.com/pages/Tutor/R_inferno.pdf HTH, Albin -- | Albin Blaschka, Mag.rer.nat. | Etrichstrasse 26, A-5020 Salzburg | * www.albinblaschka.info * www.thinkanimal.info * | - It's hard to live in the mountains, hard but not hopeless! __** 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. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R session freezes when I try to save a new script
You will probably need to read the Posting Guide and follow its recommendations to get a constructive response. Things like posting in text instead of HTML and providing the output of sessionInfo go a long way toward speeding up the troubleshooting process. You can also begin the process of identifying what your in-memory objects look like by stopping your script just before you run the function or click on a menu that hangs, and providing to us the output of the ls() function in your next email. You may have redefined an object with an important name. Alternatively, you may have a windows permissions issue (which would be outside the scope of this mailing list. Ideally you would generate a self- contained reproducible example, but if that is not possible then you will have to live with guesses as responses. (The dump or dput functions may let you share the problematic memory configuration.) --- 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. anferg...@aol.com wrote: All: Recently my R session freezes when I try to open a file or save a new script after I have run existing scripts. The session freezes so that I can no longer click on any windows within the R session -- including other scripts that are open or the R console. (I hear the ding sound when I try to click on anything.) I have looked at the Task Manager on the computer and R is still running (and is still responsive according to the Task Manager), but I cannot do anything within R. I have tried pressing Esc and that does not help. Any suggestions would be greatly appreciated! I am using a 32 bit Windows 7 computer with 4gb ram and 250gb hard drive. Thanks in advance for any suggestions! ~Amanda Ferguson [[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] Widows 8
On Sat, 15 Jun 2013, Chet Seligman wrote: Can anyone confirm that R runs on Widows 8? You can : http://lmgtfy.com/?q=site%3Astat.ethz.ch+%22windows+8%22 Thanks, Chet Seligman [[alternative HTML version deleted]] Please read the Posting Guide, and asi it requests post in plain text. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. --- 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 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Optimization of a function using optim
Not unless you read the Posting Guide, stop posting in HTML mail format, and provide a reproducible example. --- 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. Graham McDannel graham.mcdan...@gmail.com wrote: I am attempting to optimize a function I have developed using optim. I am getting the below error message: Error in n 1: 'n' is missing Could some one provide some additional clarity regarding this message and what it entails, as well as, how to rectify this issue. 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] R for Chrome OS
You should probably try to study a bit more about what ChromeOS is about before asking questions like that. The real question you should have asked is whether R is offered as SAAS in the cloud. (I don't think so.) You can setup an instance of Linux in the cloud and run R there. RStudio Server may also be helpful. If you don't like paying for your use of R by the minute, then you may want to purchase your own server or reconsider using ChromeOS at all. Also, please post here in plain text rather than using HTML email as the Posting Guide requests. --- 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. Kevin Chavers kevinchav...@gmail.com wrote: Hello, I have heard that Chrome OS is Linux based, so I am wondering if there is anyway to use R on a Google Chromebook using one of your Linux packages. If not, do you plan on making a version of R that is compatible with chromebooks or cloud based? [[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] help with string split in R
?sub --- 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. CompBiol ATL along...@gmail.com wrote: #I want to remove '_alpha' in a vector of strings myInput = c( afg3_alpha, alg12_alpha, dbp3_alpha, elp4_alpha, fob1_alpha, gpr1_alpha) #my current solution tmpsplit = strsplit(myInput, '_') tmp = NA for (item in tmpsplit){ tmp = c(tmp, item[1]) } results1 = tmp[-1]; #this is what I need, but I want a better solution. #Here is what I come up with, but it is pretty awkward tmp3 = lapply(myInput, FUN=function(x){strsplit(x, '_')[[1]][1]}) results2 = unlist(tmp3) #Please help me revise the above loop. Thanks, -- Hong [[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] BINARY traits GENETIC CORRELATION
Re-posting, particularly without referencing your earlier post, is bad mailing-list etiquette. Posting in HTML is particularly frowned upon here also. Nor is this a statistical methods support forum... it is about R. I for one am finding your question very jargonish and obscure. If your question is straightforward in the genetics domain then there might be more responsiveness in the Bioconductor mailing list. Otherwise, you may need to frame your question more directly in terms of the R language, with an example starting data set and expected results [1]. You are also expected to read the Posting Guide mentioned at the end of every R-help email. [1] http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example --- 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. Vallejo, Roger roger.vall...@ars.usda.gov wrote: Dear R Users, I have always used ASReml, MTDFREML, SAS, etc. to estimate genetic correlation (Rg) between two continuous quantitative traits (also continuous and binary trait) but I have never used R package to estimate Rg. However, I use R package for many of my other statistical analysis needs. The R package is a great tool that has advanced to a level that now we can estimate whole genome-enabled breeding values in genomic selection research. So, with the aim of moving out of those packages (listed above) which are either expensive or have little support, I would like to know if we can estimate Rg between two binary traits (disease status: alive vs. dead) with the R package. My data: we have 100 full-sib (FS) families, and two random samples (each with n= 200 FS fish) from each FS family were evaluated for resistance response to two different bacterial diseases, separately. It implies that both traits are not recorded in the same individual; each trait is recorded in different groups of full-sibs (random sampled from a FS family). So using this family relationship (full-sibs), I would like to estimate the Rg between these two disease resistance traits; of course I would like to estimate Rg with the R package. I will appreciate having directions on which R package to use if any, or combination of R functions needed to use to calculate the Rg (between two binary traits; disease survival traits). Thank you very much in advance for your help. Roger Roger L. Vallejo, Ph.D. U.S. Department of Agriculture, ARS, NCCCWA Voice: (304) 724-8340 Ext. 2141 Email: roger.vall...@ars.usda.govmailto:roger.vall...@ars.usda.gov http://www.ars.usda.gov/pandp/people/people.htm?personid=37662 This electronic message contains information generated by the USDA solely for the intended recipients. Any unauthorized interception of this message or the use or disclosure of the information it contains may violate the law and subject the violator to civil or criminal penalties. If you believe you have received this message in error, please notify the sender and delete the email immediately. [[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] R 2.11 on Mac OS X
RStudio questions belong on the RStudio support website. It is fine software, but it is off-topic here. --- 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. Norman Jessup njes...@tpg.com.au wrote: David, Thank you. You are correct - I was inadvertently accessing an old version. Deleting the old and re-installing means I can fire up R V3.0.1 which runs fine. However, I still can't get R Studio to start up, receivng the following message: ERROR r error 4 (R code execution error) [errormsg=Error in identical(call[[1L]], quote(doTryCatch)) : 7 arguments passed to .Internal(identical) which requires 5 , code=local(source(/Applications/RStudio.app/Contents/Resources/R/Tools.R, local=TRUE, echo=FALSE, verbose=FALSE, encoding='UTF-8'))]; OCCURRED AT: core::Error r::exec::anonymous namespace::evaluateExpressions(SEXP, SEXP, SEXP *, sexp::Protect *) /Users/rstudio/rstudio/src/cpp/r/RExec.cpp:145 Even though I re-installed the latest version 0.97.551. I wonder if there is an old Library or other support file that was not properly replaced? Thank you Norman Jessup On Jun 21, 2013, at 7:27 PM, Norman Jessup wrote: Hello, I've recently upgraded to R 2.11.1 on Mac OS X 10.8.4. Now when I start R up I get the following message: Error in identical(call[[1L]], quote(doTryCatch)) : 7 arguments passed to .Internal(identical) which requires 5 Error in normalizePath(dirname(pkgpath), /, TRUE) : 3 arguments passed to .Internal(normalizePath) which requires 1 cannot find system Renviron I get a similar message with user-defined functions ( i.e X arguments passed when Y defined ) though the functions appear to work. This problem is also encountered when Rstudio fires up and so it cannot run now. I did find a post that suggested it may be due to R accessing an old, possibly 32 bit library (I used to have 32 and 64 bit R installed and they both ran without trouble). Possibly I need to completely clean out the installation and start again? but I'm not sure precisely where the R support files are stored on Macs. Can anyone give me a pointer and/or suggest an alternative fix? R 2.11.1 is a rather archaic version. The current version is 3.0.1. You seems to have skipped major versions 2.12, 2.13,, 2.14 2.15. I doubt that OSX 10.8.4 was available when 2.11.1 was compiled. There is a mailing list for MacOS versions of R but I doubt there will be much interest in supporting version 2.11.1 on OSX 10.8.4. I suggest you install instead version 3.0.1 [[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] R CMD BATCH Unicode
Just because the subject mentions R doesn't mean it is on topic here. This is more related to Windows than R. I recommend studying windows documentation for awhile. A quick search turned up a number of discussions on the web, including http://stackoverflow.com/questions/1035388/unicode-output-on-windows-command-line. --- 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. Ned Harding n...@alteryx.com wrote: So just to clarify - there is no way to use R CMD BATCH on windows with Unicode? Any advice of how to use R in a batch mode with Unicode inputs and outputs? Ned. -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Prof Brian Ripley Sent: Wednesday, June 26, 2013 12:45 AM To: r-help@r-project.org Subject: Re: [R] R CMD BATCH Unicode On 25/06/2013 20:35, Ned Harding wrote: Just to clarify: The encoding didn't come through in the email. print(éíôåëëåãåâáè) is meant to be a bunch of random greek characters. In that case the message is likely correct. You failed to give us the 'at a minimum information' required by the posting guide, but you can only have input scripts in the locale encoding (and there are no UTF-8 locales on Windows). So unless you were in a Greek locale, the re-encoding should have failed. Ned. -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Ned Harding Sent: Tuesday, June 25, 2013 11:35 AM To: r-help@r-project.org Subject: [R] R CMD BATCH Unicode Hey, I am looking for some help using Unicode with R CMD BATCH on windows. In particular I would like my input and output files to be UTF-8 encoded. My command line looks like this: r CMD BATCH --encoding=UTF-8 in.txt out.txt in.txt is utf-8 encoded and contains: print(éíôåëëåãåâáè) out.txt gets: + ERROR: re-encoding failure from encoding 'UTF-8' What is the proper way to specify encoding on the command line? Thanks in advance, Ned. [[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. Please do, and note what it says about HTML mail, too. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R CMD BATCH Unicode
Well, I admit that I don't mess with this stuff much, but it worked fine for me in a simple test as long as I viewed the output with an editor or console that understood UTF-8, so I dispute your assertion that this is a problem internal to R. (I needed no special arguments to R for it to work either.) --- 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. Ned Harding n...@alteryx.com wrote: I have no problems with the windows command line. I don't need any Unicode there. It really is an internal R question because of the way R is reading and writing the input and output files. Ned. -Original Message- From: Jeff Newmiller [mailto:jdnew...@dcn.davis.ca.us] Sent: Wednesday, June 26, 2013 11:06 AM To: Ned Harding; Prof Brian Ripley; r-help@r-project.org Subject: Re: [R] R CMD BATCH Unicode Just because the subject mentions R doesn't mean it is on topic here. This is more related to Windows than R. I recommend studying windows documentation for awhile. A quick search turned up a number of discussions on the web, including http://stackoverflow.com/questions/1035388/unicode-output-on-windows-command-line. --- 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. Ned Harding n...@alteryx.com wrote: So just to clarify - there is no way to use R CMD BATCH on windows with Unicode? Any advice of how to use R in a batch mode with Unicode inputs and outputs? Ned. -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Prof Brian Ripley Sent: Wednesday, June 26, 2013 12:45 AM To: r-help@r-project.org Subject: Re: [R] R CMD BATCH Unicode On 25/06/2013 20:35, Ned Harding wrote: Just to clarify: The encoding didn't come through in the email. print(éíôåëëåãåâáè) is meant to be a bunch of random greek characters. In that case the message is likely correct. You failed to give us the 'at a minimum information' required by the posting guide, but you can only have input scripts in the locale encoding (and there are no UTF-8 locales on Windows). So unless you were in a Greek locale, the re-encoding should have failed. Ned. -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Ned Harding Sent: Tuesday, June 25, 2013 11:35 AM To: r-help@r-project.org Subject: [R] R CMD BATCH Unicode Hey, I am looking for some help using Unicode with R CMD BATCH on windows. In particular I would like my input and output files to be UTF-8 encoded. My command line looks like this: r CMD BATCH --encoding=UTF-8 in.txt out.txt in.txt is utf-8 encoded and contains: print(éíôåëëåãåâáè) out.txt gets: + ERROR: re-encoding failure from encoding 'UTF-8' What is the proper way to specify encoding on the command line? Thanks in advance, Ned. [[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. Please do, and note what it says about HTML mail, too. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Data Package Query
data is a base function (so you should not have to load any packages to use it), and it is not capitalized. Depending on the particular data set you want the data function to load, you may need to load the package that contains that data set. A common error by beginners (which may or may not be your problem in this case) is to create a variable called data. Unfortunately this hides the function named data and from that time forward that R session doesn't work when you type example code that uses the data function. If this is your problem, the best solution is to restart R and do your analysis from the beginning using a different variable name than data. (This is why keeping your working code in a separate text file is standard operating procedure.) Note that I am guessing here... the Posting Guide asks you to give a reproducible example so we don't have to guess what you have done. --- 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. Yasmine Refai y_re...@hotmail.com wrote: Hello, When i type in the below syntax: Data (name of the data set) I get an error message specifying that the data package is not found. Please note that i installed all packages having the word data included in them and loaded all these packages. Please advice. Regards! __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] [SPAM?] Re: Data Package Query
Please reply to all so the thread stays on the mailing list for all to see (and correct if wrong information is given). Regarding your code below, either you are missing a library statement to load a package that contains this trial data, or you are intending to read in your own data set but are not yet aware of how that is done. I could find no package containing a data set named trial (but I might have missed one). If you have some data of your own, then the data function is almost certainly not the right tool for the job. A PDF document called R Data Import/Export is supplied with R that can get you started. There are also various intro books available. --- 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. Yasmine Refai y_re...@hotmail.com wrote: Unfortunately, i have no variable called data. The below is the syntax i am running: data(trial) fit-logistf(data=trial, y=x1+x2+x3) Sorry for the disturbance. Regards! On Jun 27, 2013, at 9:47 AM, Jeff Newmiller jdnew...@dcn.davis.ca.us wrote: data is a base function (so you should not have to load any packages to use it), and it is not capitalized. Depending on the particular data set you want the data function to load, you may need to load the package that contains that data set. A common error by beginners (which may or may not be your problem in this case) is to create a variable called data. Unfortunately this hides the function named data and from that time forward that R session doesn't work when you type example code that uses the data function. If this is your problem, the best solution is to restart R and do your analysis from the beginning using a different variable name than data. (This is why keeping your working code in a separate text file is standard operating procedure.) Note that I am guessing here... the Posting Guide asks you to give a reproducible example so we don't have to guess what you have done. --- 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. Yasmine Refai y_re...@hotmail.com wrote: Hello, When i type in the below syntax: Data (name of the data set) I get an error message specifying that the data package is not found. Please note that i installed all packages having the word data included in them and loaded all these packages. Please advice. Regards! __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Data Package Query
You need to learn to execute one statement at a time in order to debug this yourself. Copy and paste is your friend. Hint: I already told you that the data function is inappropriate if the data does not come from a package. You should be learning to use the str(), head(), and ls() functions to explore your R in-memory environment, and use the built-in help system with the question mark (?str) or the help.search() and RSiteSearch() functions. --- 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. Yasmine Refai y_re...@hotmail.com wrote: hello, please advice what is wrong at the below syntax: Trial-read.table(Trial.txt,header=TRUE) Trial save.image(file=Trial.RData) data(Trial) fit-logistf(data=Trial, y~x1+x2) and here is the error I get: Warning message: In data(Trial) : data set ‘Trial’ not found regards, yasmine Date: Fri, 28 Jun 2013 10:29:21 +1200 From: rolf.tur...@xtra.co.nz To: jdnew...@dcn.davis.ca.us CC: y_re...@hotmail.com; r-help@r-project.org Subject: Re: [R] Data Package Query On 28/06/13 04:47, Jeff Newmiller wrote: SNIP A common error by beginners (which may or may not be your problem in this case) is to create a variable called data. Unfortunately this hides the function named data and from that time forward that R session doesn't work when you type example code that uses the data function. SNIP This is simply not true. I believe it *used* to be true, sometime wa back, but hasn't been true for years. The R language is much cleverer now. If there is a function melvin() somewhere on the search path and also a data object melvin (earlier on the search path) then doing melvin(whatever) will correctly call the function melvin() with no complaints. The R language can tell by the parentheses that you mean the *function* melvin and not the data object melvin. E.g. data - 42 require(akima) akima Error: object 'akima' not found data(akima) # No error message, nor nothin'! akima # The data set akima is displayed. All that being said it is ***BAD PRACTICE***, just in terms of comprehensibility and avoiding confusion, to give a data set set the same name as a function (either built in, or one of your own). fortune(dog) is relevant. cheers, Rolf Turner __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Bhattacharyya in R
There is a built-in guide to syntax called the help system. If you have read it you should be able to be mitre specific with your questions. I had never heard of this function. Your example code is not reproducible, nor does it indicate what result you got from running it. I used RSiteSearch(bhattacharya) and there appears to be a function bhattacharyya.matrix in the fpc package. The syntax indicated in the help for that function mentions wanting input matrices, not vectors. It also mentions another function bhattacharyya.dist which does accept vectors, but it does not accept the misclassification.bound argument. You should read the help file and ask more specific questions and provide reproducible examples per the Posting Guide recommendations. --- 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. Dzu dizem.ue...@alumni.fh-aachen.de wrote: Dear R-user, I am trying to apply bhattacharyya-distance function to my data. Did anybody use it before ? My code is the following #Bhattacharya Distance measure #a and b are vectors a - (1,2,3,4,2,2,2,2,2,2,2,1,4,5,6,-1,-1,-1,-1,-1,-3,-3,-3) b - (1.1,1.1,1.2,1.2,1.2,1.2,1.2,2.1,2.1,2.2,2.2,2,0,0,0,0,2,2,2,2,2,3.1,3.1) dist - bhattacharyya.matrix(a,b, misclassification.bound = TRUE) plot(dist) Could somebody give me a guide on the syntax ? Thanks Dizem -- View this message in context: http://r.789695.n4.nabble.com/Bhattacharyya-in-R-tp4670671.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] Lee carter model
The Posting Guide warns you to not post in HTML format (it messes up R code examples). It also warns you to supply reproducible examples (we should be able to paste your code into a fresh R session and see essentially what you see). The warning message means you have given the function a factor where it expected a numeric value (max does not work on factors). I suggest that you learn how to use the str() function on your data so you know that you have imported it successfully before you give it to analysis functions. You may need to review the Introduction to R and R Data Import/Export PDF files that come with R if you don't know what a factor is or how to import numeric data. --- 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. ntamjo achille ntamjo2...@yahoo.fr wrote: Hi everybody, I'm running codes for for a Lee carter modeling. I compute the demogdata function in the package demography.� Age is a class of factor Base-demogdata(data=x,pop=y,ages=AGE,years=YEAR,type=mortality,label=City,name=Hommes,lambda=1) � Now, I try to run codes for lee carter model, and i always get the following message: Error in Summary.factor(c(1L, 2L, 24L, 35L, 46L, 57L, 68L, 79L, 90L, 101L, �:� � max not meaningful for factors Please can you help to understand what means this message.� Many Thanks Achille [[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] Outer function in R
Read the Posting Guide. The example you provide below is not reproducible [1], so we cannot tell what you're giving to the outer() function. [1] http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example --- 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. Dzu dizem.ue...@alumni.fh-aachen.de wrote: Dear members I am trying to apply the function kl.dist (Kullback-Leibler Distance measure) to multiple matrixes. I tried the following : veckldist - Vectorize(kl.dist) distancematrix - outer (matrix1,matrix2, veckldist) But the code is complaining that the list of the object does not match. The lengths of my matrixes are same How could I fix the error? Thanks -- View this message in context: http://r.789695.n4.nabble.com/Outer-function-in-R-tp4670738.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] What package to use to download pictures and its description from server?
Wouldn't this be highly dependent on how the pictures and descriptions were formatted online, as well as what you planned to do with them? I generally find that a web browser is quite sufficient for my needs. --- 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. C W tmrs...@gmail.com wrote: Hi R community, What package would you recommend to download pictures and descriptions of the pictures? I have looked at package XML and RCurl so far. Is this what everyone uses? Thanks, Mike __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] acf question...
Then you are posting in the wrong forum, since this is a forum about getting R to do things for which you already understand the theory. As to the results you are getting, I highly recommend reading the details section of ?ccf. BTW The Posting Guide indicates that you should post in text format because HTML mutilates R code. This is a setting in your email program. --- 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. Venkatesh Nagarajan goca...@yahoo.com wrote: I am trying to understand lagged correlations. � x= 1:100; y = c(rep(NA,40), 1:60)ccf(x = x, y = y, lag.max=100, na.action=na.pass, type = correlation) � I was hoping to see max cor at lag = 40. But I am not. What am I doing wrong? � Thanks VN [[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.