Re: [R] finding components of an API
Erin, I do not think there is an R package that will enable you to get the data you would like from spotcrime.com. You could write code, in R, or some other language, to extract the data you want but that is going to be a changeling task and if the website changes its format then your code may suddenly stop working. Also, the people who run spotcrime.com may not be happy if you do so. Bob On 5/28/2017 4:45 PM, Erin Hodgess wrote: Sorry!!! It's spotcrime.com, and I would like to use it via R for crimes. On Sun, May 28, 2017 at 2:19 PM, Jeff Newmillerwrote: Can you please be just a little less vague? What API are you talking about, and how is this related to R? -- Sent from my phone. Please excuse my brevity. On May 28, 2017 11:48:42 AM PDT, Erin Hodgess wrote: Hello! I would like to use a particular API for crimes (spot crimes) but I can't find what components go into the API. I have gone into the website,but to no avail Has anyone used it please? Thank you, Sincerely, Erin __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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] lines those not started with "rs"
then my solution should work. Bob On 1/30/2017 9:44 AM, greg holly wrote: > Hi Robert; > > I do appreciate your advice. Only the first column of the data is > text. The rest columns are numeric. > > Regards, > > Greg > > On Mon, Jan 30, 2017 at 9:36 AM, Robert Sherry <rsher...@comcast.net > <mailto:rsher...@comcast.net>> wrote: > > Greg, > > I am assuming that your data is in a text file. R is a good tool > but not the tool I would use for this job. The tool I would > use is grep. The following command should get you want you want: > grep -v "^rs" > > Bob > > > On 1/30/2017 9:23 AM, greg holly wrote: > > Hi all; > > I have a file which has about 3.000.000 lines. Most of the > lines at first > column start with "rs", for example, rs1056, rs1076 > and so on. I > would like to get the lines which do not start with "rs" . > Your helps > highly appreciated. > > Regards, > > Greg > > [[alternative HTML version deleted]] > > __ > R-help@r-project.org <mailto:R-help@r-project.org> mailing > list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > <https://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 <mailto:R-help@r-project.org> mailing list -- > To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > <https://stat.ethz.ch/mailman/listinfo/r-help> > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > <http://www.R-project.org/posting-guide.html> > and provide commented, minimal, self-contained, reproducible code. > > [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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] lines those not started with "rs"
Greg, I am assuming that your data is in a text file. R is a good tool but not the tool I would use for this job. The tool I would use is grep. The following command should get you want you want: grep -v "^rs" Bob On 1/30/2017 9:23 AM, greg holly wrote: Hi all; I have a file which has about 3.000.000 lines. Most of the lines at first column start with "rs", for example, rs1056, rs1076 and so on. I would like to get the lines which do not start with "rs" . Your helps highly appreciated. Regards, Greg [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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)
Here is one thought. Assign each month a value of 0, 1 or 2. Then do a simple linear regression analysis where the value of the month is the independent variable. You can also do multiple linear regression with the value you assigned to the month plus the other factors that you believe are causing a change to your data. Time is the one that comes to my mind. You can do this with the standard R function lm. I hope this helps. Bob On 1/30/2017 9:11 AM, Kwesi Quagraine wrote: Hello, I have a data with two variables nodes and index, I want to extract 3 months seasons, with a shift of 1 month, that is, DJF, JFM, FMA etc to OND. Was wondering how to go about it. Kindly find data sample below, data is in csv format. Any help will be appreciated. My data sample; era...1.Node_freq MEI 1 1980-01-01 -0.389855332 0.3394196488 2 1980-02-01 -0.728019153 0.2483738232 3 1980-03-01 -1.992457784 0.3516954904 4 1980-04-01 0.222760284 0.5736836269 5 1980-05-01 0.972601798 0.6289249144 6 1980-06-01 0.570725954 0.5736836269 7 1980-07-01 -0.977966324 0.4120517119 8 1980-08-01 0.056128836 -0.0104418383 9 1980-09-01 0.987304573 -0.0687520861 10 1980-10-01 1.188242495 -0.1403611624 11 1980-11-01 1.693037763 -0.0963727298 12 1980-12-01 1.173539720 -0.2539126977 13 1981-01-01 0.423698206 -0.6140040528 14 1981-02-01 -2.208098481 -0.5209122536 15 1981-03-01 -0.786830252 0.1133395650 16 1981-04-01 -0.110502611 0.3302127675 17 1981-05-01 -1.272021820 -0.1894645290 18 1981-06-01 0.394292656 -0.3736021538 19 1981-07-01 1.452892441 -0.4032687711 20 1981-08-01 0.698150002 -0.4441882433 21 1981-09-01 0.997106423 -0.1720737534 22 1981-10-01 0.247264908 -0.2436828296 23 1981-11-01 0.771663876 -0.3909929295 24 1981-12-01 -0.316341458 -0.4943145967 Regards, Kwesi __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] for loop in R
I only see one for loop in your code. I am wondering if you want a second for loop based upon the length of newdata. I would also think that you do not need the second call to set.seed. Bob On 1/12/2017 4:44 PM, Jennifer Sheng wrote: Dear friends, I am working on a double loop using for. One level of loop is to predict N times for each subject, and the second level is to predict M times for the every subject, one subject after one subject. Please note every subject have different N or M rows of data. Any advice? Thank you so much! Below is the current code: set.seed (123) ## for consistent result; ND <- S004Cmin[S004Cmin$ID %in% c(1:10),] # define the first 10 subjects predSurv <- vector("list", nrow(ND)) for (i in 1:nrow(ND)) { set.seed(123) predSurv[[i]] <- survfitJM(fitJOINT.NULL, newdata = ND[1:i, ], idVar="USUBJID") } Thank you very much! Jenny [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to speed up my program
Hi Ragia, First, when you wrote mad, I assume you mean made. Also, when you say it is a multi core prog, does that mean it is using threads? running two or more items in parallel? By any chance are you using this package? https://stat.ethz.ch/R-manual/R-devel/library/parallel/doc/parallel.pdf If not, maybe you should. There is also a new version of R called pqR. It is multi thread and that maybe exactly what you need. Also R is interpreted not compiled. Therefore if speed is important rewriting it in a compiled language like C or C++ could be a whole lot faster. I suspect that this would also be a lot of work and probably not worth it. Bob On 4/1/2016 4:01 AM, Ragia . wrote: Dear group I had a R program that was to slow, I mad it multi core prog..to speed up, its a simulation when the runs are 100 its very fast..raising the runs to 10k mad it in the first fast then it slow down I checked the HW usafe and here is the top command results %Cpu0 :100.0 us, 0.0 sy, 0.0 ni, 0.0 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st %Cpu1 :100.0 us, 0.0 sy, 0.0 ni, 0.0 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st %Cpu2 :100.0 us, 0.0 sy, 0.0 ni, 0.0 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st %Cpu3 :100.0 us, 0.0 sy, 0.0 ni, 0.0 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st %Cpu4 :100.0 us, 0.0 sy, 0.0 ni, 0.0 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st %Cpu5 :100.0 us, 0.0 sy, 0.0 ni, 0.0 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st %Cpu6 :100.0 us, 0.0 sy, 0.0 ni, 0.0 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st %Cpu7 :100.0 us, 0.0 sy, 0.0 ni, 0.0 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st KiB Mem: 65863948 total, 13940104 used, 51923844 free, 231084 buffers KiB Swap: 1046520 total,0 used, 1046520 free. 4418180 cached Mem what should I do to speed it up? thanks in advance __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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] Open source project that needs performance optimizations
I am not up on the internals of R but there does seem some run for parallelism. Are we talking about special hardware? or running this on an Intel Box? If it is the second, then I am thinking threads would be the way to go. Please consider the following R statements: for( i in 1:30 )a[i] = f1(i) Would it make sense to setup a separate thread for each call to f1? I think it in most cases, the answer is no but on some machines and depending on the running time of f1, it could be a big win. Also, does the user have to change his code, or would R be smart enough to do the work behind the scenes. I consider the second to be significantly better than the first. You may also want to look at the following URL http://stackoverflow.com/questions/1395309/how-to-make-r-use-all-processors Bob On 3/27/2016 11:52 AM, PSATHAS NILOS-HRISTOS wrote: Hello, i am an undergraduate student on computer engineering and im considering to do my thesis to an open source project and make performance optimizations and/or add parallelism to it where possible (or even better make use of GPU). Do you think that R-project is a good candidate? Thanks, Psathas Neilos __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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] Double AND within an IF statement
This should work: if ( age > 4 && age < 8 && infection > 0 ) replacement = 2 Bob On 2/24/2016 7:08 AM, Polychronis KOSTOULAS wrote: Hi there, apologies if this is easy. I want to write this condition: If age is more than 4 years and less or equal to 8 years and infection is positive then replacement is 2. Can you help me the double END? Thanks, Polychronis __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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] Variable Argument Function
I would like to write a function in R that would take a variable number of integers as parameters. I do not have a pressing reason to do this, I am just trying to learn R. I thought a good first step would be to print out the arguments. So I wrote the following function: f1 = function (...) { list1 = as.list(...) for( i in 1:length(list1) ) cat( "i is ", list1[[i]], "\n" ) return (0) } I ran it as: f1(2,4,10,12) and I get: i is 2 [1] 0 I was hoping for i is 2 i is 4 i is 10 i is 12 I am hoping somebody can tell me what I am doing wrong. Is using a list a bad idea? Thanks Bob __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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] Variable Argument Function
Ben, Your solution solved my issue. Thank you. I do not see a need for a nested function. Based upon your solution, I came up with this solution: fbob = function (...) { l1 = list(...) for( i in 1:length(l1) ) cat( "i is ", l1[[i]], "\n" ) return (0); } It does not use nested functions and it works also. Is there a reason why your solution is better? Bob On 2/7/2016 7:14 PM, Ben Tupper wrote: Hi, On Feb 7, 2016, at 6:24 PM, Duncan Murdoch <murdoch.dun...@gmail.com> wrote: On 07/02/2016 6:12 PM, Robert Sherry wrote: I would like to write a function in R that would take a variable number of integers as parameters. I do not have a pressing reason to do this, I am just trying to learn R. I thought a good first step would be to print out the arguments. So I wrote the following function: f1 = function (...) { list1 = as.list(...) This is wrong. The ... object is weird; it's not something that can be coerced to a list. However, you can pass it as list(...) and it will give you what you were expecting. Do you mean that Bob should nest a function within f1? Like this? f1 = function (...){ f2 <- function(list1){ for( i in 1:length(list1) ) cat( "i is ", list1[[i]], "\n" ) return (0) } f2(list(...)) } f1(2,4,10,12) f1(2,4,10,12) i is 2 i is 4 i is 10 i is 12 Ben The theory is that it will expand to multiple arguments to the list() function, which constructs a list containing them. as.list() doesn't want a bunch of arguments, it will just ignore most of them. Duncan Murdoch for( i in 1:length(list1) ) cat( "i is ", list1[[i]], "\n" ) return (0) } I ran it as: f1(2,4,10,12) and I get: i is 2 [1] 0 I was hoping for i is 2 i is 4 i is 10 i is 12 I am hoping somebody can tell me what I am doing wrong. Is using a list a bad idea? Thanks Bob __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Ben Tupper Bigelow Laboratory for Ocean Sciences 60 Bigelow Drive, P.O. Box 380 East Boothbay, Maine 04544 http://www.bigelow.org __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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] Sorting a Data Frame
Thank you for the response. As expected, the following expression worked: df[order(df$x),] I would expect the following expression to work also: df[order(df$x)] However it does not. That is, the comma is needed. Please tell me why the comma is there. Thanks Bob On 1/26/2016 8:19 AM, S Ellison wrote: On 23.01.2016 01:21, Robert Sherry wrote: In R, I run the following commands: df = data.frame( x=runif(10), y=runif(10) ) df2 = df[order(x),] You use another x from your workspace, you actually want to df2 = df[order(df[,"x"]),] or df[order(df$x),] And just to prevent yet more confusion, you might also want to avoid 'df' as a name. 'df' is the function that returns the density of the F distribution ... S Ellison *** This email and any attachments are confidential. Any use...{{dropped:8}} __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guidehttp://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R-help mailing list activity / R-not-help?
I think this mailing list is wonderful and it has helped me a lot. In fact, I am not sure I would be using R today if it was not for this list. Bob On 1/24/2016 4:42 PM, Michael Friendly wrote: On 1/23/2016 7:28 AM, Jean-Luc Dupouey wrote: Dear members, Not a technical question: But one worth raising... The number of threads in this mailing list, following a long period of increase, has been regularly and strongly decreasing since 2010, passing from more than 40K threads to less than 11K threads last year. The trend is similar for most of the "ancient" mailing lists of the R-project. [snip ...] I hope it is the wright place to ask this question. Thanks in advance, In addition to the other replies, there is another trend I've seen that has actively worked to suppress discussion on R-help and move it elsewhere. The general things: - R-help was too unwieldy and so it was a good idea to hive-off specialized topics to various sub lists, R-SIG-Mac, R-SIG-Geo, etc. - Many people posted badly-formed questions to R-help, and so it was a good idea to develop and refer to the posting guide to mitigate the number of purely junk postings. Yet, the trend I've seen is one of increasing **R-not-help**, in that there are many posts, often by new R users who get replies that not infrequently range from just mildly off-putting to actively hostile: - Is this homework? We don't do homework (sometimes false alarms, where the OP has to reply to say it is not) - Didn't you bother to do your homework, RTFM, or Google? - This is off-topic because XXX (e.g., it is not strictly an R programming question). - You asked about doing XXX, but this is a stupid thing to want to do. - Don't ask here; you need to talk to a statistical consultant. I find this sad in a public mailing list sent to all R-help subscribers and I sometimes cringe when I read replies to people who were actually trying to get help with some R-related problem, but expressed it badly, didn't know exactly what to ask for, or how to format it, or somehow motivated a frequent-replier to publicly dis the OP. On the other hand, I still see a spirit of great generosity among some people who frequently reply to R-help, taking a possibly badly posed or ill-formatted question, and going to some lengths to provide a a helpful answer of some sort. I applaud those who take the time and effort to do this. I use R in a number of my courses, and used to advise students to post to R-help for general programming questions (not just homework) they couldn't solve. I don't do this any more, because several of them reported a negative experience. In contrast, in the Stackexchange model, there are numerous sublists cross-classified by their tags. If I have a specific knitr, ggplot2, LaTeX, or statistical modeling question, I'm now more likely to post it there, and the worst that can happen is that no one "upvotes" it or someone (helpfully) marks it as a duplicate of a similar question. But comments there are not propagated to all subscribers, and those who reply helpfully, can see their solutions accepted or not, or commented on in that specific topic. Perhaps one solution would be to create a new "R-not-help" list where, as in a Monty Python skit, people could be directed there to be insulted and all these unhelpful replies could be sent. A milder alternative is to encourage some R-help subscribers to click the "Don't send" or "Save" button and think better of their replies. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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] Sorting a Data Frame
In R, I run the following commands: df = data.frame( x=runif(10), y=runif(10) ) df2 = df[order(x),] The first, as I would expect, creates a data frame with two columns and 10 rows. I expect the second to sort the data based upon the columns x and produce a new data frame, df2, with the same size as df. However, the data frame is produces is much larger. I do not understand what is going on. I am hoping somebody can help me. I am also wondering if I should have a comma after order(x) in the second statement. I do not see a purpose for it but it was in an example on the web. Thanks Bob __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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] F Distribution
When I use a table, from a Schaum book, I see that for the 95 percentile, with v_1 = 1 and v_2 = 1 the value is 161. In the modern era, looking values up in a table is less than ideal. Therefore, I would expect R to have a function to do this and based upon my reading of the documentation, I would expect the following call to get the value I expect: pf( .95,1, 1) However, it produces 0.4918373 Therefore, I conclude that I am using the wrong function. What function should I use? Thanks Bob __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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] not allocate of vactor size
I am thinking that R is running out of memory. Therefore, I would look to increase the size of my virtual memory. Here are two links that might help you with that: http://windows.microsoft.com/en-us/windows/change-virtual-memory-size#1TC=windows-7 http://www.ehow.com/how_5001512_increase-virtual-memory-linux.html Bob On 11/22/2015 10:08 AM, Tamsila Parveen via R-help wrote: Hello, Is there anyone to help me out how can I resolve memory issue of R, when I want to analyze data of 1Gb file, R returns me Error: not allocate of vector size of 1.8 GB.I tried on linux as well as on windows with 64 bit system and using 64 bit R-3.2.2 version. So anyone who knows please guide me to resolve this issue [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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] QuantMod and XML
I am trying to use the package quantmod to get option quotes in R. Therefore, I executed the following two commands: library ("quantmod" ) getOptionChain("AAPL") The first one worked but the second one produced the following error message: Error in getOptionChain.yahoo(Symbols = "AAPL") : package:“XML”cannot be loaded. Therefore, I am thinking I need to install the package XML. To do so, I executed the following command: install.packages( "XML" ) However, that command failed because it could not find the package XML. The following URL: https://cran.r-project.org/web/packages/XML/XML.pdf indicates to me that it does exist. I am hoping somebody can tell me what I am doing wrong. Thanks Bob __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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] QuantMod and XML
Thanks for the response. I am currently using Windows 7. I tried the following command: install.packages("XML", repos = "http://www.omegahat.org/R;) and I got: Installing package into ‘C:/Users/Bob/Documents/R/win-library/3.1’ (as ‘lib’ is unspecified) Warning: unable to access index for repository http://www.omegahat.org/R/bin/windows/contrib/3.1 package ‘XML’ is available as a source package but not as a binary Warning message: package ‘XML’ is not available (for R version 3.1.2) I also tried this command: install.packages("RSXML", repos = "http://www.omegahat.org/R;) and I got: Installing package into ‘C:/Users/Bob/Documents/R/win-library/3.1’ (as ‘lib’ is unspecified) Warning: unable to access index for repository http://www.omegahat.org/R/bin/windows/contrib/3.1 Warning message: package ‘RSXML’ is not available (for R version 3.1.2) I am wondering why it is not work. Please help. Thanks Bob On 11/7/2015 6:41 PM, Hasan Diwan wrote: > Bob, > > On 7 November 2015 at 15:27, Robert Sherry <rsher...@comcast.net > <mailto:rsher...@comcast.net>> wrote: > > > I am trying to use the package quantmod to get option quotes in R. > Therefore, I executed the following two commands: > library ("quantmod" ) > getOptionChain("AAPL") > The first one worked but the second one produced the following > error message: > Error in getOptionChain.yahoo(Symbols = "AAPL") : > package:“XML”cannot be loaded. > Therefore, I am thinking I need to install the package XML. To do > so, I executed the following command: > install.packages( "XML" ) > However, that command failed because it could not find the package > XML. The following URL: > https://cran.r-project.org/web/packages/XML/XML.pdf > indicates to me that it does exist. > > > It also shows its webpage to be at http://www.omegahat.org/RSXML. On > the root of the site -- http://www.omegahat.org -- the installation > command is given as install.packages(packageName, repos = > "http://www.omegahat.org/R;). So perhaps, you should try > install.packages("XML", repos = "http://www.omegahat.org/R;) or > install.packages("RSXML", repos = "http://www.omegahat.org/R;) as one > of those two should get you what you want. Hope that helped... -- H > > > I am hoping somebody can tell me what I am doing wrong. > > Thanks > Bob > > __ > R-help@r-project.org <mailto:R-help@r-project.org> mailing list -- > To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > > > > > -- > OpenPGP: https://hasan.d8u.us/gpg.key > Sent from my mobile device > Envoyé de mon portable [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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] Working with Data Frames
I have created what I believe to be a data frame. It is called env1$SPY. The r statement head( env1$SPY ) produces the following output: SPY.Open SPY.High SPY.Low SPY.Close SPY.Volume SPY.Adjusted 1995-01-03 45.7031 45.8437 45.6875 45.7812 324300 31.55312 1995-01-04 45.9843 46. 45.7500 46. 351800 31.70392 1995-01-05 46.0312 46.1093 45.9531 46. 89800 31.70392 1995-01-06 46.0937 46.2500 45.9062 46.0468 448400 31.73617 1995-01-09 46.0312 46.0937 46. 46.0937 36800 31.76850 1995-01-10 46.2031 46.3906 46.1406 46.1406 229800 31.80082 The above data from was created by the following commands: library( quantmod ) env1 <- new.env() getSymbols("SPY", src = 'yahoo', from = '1995-01-01', env = env1, auto.assign = T) Now, what I want to do is to loo through the data look for when the month changes. What is the proper way of writing a for loop in R and access the date field? Bob __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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] Interview questions?
Here is a question that I might ask. What are the alternatives to R and how does R compare? That is, for what class of problems is R the best tool around? Bob On 1/11/2015 1:16 PM, Barry Rowlingson wrote: Ask if they have a favourite R programmer. This will tell you how much into the R culture they are, and perhaps also tell you if their opinions of a good programmer concur with yours... On 11 Jan 2015 16:49, Keith S Weintraub kw1...@gmail.com wrote: Folks, I was wondering if anyone has put together a list of R job interview questions? I’m thinking of about 5-20 possibly open ended questions for interviewing a candidate to do R programming. Just programming. Not statistics or mathematics. What I don’t want are tricky “puzzles” that are more about how clever the interviewer questions are than how to get the best person for the job. I would consider myself a mid-level R programmer so this would also be a great opportunity to learn more and be able to hire a great candidate. I am perfectly happy to get a reference, book title or URL. Not looking for anyone to do my work for me! Best to all, Happy New Year, KW __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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 Getting the Price of Gold
I am trying to get the current price of gold for my application. I am using the library quantmod. The R commands I use are: getMetals(c('XAU'), from=Sys.Date(), autoassign = FALSE ) XAUUSD$XAU.USD[1,1] I would expect the value in XAUUSD$XAU.USD[1,1] to be a scalar but it comes back with a date and a number. All I want is the current value, not today's date. How do I just get the value? Thanks Bob [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Problem getting Option Quotes
I am using R and quantmod to get stock and option quotes. However, it has stopped working. I expect the following function call to produce a list of options: getOptionChain( XOM, Exp = 2015-01-20 ) However, I get the following error messages: Error in lapply(strsplit(opt, tr), function(.) gsub(,, , gsub(N/A, : subscript out of bounds In addition: Warning message: In readLines(paste(paste(http://finance.yahoo.com/q/op?s=;, Symbols, : incomplete final line found on 'http://finance.yahoo.com/q/op?s=XOMm=2015-01-20+Options' Has something changed? Am I doing something wrong? Thanks Bob __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Using R to Compute Covariance
I have the following data set: xy p 11 1/2 22 1/4 39 1/4 In this case, p represents the probability of the values occurring. I compute the covariance of x and y by hand and come up with a value of 41/16. When computing the covariance, I am dividing by n (in this case 3) not n-1. I now want to use R to find the covarinace. I understand that R will divided by n-1 not n. Here are the commands that I issued: x = c(1,2,3) y = c(1,2,9) df =dataframe(x,y) w1 = c(1/2,1/4,1/4) cov.wt(df, wt = w1 ) The last command returns: $cov xy x 1.1 4.1 y 4.1 17.9 $center xy 1.75 3.25 $n.obs [1] 3 $wt [1] 0.50 0.25 0.25 Therefore, I conclude that R is finding the covariance of x and y to be 4.1. However, I need to adjust that number by multiplying it by 2 and then dividing by 3. However, when I get that I still do not get 41/16. What am I missing? I thank the group in advance for their responses. Bob __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Using R to Compute Covariance
David, Thanks for the response. I believe you have solved my problem. Bob On 7/26/2014 3:50 PM, David Winsemius wrote: On Jul 26, 2014, at 11:07 AM, Robert Sherry wrote: I have the following data set: xy p 11 1/2 22 1/4 39 1/4 In this case, p represents the probability of the values occurring. I compute the covariance of x and y by hand and come up with a value of 41/16. When computing the covariance, I am dividing by n (in this case 3) not n-1. I now want to use R to find the [covariance]. I understand that R will [divide] by n-1 not n. Please read what the help page says about the choice of the method parameter. Here are the commands that I issued: x = c(1,2,3) y = c(1,2,9) df =dataframe(x,y) # There's no function named 'dataframe'.\\ df =data.frame(x,y) w1 = c(1/2,1/4,1/4) cov.wt(df, wt = w1 ) cov.wt(df, wt = w1 ,method=ML)$cov[2,1] [1] 2.5625 all.equal (41/16, cov.wt(df, wt = w1 ,method=ML)$cov[2,1] ) [1] TRUE The last command returns: $cov xy x 1.1 4.1 y 4.1 17.9 $center xy 1.75 3.25 $n.obs [1] 3 $wt [1] 0.50 0.25 0.25 Therefore, I conclude that R is finding the covariance of x and y to be 4.1. However, I need to adjust that number by multiplying it by 2 and then dividing by 3. However, when I get that I still do not get 41/16. What am I missing? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Correlation
Please consider the following R Script: x = c(1,2,3) y = c(1,2,9) cor(x,y) These three lines will produce, as I expected, the correlation between the variables x and y. However, R is going to assume that the probability that x = 1 is the same as the probability that x = 2. Suppose I know the probability that x = 1 is 0.5 and the probability that x = 2 (or x = 3 ) is 0.25. I believe that would effect the correlation between the variables x and y. How do I tell R about these probabilities? I thank the group in advance for their responses to this post. Bob __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] A Question about read.table and Data Frames in R
I created the following file: symbol,shares XOM,1000 APA,400 CVX,200 I then read the file in R using the command: stockList=read.table(/NotesOnR/stockList, header = T, sep=,) I would then expect the following expression to evaluate to the simple string APA: stockList$symbol[2] However when I type that in on the command line, I get: [1] APA Levels: APA CVX XOM I would also expect to be able to print out the table by using the command: for( i in 1:3 ) { print( stockList$symbol[i] ) print ( stockList$shares[i] ) } However, as part of the output I get: Levels: APA CVX XOM I do not understand what is going on. Also, when I try passing the expression stockList$symbol to a standard function in R, it does not work. I think that I am missing something here but I am not sure what I am missing. Should I be writing code like: for ( i in stockList$smybol ) However, given the symbol, I am not sure how to get the share count that is in the same row. I thank the group in advance for their responses. Bob __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Data Frame Members
Suppose that a data frame has been created by the user. Perhaps it has been created using the library quantmod. Is there any command to find out what the members of the data frame is? Thanks Bob __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.