[R] qq-plot in R
Hi, I am some questions on qq-plot offered by R. Let say I have following qq-plot: qqplot(rt(300, df = 5), rt(300, df = 5)) However I want to get more controls to define the range of x-axis as well as y-axis. For example I want to define that, x-axis range will be -10 to 10 and y-axis range will be 0-10 (just an example on what I am looking for). Additionally I want to get the entire list of (x,y) coordinates for all plotted points. Basically one my goals is to draw multiple different qq-plots onto same plot-window, with my optimally chosen range of x y axes. Can somebody here guide me how to achieve that? Appreciate your pointers and help. 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] A basic statistics question
Hi, I would need to get a clarification on a quite fundamental statistics property, hope expeRts here would not mind if I post that here. I leant that variance-covariance matrix of the standardized data is equal to the correlation matrix for the unstandardized data. So I used following data. Data - structure(c(7L, 5L, 9L, 7L, 8L, 7L, 6L, 6L, 5L, 7L, 8L, 6L, 7L, 7L, 6L, 7L, 7L, 6L, 8L, 6L, 7L, 7L, 7L, 8L, 7L, 9L, 8L, 7L, 7L, 0L, 10L, 10L, 10L, 7L, 6L, 8L, 5L, 5L, 6L, 6L, 7L, 11L, 9L, 10L, 0L, 13L, 13L, 10L, 7L, 7L, 7L, 10L, 7L, 5L, 8L, 7L, 10L, 10L, 10L, 6L, 7L, 6L, 6L, 8L, 8L, 7L, 7L, 7L, 7L, 8L, 7L, 8L, 6L, 6L, 8L, 7L, 4L, 7L, 7L, 10L, 10L, 6L, 7L, 7L, 12L, 12L, 8L, 5L, 5L, 5L, 5L, 6L, 6L, 6L, 6L, 6L, 7L, 7L, 5L, 4L, 5L, 5L, 5L, 6L, 7L, 5L, 7L, 5L, 7L, 7L, 7L, 7L, 8L, 7L, 6L, 7L, 7L, 6L, 7L, 7L, 6L, 4L, 4L, 6L, 6L, 7L, 8L, 7L, 11L, 10L, 8L, 7L, 6L, 6L, 11L, 5L, 4L, 6L, 6L, 6L, 7L, 8L, 7L, 12L, 4L, 4L, 2L, 5L, 6L, 7L, 6L, 6L, 5L, 6L, 5L, 7L, 7L, 7L, 6L, 5L, 6L, 6L, 5L, 5L, 6L, 6L, 4L, 4L, 5L, 10L, 10L, 7L, 7L, 6L, 4L, 6L, 10L, 7L, 4L, 6L, 6L, 6L, 8L, 8L, 8L, 7L, 8L, 9L, 10L, 7L, 6L, 6L, 8L, 6L, 8L, 3L, 3L, 4L, 5L, 5L, 6L, 5L, 5L, 6L, 4L, 8L, 7L, 3L, 5L, 6L, 9L, 8L, 9L, 10L, 8L, 9L, 8L, 9L, 8L, 8L, 9L, 11L, 10L, 9L, 9L, 13L, 13L, 10L, 7L, 7L, 7L, 9L, 8L, 7L, 6L, 10L, 8L, 7L, 8L, 8L, 3L, 4L, 3L, 7L, 6L, 6L, 6L, 6L, 5L, 6L, 6L, 6L, 2L, 5L, 7L, 9L, 8L, 9L, 10L, 8L, 8L, 9L, 9L, 11L, 11L, 11L, 10L, 9L, 9L, 11L, 2L, 3L, 2L, 2L, 2L, 1L, 4L, 4L, 2L, 2L, 1L, 1L, 1L, 3L, 3L, 4L, 6L, 4L, 5L, 2L, 3L, 5L, 4L, 4L, 2L, 4L, 4L, 5L, 4L, 2L, 7L, 3L, 3L, 10L, 13L, 11L, 9L, 9L, 7L, 8L, 9L, 6L, 7L, 6L, 5L, 3L, 13L, 3L, 3L, 0L, 1L, 4L, 5L, 3L, 3L, 0L, 2L, 20L, 3L, 2L, 6L, 5L, 5L, 5L, 2L, 2L, 5L, 5L, 5L, 4L, 3L, 4L, 4L, 3L, 4L, 10L, 10L, 9L, 8L, 4L, 4L, 8L, 7L, 10L, 3L, 1L, 9L, 5L, 11L, 9L), .Dim = c(45L, 8L), .Dimnames = list(NULL, c(V1, V7, V13, V19, V25, V31, V37, V43))) Data_Normalized - apply(Data, 2, function(x) return((x - mean(x))/sd(x))) (t(Data_Normalized) %*% Data_Normalized)/dim(Data_Normalized)[1] Point is that I am not getting exact CORR matrix. Can somebody point me what I am missing here? Thanks for your pointer. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Possible pair of 2 binary vectors
Hi, Let say I have 2 binary vectors of length 'd', therefore both these vectors can take only 0-1 values. Now I want to simulate all possible pairs of them. Theoretically there will be 4^d possible pairs. Is there any R function to directly simulate them? Thanks for your help. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] A question on graphical representation
Hi, Let say I Have following data: Info - structure(list(Person = structure(1:6, .Label = c(A, B, C, + D, E, F), class = factor), Attr1 = c(0.52, 0.14, 0.63, + 0.43, 0.89, 18.46), Attr2 = c(0.06, 3.35, 0.62, 1.42, 1.96, 8.38 + )), .Names = c(Person, Attr1, Attr2), row.names = c(NA, + -6L), class = data.frame) Info Person Attr1 Attr2 1 A 0.52 0.06 2 B 0.14 3.35 3 C 0.63 0.62 4 D 0.43 1.42 5 E 0.89 1.96 6 F 18.46 8.38 Diff - Info[, 'Attr1'] - Info[, 'Attr2'] Diff [1] 0.46 -3.21 0.01 -0.99 -1.07 10.08 Overall_Diff - sum(Diff) Overall_Diff [1] 5.28 Now we see that the overall difference between attribute-1 and attribute-2 for persons A-F is 5.28. Now I was asked this question: tell me out of that overall difference, how much is attributed to person A, person B, person F? In case the 'Diff' variable all have positive values, I probably consider making a pie-chart. However this is not possible (probably) in this present case, because some values are negative and some values are positive. So my question is how to build a robust graphical representation to answer this question? Your help will be highly appreciated. Thanks for your pointer. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 calculation in data.frame
Hi, I have to perform some formula driven calculation in a data.frame (as defined below). Let say I have following DF: DF - data.frame(A1 = c('a', 'a', 'a', 'b', 'b', 'b', 'c', 'c', 'c'), A2 = c('m', 'n', 'p', 'm', 'n', 'p', 'm', 'n', 'p'), A3 = c(1,2,3,4,5,6,7,8,9)) DF A1 A2 A3 1 a m 1 2 a n 2 3 a p 3 4 b m 4 5 b n 5 6 b p 6 7 c m 7 8 c n 8 9 c p 9 Now let say, user gives one formula which will be applied on the elements of A1 column. Let say the formula looks like: z = a + 2*b + c (infact the formula will be arbitrary like z = f(a, b, c)) Once such formula is given, the result will be like (for the columns A1, A2, A3 respectively) z m 16 z n 20 z p 24 the last column comes from the fact that 1 + 2*4 + 7 = 16, 2 + 2*5 + 8 = 20, 3 + 2*6 + 9 = 24 Given that the formula wil be user defined, and to be applied on some data.frame like DF, I am seeking some automated way to accomplice the task for really big DF of previous kind and fairly complex formula. Can somebody suggest me for efficient way to perform this task in R? Really appreciate your help. Thanks, __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Extract part of string
Hi, I am struggling to extract a part of string using regular expression in R. Let say, the string to be extracted is 'ron' from the expression 'my name is ron'. So I tried following: gsub([^(ron)], , 'my name is ron') [1] nron I was expecting to get 'ron', which is not the case. Could someone please guide me what will be the right way for that? Thanks for your help. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] R function to locate Excel sheet?
Hi, I am looking for some R function which will tell me, whether a particular sheet in an Excel file (.xlsx/.xls) exists or not. I just need to get some TRUE/FALSE type of answer. Can somebody give me any pointer if such function exists or not? Thanks and 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] Can not read Excel file correctly
Hi, I need to read an Excel file which can be available in following link: http://www45.zippyshare.com/v/43626889/file.html Now I wanted to read the 1st sheet of this Excel file. Below are my code so far (I saved that file in 'F:' drive): library(XLConnect) Loading required package: rJava XLConnect 0.2-5 by Mirai Solutions GmbH http://www.mirai-solutions.com , http://miraisolutions.wordpress.com readWorksheetFromFile(f:/Dat1.xlsx, sheet = 1) Col1 Col2 Col3 Col4 1 NA NA 2013-05-01 NA 2 NA NA NA NA 3 1930-01-01 NA NA NA 4 NA 3127312736128730 NA NA 5 NA NA NA NA 6 NA NA NA SAsSag What I saw that, the element in A1 cell is missing. Also the data in C1 A4 are read in different format. In Excel file, it is Month-Year format, however what I see is Year-Month-Day format. I have many such files, therefore I do not want to convert them to csv (or any other). Doing so will be cumbersome. Can somebody here help me how to read that file in proper format? Thanks for your time. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Finding solution for non-linear equations
Hi, I need to solve following simultaneous equations for A, B, Y1, Y2: B * Phi(Y1 - A) + (1-B) * Phi(Y1 + A) = 0.05 B * Phi(Y2 - A) + (1-B) * Phi(Y2 + A) = 0.01 Y1 = -1.65 Y2 = -2.33 0 = B =1 Phi is CDF for standard normal If there is no unique solution, then I should be able to get some feassible solution(s) Is there any way that using R I can achieve that? Thanks for your time __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Downloading data directly from internet
Hi, I need to download data from this site: http://www.cmegroup.com/trading/agricultural/grain-and-oilseed/corn_quotes_globex.html I tried with following set of codes: library(RCurl) library(XML) aa - getURL(http://www.cmegroup.com/trading/agricultural/grain-and-oilseed/corn_quotes_globex.html;) readHTMLTable(aa) However not getting the required data. Can someone please help me to point out how I can get that data? Your help will be highly appreciated. Thank you very much. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] ifelse() applied on function
Hi, How can I apply ifelse function to chose appropriate function? My goal is user will chose lapply() function if ChooseFn = T otherwise to chose sfLapply() from snowfall package. I am basically trying to avoid repeatation to write all internal steps, if user choses lapply or sfLapply. For example, I am wondering if there is any posibility to write something like: ifelse(ChooseFn, lapply, sfLapply)(MyList, function(x) { ... .. return()) Really appreciate if someone helps me out. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Converting string to date
Hi, I want to convert following string to a Date format (mm/dd/): MyString - c(Sun Sep 01 00:00:00 EDT 2013, Sun Dec 01 00:00:00 EST 2013) Can somebody point me if it is possible to do that? Thank you. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to download this data?
Hello Duncan, Thank you very much for your pointer. However when I tried to run your code, I got following error: rawOrig = getURLContent(https://www.theice.com/productguide/ProductSpec.shtml?specId=219#expiry;) Error in function (type, msg, asError = TRUE) : SSL certificate problem, verify that the CA cert is OK. Details: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed Can someone help me to understand what could be the cause of this error? Thank you. - Original Message - From: Duncan Temple Lang dtemplel...@ucdavis.edu To: r-help@r-project.org Cc: Sent: Saturday, 3 August 2013 4:33 AM Subject: Re: [R] How to download this data? That URL is an HTTPS (secure HTTP), not an HTTP. The XML parser cannot retrieve the file. Instead, use the RCurl package to get the file. However, it is more complicated than that. If you look at source of the HTML page in a browser, you'll see a jsessionid and that is a session identifier. The following retrieves the content of your URL and then parses it and extracts the value of the jsessionid. Then we create the full URL to the actual data page (which is actually in the HTML content but in JavaScript code) library(RCurl) library(XML) rawOrig = getURLContent(https://www.theice.com/productguide/ProductSpec.shtml?specId=219#expiry;) rawDoc = htmlParse(rawOrig) tmp = getNodeSet(rawDoc, //@href[contains(.,\040'jsessionid=')])[[1]] jsession = gsub(.*jsessionid=([^?]+)?.*, \\1, tmp) u = sprintf(https://www.theice.com/productguide/ProductSpec.shtml;jsessionid=%s?expiryDates=specId=219;, jsession) doc = htmlParse(getURLContent(u)) tbls = readHTMLTable(doc) data = tbls[[1]] dim(data) I did this quickly so it may not be the best way or completely robust, but hopefully it gets the point across and does get the data. D. On 8/2/13 2:42 PM, Ron Michael wrote: Hi all, I need to download the data from this web page: https://www.theice.com/productguide/ProductSpec.shtml?specId=219#expiry I used the function readHTMLTable() from package XML, however could not download that. Can somebody help me how to get the data onto my R window? Thank you. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 download this data?
In the mean time I have this problem sorted out, hopefully I did it correctly. I have modified the line of your code as: rawOrig = getURLContent(https://www.theice.com/productguide/ProductSpec.shtml?specId=219#expiry;, ssl.verifypeer = FALSE) However next I faced with another problem to executing: u = sprintf(a href=https://www.theice.com/productguide/ProductSpec.shtml;jsessionid=%s?expiryDates=specId=219;https://www.theice.com/productguide/ProductSpec.shtml;jsessionid=%s?expiryDates=specId=219;, jsession) Error: unexpected symbol in u = sprintf(a href=https Can you or someone else help me to get out of this error? Also, my another question is: from where you got the expression: a href=https://www.theice.com/productguide/ProductSpec.shtml;jsessionid=%s?expiryDates=specId=219;https://www.theice.com/productguide/ProductSpec.shtml;jsessionid=%s?expiryDates=specId=219; I really appreciate if someone help me to understand that. Thank you. - Original Message - From: Ron Michael ron_michae...@yahoo.com To: Duncan Temple Lang dtemplel...@ucdavis.edu; r-help@r-project.org r-help@r-project.org Cc: Sent: Saturday, 3 August 2013 12:58 PM Subject: Re: [R] How to download this data? Hello Duncan, Thank you very much for your pointer. However when I tried to run your code, I got following error: rawOrig = getURLContent(https://www.theice.com/productguide/ProductSpec.shtml?specId=219#expiry;) Error in function (type, msg, asError = TRUE) : SSL certificate problem, verify that the CA cert is OK. Details: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed Can someone help me to understand what could be the cause of this error? Thank you. - Original Message - From: Duncan Temple Lang dtemplel...@ucdavis.edu To: r-help@r-project.org Cc: Sent: Saturday, 3 August 2013 4:33 AM Subject: Re: [R] How to download this data? That URL is an HTTPS (secure HTTP), not an HTTP. The XML parser cannot retrieve the file. Instead, use the RCurl package to get the file. However, it is more complicated than that. If you look at source of the HTML page in a browser, you'll see a jsessionid and that is a session identifier. The following retrieves the content of your URL and then parses it and extracts the value of the jsessionid. Then we create the full URL to the actual data page (which is actually in the HTML content but in JavaScript code) library(RCurl) library(XML) rawOrig = getURLContent(https://www.theice.com/productguide/ProductSpec.shtml?specId=219#expiry;) rawDoc = htmlParse(rawOrig) tmp = getNodeSet(rawDoc, //@href[contains(.,\040'jsessionid=')])[[1]] jsession = gsub(.*jsessionid=([^?]+)?.*, \\1, tmp) u = sprintf(https://www.theice.com/productguide/ProductSpec.shtml;jsessionid=%s?expiryDates=specId=219;, jsession) doc = htmlParse(getURLContent(u)) tbls = readHTMLTable(doc) data = tbls[[1]] dim(data) I did this quickly so it may not be the best way or completely robust, but hopefully it gets the point across and does get the data. D. On 8/2/13 2:42 PM, Ron Michael wrote: Hi all, I need to download the data from this web page: https://www.theice.com/productguide/ProductSpec.shtml?specId=219#expiry I used the function readHTMLTable() from package XML, however could not download that. Can somebody help me how to get the data onto my R window? Thank you. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 download this data?
Hi Duncan, Thank you very much for your prompt help. Now all worked very smoothly. Thank you. - Original Message - From: Duncan Temple Lang dtemplel...@ucdavis.edu To: Ron Michael ron_michae...@yahoo.com Cc: r-help@r-project.org r-help@r-project.org Sent: Saturday, 3 August 2013 7:43 PM Subject: Re: [R] How to download this data? Hi Ron Yes, you can use ssl.verifypeer = FALSE. Or alternatively, you can use also use getURLContent(, cainfo = system.file(CurlSSL, cacert.pem, package = RCurl)) to specify where libcurl can find the certificates to verify the SSL signature. The error you are encountering appears to becoming from a garbled R expression. This may have arisen as a result of an HTML mailer adding the a href= into the expression where it found an https://... What we want to do is end up with a string of the form https://www.theice.com/productguide/ProductSpec.shtml;jsessionid=adasdasdad?expiryData=specId=219 We have to substitute the text adasdasdad which we assigned to jsession in a previous command. So, take the literal text c(https://www.theice.com/productguide/ProductSpec.shtml;jsessionid=;, jsession, ?expiryData=specId=219) and combine it into a single string with paste0. We need the literal strings as they appear when you view the mail for R to make sense of them, not what the mailer adds. As to where I found this, it is in the source of the original HTML page in rawDoc scripts = getNodeSet(rawDoc, //body//script) scripts[[ length(scripts) ]] and look at the text, specifically the app.urls and its 'expiry' field. script type=text/javascript![CDATA[ var app = {}; app.isOption = false; app.urls = { 'spec':'/productguide/ProductSpec.shtml;jsessionid=22E9BE9DB19FC6F3446C9ED4AFF2BE3F?details=specId=219', 'data':'/productguide/ProductSpec.shtml;jsessionid=22E9BE9DB19FC6F3446C9ED4AFF2BE3F?data=specId=219', 'confirm':'/reports/dealreports/getSampleConfirm.do;jsessionid=22E9BE9DB19FC6F3446C9ED4AFF2BE3F?hubId=403productId=254', 'reports':'/productguide/ProductSpec.shtml;jsessionid=22E9BE9DB19FC6F3446C9ED4AFF2BE3F?reports=specId=219', 'expiry':'/productguide/ProductSpec.shtml;jsessionid=22E9BE9DB19FC6F3446C9ED4AFF2BE3F?expiryDates=specId=219' }; app.Router = Backbone.Router.extend({ routes:{ spec:spec, data:data, confirm:confirm, On 8/3/13 1:05 AM, Ron Michael wrote: In the mean time I have this problem sorted out, hopefully I did it correctly. I have modified the line of your code as: rawOrig = getURLContent(https://www.theice.com/productguide/ProductSpec.shtml?specId=219#expiry;, ssl.verifypeer = FALSE) However next I faced with another problem to executing: u = sprintf(a href=https://www.theice.com/productguide/ProductSpec.shtml;jsessionid=%s?expiryDates=specId=219;https://www.theice.com/productguide/ProductSpec.shtml;jsessionid=%s?expiryDates=specId=219;, jsession) Error: unexpected symbol in u = sprintf(a href=https Can you or someone else help me to get out of this error? Also, my another question is: from where you got the expression: a href=https://www.theice.com/productguide/ProductSpec.shtml;jsessionid=%s?expiryDates=specId=219;https://www.theice.com/productguide/ProductSpec.shtml;jsessionid=%s?expiryDates=specId=219; I really appreciate if someone help me to understand that. Thank you. - Original Message - From: Ron Michael ron_michae...@yahoo.com To: Duncan Temple Lang dtemplel...@ucdavis.edu; r-help@r-project.org r-help@r-project.org Cc: Sent: Saturday, 3 August 2013 12:58 PM Subject: Re: [R] How to download this data? Hello Duncan, Thank you very much for your pointer. However when I tried to run your code, I got following error: rawOrig = getURLContent(https://www.theice.com/productguide/ProductSpec.shtml?specId=219#expiry;) Error in function (type, msg, asError = TRUE) : SSL certificate problem, verify that the CA cert is OK. Details: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed Can someone help me to understand what could be the cause of this error? Thank you. - Original Message - From: Duncan Temple Lang dtemplel...@ucdavis.edu To: r-help@r-project.org Cc: Sent: Saturday, 3 August 2013 4:33 AM Subject: Re: [R] How to download this data? That URL is an HTTPS (secure HTTP), not an HTTP. The XML parser cannot retrieve the file. Instead, use the RCurl package to get the file. However, it is more complicated than that. If you look at source of the HTML page in a browser, you'll see a jsessionid and that is a session identifier. The following retrieves the content of your URL and then parses it and extracts the value of the jsessionid. Then we create the full URL to the actual data page (which
[R] How to download this data?
Hi all, I need to download the data from this web page: https://www.theice.com/productguide/ProductSpec.shtml?specId=219#expiry I used the function readHTMLTable() from package XML, however could not download that. Can somebody help me how to get the data onto my R window? Thank you. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Need help on window() function of the 'zoo' package
Hi, I observed that if I use window() function available with the 'zoo' package to extract a portion of my times series and if that time series data is stored in some 'zoo' object with only 1 column, then the resulting zoo object is becoming vector. Here is my observation: library(zoo) Dat - matrix(1:3, nc = 1) Dat [,1] [1,] 1 [2,] 2 [3,] 3 Dat_zoo - zooreg(Dat, start = as.Date(2001-01-01), frequency = 1) Dat_zoo 2001-01-01 1 2001-01-02 2 2001-01-03 3 window(Dat_zoo, start = as.Date(2001-01-02)) ### why it is becoming vector? I want to retain it as matrix only 2001-01-02 2001-01-03 2 3 Here you can see that, originally my 'Dat_zoo ' object was basically a matrix. However once I use window() function, it became vector. Is there any possibility to retain the shape of the original object, particularly if that object is matrix with 1 column? Thank you very much 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] Need to download data from internet
Hi, I need to dowload a time series with arbitray start date and end date, from this site: http://www.mcxindia.com/sitepages/SpotMarketHistory.aspx?sLinkPage=Y While I can download my required data manually, I would like R to do that for me. I have tried 'quandl' package, however could not find any such data available to download. Can somebody point me some R function which can help me to download that data automatically? 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] Working with date
Hi, Let say I have a date variable: asd - as.Date(2012-01-03) asd [1] 2012-01-03 Now, I want to express this date like 3/1/2012. can somebody help me how to achieve that? Thanks, __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Working with date
Thanks Jim for your reply. However I want 3/1/2012 not 03/01/2012 Any idea ? Thanks - Original Message - From: jim holtman jholt...@gmail.com To: Ron Michael ron_michae...@yahoo.com Cc: r-help@r-project.org r-help@r-project.org Sent: Thursday, 27 December 2012 1:01 AM Subject: Re: [R] Working with date forgot you were asking for mdy format # interchange day and month format(asd, format = '%d/%m/%Y') [1] 03/01/2012 On Wed, Dec 26, 2012 at 2:14 PM, jim holtman jholt...@gmail.com wrote: try this: asd - as.Date(2012-01-03) asd [1] 2012-01-03 format(asd, format = '%m/%d/%Y') [1] 01/03/2012 On Wed, Dec 26, 2012 at 1:31 PM, Ron Michael ron_michae...@yahoo.com wrote: asd - as.Date(2012-01-03) -- Jim Holtman Data Munger Guru What is the problem that you are trying to solve? Tell me what you want to do, not how you want to do it. -- Jim Holtman Data Munger Guru What is the problem that you are trying to solve? Tell me what you want to do, not how you want to do it. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Wriritng to a CSV file
Dear all, let say I want to write a vector to a CSV file. So I can have following syntax: write.csv(rnorm(10), dat.csv) Now I want to add one more column into that existing file. If I use the same code then existing file will be destroyed. Is there any functionality to add without destroying the existing file? I have tries with 'append = TRUE' however it is not working! Any suggestion will be highly appreciated. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Wriritng to a CSV file
Okay, so I understood that appending can only happen row-wise. Therefore I tried with following code: write.csv(matrix(1:5, 1), dat.csv) write.csv(matrix(1:5, 1), dat.csv, append = TRUE) Warning message: In write.csv(matrix(1:5, 1), dat.csv, append = TRUE) : attempt to set 'append' ignored It is destroying my previous file. Where I have done wrong? Thanks, - Original Message - From: Uwe Ligges lig...@statistik.tu-dortmund.de To: Ron Michael ron_michae...@yahoo.com Cc: r-help@r-project.org r-help@r-project.org Sent: Thursday, 9 February 2012 1:07 AM Subject: Re: [R] Wriritng to a CSV file On 08.02.2012 20:14, Ron Michael wrote: Dear all, let say I want to write a vector to a CSV file. So I can have following syntax: write.csv(rnorm(10), dat.csv) Now I want to add one more column into that existing file. If I use the same code then existing file will be destroyed. Is there any functionality to add without destroying the existing file? I have tries with 'append = TRUE' however it is not working! Any suggestion will be highly appreciated. Since these text files are written line by line, you cannot add a column afterwards, you can just append rows. Hence read the first column and write a two column data.frame afterwards. Uwe Ligges __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Drawing sample
Dear all, here I need to draw all possible samples of size 2, from a population, which is characterized by c(1,4,56, 3). Sampling will be done with replacement. Is there any direct R function to faciliate this darwing? Thanks for your help __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Looking for a C function
Dear all, I was looking for the C program found within approxfun() function. I already have a list of available C programs which are being used with R here, https://svn.r-project.org/R/trunk/src/main/. However this list does not contain above C function. Can somebody help me on where to find that? Thanks, __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] A problem with chol() function
I think I am missing something with the chol() function. Here is my calculation: mat [,1] [,2] [,3] [,4] [,5] [1,] 1 3 0 0 0 [2,] 0 1 0 0 0 [3,] 0 0 1 0 0 [4,] 0 0 0 1 0 [5,] 0 0 0 0 1 eigen(mat) $values [1] 1 1 1 1 1 $vectors [,1] [,2] [,3] [,4] [,5] [1,] 1 -1.00e+00 0 0 0 [2,] 0 7.401487e-17 0 0 0 [3,] 0 0.00e+00 1 0 0 [4,] 0 0.00e+00 0 1 0 [5,] 0 0.00e+00 0 0 1 chol(mat) Error in chol.default(mat) : the leading minor of order 2 is not positive definite As per the eigen values my matrix is PD (as all eigen values are positive). Then why still I can not get Cholesky factor of my matrix? Can somebody point mw where I am missing? Thanks and 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] Question on RNG
Hi all, I have happened to work on MS .NET for sometime now, and I found that this language offers RNG what is called as Donald E. Knuth's subtractive random number generator algorithm (found here: http://msdn.microsoft.com/en-us/library/system.random.aspx#Y12). Here I was wondering whether R also have same RNG in it's inventory, so looked at ?set.seed. There I found 2 related RNGs namely 'Knuth-TAOCP-2002', 'Knuth-TAOCP'. Can somebody guide me what is the most related RNG with .Net's? I also want to have R to draw random number from that RNG, given I set a seed. My goal is to have same set of random numbers in .Net R, so that I can match and see and compare the performance for some further calculations, which are based on random numbers in both .Net R. It will be really great to me if somebody can help me out. Thanks, __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Question on RNG
Thanks Duncan for your reply. However I could not understand this: 'R provides ways to call its RNGs from C'. Can you be more detailed what I need to do here? Thanks, - Original Message - From: Duncan Murdoch murdoch.dun...@gmail.com To: Ron Michael ron_michae...@yahoo.com Cc: r-help@r-project.org r-help@r-project.org Sent: Saturday, 6 August 2011 1:24 AM Subject: Re: [R] Question on RNG On 11-08-05 2:17 PM, Ron Michael wrote: Hi all, I have happened to work on MS .NET for sometime now, and I found that this language offers RNG what is called as Donald E. Knuth's subtractive random number generator algorithm (found here: http://msdn.microsoft.com/en-us/library/system.random.aspx#Y12). Here I was wondering whether R also have same RNG in it's inventory, so looked at ?set.seed. There I found 2 related RNGs namely 'Knuth-TAOCP-2002', 'Knuth-TAOCP'. Can somebody guide me what is the most related RNG with .Net's? I also want to have R to draw random number from that RNG, given I set a seed. My goal is to have same set of random numbers in .Net R, so that I can match and see and compare the performance for some further calculations, which are based on random numbers in both .Net R. It will be really great to me if somebody can help me out. As far as I know, Microsoft doesn't publish the code for their RNG. Naming it is not enough -- implementations that differ in subtle details will give different streams. So I'd recommend that you call a known RNG from .NET, rather than whatever is built in. R provides ways to call its RNGs from C, so it's probably possible to call it from .NET: then you can be sure the two streams are identical. 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] A Calculation on list object
Hello, I am into some calculation on a list object, therefore requesting the peers if there is any short cut way to so the same calculation. Let say I have following list object: List - vector('list', length = 3) set.seed(1) List[[1]] - rnorm(5) List[[2]] - rnorm(2) List[[3]] - rnorm(7) List [[1]] [1] -0.6264538 0.1836433 -0.8356286 1.5952808 0.3295078 [[2]] [1] -0.8204684 0.4874291 [[3]] [1] 0.7383247 0.5757814 -0.3053884 1.5117812 0.3898432 -0.6212406 -2.2146999 Vector - 3:5 Vector [1] 3 4 5 Now, what I want to do is, add List with Vector, element-by-element. Means I wanted to do: List[[1]] + Vector[1] [1] 2.373546 3.183643 2.164371 4.595281 3.329508 List[[2]] + Vector[2] [1] 3.179532 4.487429 List[[3]] + Vector[3] [1] 5.738325 5.575781 4.694612 6.511781 5.389843 4.378759 2.785300 Till now I have done this calculation with for-loop. Therefore it would be interesting if there is any elegant way to do the same. Thanks, __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Vectorizing a function: what does it mean?
Dear all, I would really appreciate if somebody can help me to understand what does the phrase Vectorize your function mean? And what is the job of Vectorize() function in doing that? I have read many threads where experts suggest to Vectorize the function, which will speed up entire calculation (and more elegant ofcourse.) I used to think that vectorizing function means, to create a function such a way so that if input(s) are vector then this function will also return a vector output (without having any extra effort like use of 'for' loop etc.) Is this understanding correct? Here I have tried 2 essentially similar functions: fn1 - function(x,y,z) return(x+y+z) fn2 - Vectorize(function(x,y,z) return(x+y+z), SIMPLIFY=TRUE) fn1(1:3, 4:6,5) [1] 10 12 14 fn2(1:3, 4:6,5) [1] 10 12 14 You see that, fn1() and fn2() is giving same answer (vectorized?) despite of the fact that fn1() is not wrapped within Vectorize() function. Therefore I want to know: what additional thing this Vectorize() function brings on the table? Thanks for your time. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] lower.tri/upper.tri functions unable to make a matrix symmetric!
Dear all, I have having a strange problem with upper.tri()/lower.tri() functions which I used to use to make a matrix symmetric. However for a specific large matrix, they seem not working. Initial I had following matrix: MyMatrix [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [1,] 0.0002137831 1.791564e-06 1.308941e-06 1.320362e-06 1.576466e-06 -2.090668e-06 -4.480179e-08 1.617517e-06 1.188307e-06 -6.592009e-06 [2,] NA 2.313636e-04 -2.028031e-06 -2.749156e-06 -4.670093e-07 2.630111e-06 1.364227e-06 -5.065928e-06 9.069602e-07 7.034820e-07 [3,] NA NA 2.800611e-04 2.530742e-06 1.237191e-06 6.105895e-07 -2.095904e-06 -5.090979e-06 1.180013e-06 8.172282e-06 [4,] NA NANA 3.219580e-04 -8.626130e-08 2.877486e-06 -4.387613e-06 1.551715e-06 5.999397e-07 -4.047684e-06 [5,] NA NANANA 2.343739e-04 5.086490e-06 2.839762e-06 -5.081967e-07 1.121733e-07 -3.601529e-06 [6,] NA NANANANA 2.488756e-04 2.118398e-07 -1.879584e-06 7.186348e-07 -3.602057e-06 [7,] NA NANANANA NA 2.946481e-04 2.454685e-06 -2.310217e-07 2.787164e-06 [8,] NA NANANANA NANA 1.899915e-04 1.224963e-06 -1.533257e-07 [9,] NA NANANANA NANANA 2.009841e-04 -6.389595e-07 [10,] NA NANANANA NANANANA 4.427314e-04 [11,] NA NANANANA NANANANANA [12,] NA NANANANA NANANANANA [13,] NA NANANANA NANANANANA [14,] NA NANANANA NANANANANA [15,] NA NANANANA NANANANANA [16,] NA NANANANA NANANANANA [,11] [,12] [,13] [,14] [,15] [,16] [1,] 1.611978e-06 1.156455e-06 2.429236e-06 -6.371224e-07 3.092417e-07 3.011528e-06 [2,] -5.510187e-06 -8.998582e-07 9.614807e-07 -8.311204e-07 -8.974948e-07 -3.812490e-08 [3,] -1.373343e-06 -5.213719e-07 -1.775968e-06 1.206253e-06 6.585452e-07 1.272045e-06 [4,] -2.28e-07 2.386934e-06 2.966653e-06 2.694338e-06 2.838703e-06 3.419373e-06 [5,] 4.707156e-06 2.080091e-06 -1.449516e-06 2.091399e-07 1.564799e-06 1.203982e-06 [6,] -7.174750e-06 -1.016559e-06 3.679732e-07 -1.604075e-06 3.363196e-06 -2.106617e-06 [7,] -1.358783e-06 -2.298378e-06 -1.822507e-06 1.792765e-06 1.201043e-06 -2.553821e-06 [8,] 5.935161e-06 -3.651090e-07 2.112346e-06 -1.432126e-06 -3.692184e-07 -2.214944e-06 [9,] 3.847311e-07 -1.156356e-07 4.155777e-06 -1.627045e-06 1.789992e-07 3.229348e-06 [10,] 3.123505e-06 3.504098e-06 -1.462336e-06 3.846515e-06 -2.693877e-08 3.698078e-06 [11,] 3.421896e-04 -1.334050e-06 -4.764588e-06 -4.065790e-07 1.312966e-06 1.531616e-06 [12,]NA 1.600832e-04 7.403796e-07 2.684925e-06 2.003153e-06 1.217396e-06 [13,]NANA 3.573365e-04 -1.540675e-06 4.166715e-07 1.457177e-06 [14,]NANANA 2.21e-04 1.856102e-06 -1.513366e-06 [15,]NANANANA 2.065449e-04 1.294455e-06 [16,]NANANANANA 2.056605e-04 MyMatrix[lower.tri(MyMatrix)] - MyMatrix[upper.tri(MyMatrix)] isSymmetric(MyMatrix) [1] FALSE Can somebody please tell me what is the problem with lower.tri/upper.tri functions? why they are not making my matrix symmetric? Thanks __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Writing diagonal matrix in opposite direction
Hi, is there any direct R function to write an diagonal matrix in an opposite way? for example I want to get like: diag(rnorm(5))[,5:1] [,1] [,2] [,3] [,4] [,5] [1,] 0.000 0.000 0.000 0.00 -0.1504687 [2,] 0.000 0.000 0.000 -2.139669 0.000 [3,] 0.000 0.000 -0.2102133 0.00 0.000 [4,] 0.000 -0.2609686 0.000 0.00 0.000 [5,] -0.6818889 0.000 0.000 0.00 0.000 Is there any typical name for this type of matrix? 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] Question on list objects
Hi, I have 2 questions on list object: 1. Suppose I have a matrix like: dat - matrix(1:9,3) Now I want to replicate this entire matrix 3 times and put entire result in a list object. Means, if res is the resulting list then I should have: res[[1]]=dat, res[[2]]=dat, res[[3]]=dat How can I do that in the easilest manner? 2. Suppose I have 2 list objects: list1 - list2 - vector(list, length=2) for(i in 1:2) { list1[[i]] - matrix(rnorm(15), 3) list2[[i]] - matrix(rnorm(15), 3) } How can I add these 2 list objects? I have tried with just list1+list2, however it is generating some error. Would be grateful for any help. 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] A question to get all possible combinations
Let say, I have a matrix with 8 rows and 6 columns: df1 - matrix(NA, 8, 4) df1 [,1] [,2] [,3] [,4] [1,] NA NA NA NA [2,] NA NA NA NA [3,] NA NA NA NA [4,] NA NA NA NA [5,] NA NA NA NA [6,] NA NA NA NA [7,] NA NA NA NA [8,] NA NA NA NA Now I want to get **all possible** ways to fetch 6 cells at a time. Is there any function to do that? 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] Calculating weekly/bi-monthly average for time series data
Dear all, given a daily time series data, I am able to calculate monthly average, quarterly average like: library(zoo) dat - zooreg(rnorm(500), start=as.Date(2000-01-01), frequency=1) mo.ave - aggregate(dat, as.yearmon(index(dat)), mean) head(dat) head(mo.ave) However is there any direct way like above to calculate the weekly average, bi-monthly average? 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] Priniting numerics
Hi all, can somebody help me on my little problem? I want to print a number say 10^10 is numerical format not in scientific notation. I ttied following: options(scipen = 1) print(10^10, 10) [1] 1e+10 I am not getting my desired output in simple numerical format. How can I get that? Thanks in advance. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Priniting numerics
I am not sure if I understood the help page. It says fixed notation will be preferred unless it is more than âscipenâ digits wider. If I understood correctly it says, the corresponding number needs to be less wider than 'scipen' digit, to print it numerically. Let say:  options(scipen = 5) 10^10 [1] 1e+10 options(scipen = 6) 10^10 [1] 100 I both cases (10^10) is wider than scipen digit. Still why I am getting different representations? I am missing something?  Thanks,   --- On Sat, 27/11/10, Peter Ehlers ehl...@ucalgary.ca wrote: From: Peter Ehlers ehl...@ucalgary.ca Subject: Re: [R] Priniting numerics To: Ron Michael ron_michae...@yahoo.com Cc: r-help@r-project.org r-help@r-project.org Date: Saturday, 27 November, 2010, 5:43 PM On 2010-11-27 02:15, Ron Michael wrote: Hi all, can somebody help me on my little problem? I want to print a number say 10^10 is numerical format not in scientific notation. I ttied following: options(scipen = 1) print(10^10, 10) [1] 1e+10 I am not getting my desired output in simple numerical format. How can I get that? You'll need a greater penalty; see ?options. Peter Ehlers Thanks in advance.    [[alternative HTML version deleted]] [[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] Seek some help on Statistics
Hi friends, I would really appreciate if somebody helps me give better understanding on subject matter. Suppose I have a set of Integrated variables (say max order is 1). I understand there may be some cases when there could be some linear combinations which are stationary and this phenomena is called as co-integration. Now suppose I have a vector of Random walks (which is also integrated of order 1 each), where error terms are not necessarily independent but of course uncorrelated over time i.e. error terms are WN. Here my question is still can we find some linear combinations (like co-integrated variables) which are stationary? And if not, why this is not. Please forgive me if my question seems very naive. However although intuitively I feel that no such linear relationships exist for RWs, however I find hard to explain to 2nd person. Any help please? 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] quiry on paste() function
Hi all, I want to club different objects (character type) to a single one and using paste() function that can be done happily. However the problem with paste function is the separator field is unique for all underlying objects. If I put separator as - then this will come in between all underlying objects which are to be clubbed. Therefore I am wondering whether there is any mechanism to put different separators for different places. Trivially this can be done by applying paste() function repeatedly. However I feel there must be some single mechanism for doing that. Here is one example, where I apply paste() function twice to incorporate 2 different separators: paste(paste(a, b, sep=,), c, sep=:) [1] a,b:c Can the same thing be done using paste() function once? something like: paste(a, b, c, sep=c(,, :)) # this put 1st separator everywhere which is not intended 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] Checking existance of a directory
Hi all, I am wondering is there any way to check whether some Directory exists or not, given the parent path of that directory? After searching for a while I found that there is a function dir.create() to create some directory. However I need to know whether such directory already exists or not, otherwise I will create that. 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] Vector multiplication
Is there any operator in R, which will multiply each possible combination of the elements of 2 vectors? Suppose I have 2 vectors (1,2) and (1,2,3). If I multiply those 2, I should get:(1,2,3,2,4,6) 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] Fw: Problem to create a matrix polynomial
Awaiting some suggestion. Was my question not very understandable? Please let me know how can I offer more elaborate clarification. Additionally, I would like to solve the determinant of p1 for the values of z (I am working with some multivariate time series modelling). When I use det() function, it am getting error that, that function is not for objects with class polynomial. Any idea please? Thanks, --- On Wed, 13/10/10, Ron_M ron_michae...@yahoo.com wrote: From: Ron_M ron_michae...@yahoo.com Subject: [R] Problem to create a matrix polynomial To: r-help@r-project.org Date: Wednesday, 13 October, 2010, 4:31 PM Dear all R users, I was trying to create a polymonial using the polynom() of PolynomF package. My problem is, if I pass coefficients as simple numerical values, it is working, but for matrix coefficient it is not. Here is my try: library(PolynomF) z - polynom() ## following is working p1 - 1- 4.5*z ## However following is not giving results as intended p1 - diag(3)- matrix(1:9, 3,3)*z In the 2nd example, I was expecting a matrix polynomial in z upto degree 1, which I did not get. Can anyone please correct me how to address this problem? Thanks, -- View this message in context: http://r.789695.n4.nabble.com/Problem-to-create-a-matrix-polynomial-tp2993411p2993411.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. [[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] Generating weekdays only
Dear all, can anyone please tell me how to generate a sequence of days continuously, however without considering weekends i.e. Saturday and Sunday? I am aware of following code: seq(as.Date(2010-01-01), as.Date(2010-02-01), by=1 day) [1] 2010-01-01 2010-01-02 2010-01-03 2010-01-04 2010-01-05 2010-01-06 2010-01-07 2010-01-08 [9] 2010-01-09 2010-01-10 2010-01-11 2010-01-12 2010-01-13 2010-01-14 2010-01-15 2010-01-16 [17] 2010-01-17 2010-01-18 2010-01-19 2010-01-20 2010-01-21 2010-01-22 2010-01-23 2010-01-24 [25] 2010-01-25 2010-01-26 2010-01-27 2010-01-28 2010-01-29 2010-01-30 2010-01-31 2010-02-01 However this generates all days. Thanks for your time. [[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] Keyword to clear the screen
Hi all, can anyone please tell me what is the key-word to clear the screen? I am aware of the cont+L, however I need some R-syntax, that can be typed into the console to clear the screen. Thanks [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Keyword to clear the screen
Thanks everyone who have looked into my problem. In the mean time I already found one tip here http://onertipaday.blogspot.com/2007/05/how-to-clear-screen-in-r.html to do that. I am yet to try it...perhaps it would solve me problem :) Thanks, --- On Wed, 15/9/10, Ron Michael ron_michae...@yahoo.com wrote: From: Ron Michael ron_michae...@yahoo.com Subject: [R] Keyword to clear the screen To: r-h...@stat.math.ethz.ch Date: Wednesday, 15 September, 2010, 8:27 PM Hi all, can anyone please tell me what is the key-word to clear the screen? I am aware of the cont+L, however I need some R-syntax, that can be typed into the console to clear the screen. Thanks [[alternative HTML version deleted]] -Inline Attachment Follows- __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Matrix to list
Dear all, suppose I have following matrix: mat - matrix(rnorm(25), 5) mat [,1] [,2] [,3] [,4] [,5] [1,] 0.97056228 -1.3278509 -0.73511792 2.1650629 -0.4411997 [2,] 0.58613700 -0.2559899 -1.18334248 -1.4990907 1.8138846 [3,] -1.0313 2.0227887 0.89622681 0.6483973 -1.5523283 [4,] 0.38968833 0.2490004 -0.02301061 -0.2705150 -0.9237268 [5,] 0.03306289 -0.4022751 -0.44404905 -1.6810542 -0.1016683 Now from mat I would like to create a list object where i-th column of mat will represent i-th element of that list object. I am looking for some way to avoid for loop. It will be really helpful if somebody points me on that. Thanks, [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Matrix to list
Thanks Henrique and Marc for your reply, both worked. However I need one more suggestion on from list to matrix dat - vector(list, 3) dat[[1]] - rnorm(5) dat[[2]] - rnorm(15) dat[[3]] - rnorm(3) dat [[1]] [1] 0.7615421 0.4151374 0.6534402 1.5999338 1.4131837 [[2]] [1] 0.7364765 2.0786904 -1.1087768 1.5091391 -0.1448301 1.6015788 1.8039138 1.1194863 1.4907951 0.5324749 [11] 0.6792318 -0.8328359 -1.8009706 -0.8523432 0.5314461 [[3]] [1] -0.4350899 -0.2610924 -0.6489858 Now I want to convert dat to a matrix. I tried following: Reduce(cbind, dat) init [1,] 0.7615421 0.7364765 -0.4350899 [2,] 0.4151374 2.0786904 -0.2610924 [3,] 0.6534402 -1.1087768 -0.6489858 [4,] 1.5999338 1.5091391 -0.4350899 [5,] 1.4131837 -0.1448301 -0.2610924 [6,] 0.7615421 1.6015788 -0.6489858 [7,] 0.4151374 1.8039138 -0.4350899 [8,] 0.6534402 1.1194863 -0.2610924 [9,] 1.5999338 1.4907951 -0.6489858 [10,] 1.4131837 0.5324749 -0.4350899 [11,] 0.7615421 0.6792318 -0.2610924 [12,] 0.4151374 -0.8328359 -0.6489858 [13,] 0.6534402 -1.8009706 -0.4350899 [14,] 1.5999338 -0.8523432 -0.2610924 [15,] 1.4131837 0.5314461 -0.6489858 Here you see values of vector with smaller length is getting repeated. Instead of repetition, I would like to fill those with NA (or possibly some predefined fixed value) Would you please suggest me how to do that? Thanks, --- On Fri, 3/9/10, Henrique Dallazuanna www...@gmail.com wrote: From: Henrique Dallazuanna www...@gmail.com Subject: Re: [R] Matrix to list To: Ron Michael ron_michae...@yahoo.com Cc: r-h...@stat.math.ethz.ch Date: Friday, 3 September, 2010, 8:07 PM Try this: unclass(as.data.frame(mat)) On Fri, Sep 3, 2010 at 9:48 AM, Ron Michael ron_michae...@yahoo.com wrote: Dear all, suppose I have following matrix: mat - matrix(rnorm(25), 5) mat [,1] [,2] [,3] [,4] [,5] [1,] 0.97056228 -1.3278509 -0.73511792 2.1650629 -0.4411997 [2,] 0.58613700 -0.2559899 -1.18334248 -1.4990907 1.8138846 [3,] -1.0313 2.0227887 0.89622681 0.6483973 -1.5523283 [4,] 0.38968833 0.2490004 -0.02301061 -0.2705150 -0.9237268 [5,] 0.03306289 -0.4022751 -0.44404905 -1.6810542 -0.1016683 Now from mat I would like to create a list object where i-th column of mat will represent i-th element of that list object. I am looking for some way to avoid for loop. It will be really helpful if somebody points me on that. 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. -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40 S 49° 16' 22 O [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Determining the length of unique items in a vector
Dear all, let suppose I have following vector: dat1 - c(rep(asd, 5), rep(xyz, 12), rep(erd, 17)) dat1 - dat1[sample(1:length(dat1), length(dat1), replace=F)] dat1 [1] erd xyz erd asd asd erd xyz asd erd erd asd xyz erd asd xyz xyz erd xyz erd [20] erd erd xyz xyz erd erd erd erd xyz xyz xyz erd xyz erd erd Here I want to know the length of replications for each unique items viz asd, xyz, and erd. Is there any R function available to directly implement that? 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] Need help on upper.tri()
HI, I am really messing up to make a symmetrical matrix using upper.tri() lower.tri() function. Here is my code: set.seed(1) mat = matrix(rnorm(25), 5, 5) mat [,1] [,2] [,3] [,4] [,5] [1,] -0.6264538 -0.8204684 1.5117812 -0.04493361 0.91897737 [2,] 0.1836433 0.4874291 0.3898432 -0.01619026 0.78213630 [3,] -0.8356286 0.7383247 -0.6212406 0.94383621 0.07456498 [4,] 1.5952808 0.5757814 -2.2146999 0.82122120 -1.98935170 [5,] 0.3295078 -0.3053884 1.1249309 0.59390132 0.61982575 mat[lower.tri(mat)] = mat[upper.tri(mat)] mat [,1] [,2] [,3] [,4] [,5] [1,] -0.62645381 -0.82046838 1.51178117 -0.04493361 0.91897737 [2,] -0.82046838 0.48742905 0.38984324 -0.01619026 0.78213630 [3,] 1.51178117 -0.01619026 -0.62124058 0.94383621 0.07456498 [4,] 0.38984324 0.94383621 0.78213630 0.82122120 -1.98935170 [5,] -0.04493361 0.91897737 0.07456498 -1.98935170 0.61982575 Which is not coming as symmetrical function. Can anyone point me on the correct way of using upper, lower.try() function to get a symmetrical matrix? 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] Meaning of following function
Hi friends, I am aware of the function -() which acts as minus in ordinary computations. For example: -(3, 1) [1] 2 However what is the meaning of -(3) [1] -3 I was expecting R to generate some error as it does for *(3). What is the logic for that calculation? 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] Drawing sample from a circle
Hi, I would like to draw 10 uniformly distributed sample points from a circle with redius one and centered at (0,0). Is there any R function to do that? Thanks, [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] [OOPS] Re: Drawing sample from a circle
Thank you so much Teds for pviding this function. Would you please explain the theory behind that? Thanks, --- On Fri, 18/6/10, ted.hard...@manchester.ac.uk ted.hard...@manchester.ac.uk wrote: From: ted.hard...@manchester.ac.uk ted.hard...@manchester.ac.uk Subject: [OOPS] Re: [R] Drawing sample from a circle To: r-h...@stat.math.ethz.ch Cc: Ron Michael ron_michae...@yahoo.com Date: Friday, 18 June, 2010, 4:48 PM OOPS: AN error on the code below! See in-line. Ted. On 18-Jun-10 09:33:04, Ted Harding wrote: On 18-Jun-10 08:04:36, Ron Michael wrote: Hi, I would like to draw 10 uniformly distributed sample points from a circle with redius one and centered at (0,0). Is there any R function to do that? _ Thanks, You can quite easily write one. [A] Sampling uniformly on the circumference of the circle: csamp - function(n,rad=1,centre=c(0,0)){ x0 - centre[1] ; y0 - centre[2] u - 2*pi*runif(n) rad*cbind(x=cos(u)+x0, y=sin(u)+y0) } # Returns an nx2 matrix whose two columns are the x and y coordinates CORRECTION: csamp - function(n,rad=1,centre=c(0,0)){ x0 - centre[1] ; y0 - centre[2] u - 2*pi*runif(n) cbind(x=rad*cos(u)+x0, y=rad*sin(u)+y0) } # Returns an nx2 matrix whose two columns are the x and y coordinates [B] Sampling uniformaly within the circle Csamp - function(n,rad=1,centre=c(0,0)){ x0 - centre[1] ; y0 - centre[2] u - 2*pi*runif(n) r - sqrt(runif(n)) rad*cbind(x=r*cos(u)+x0, y=r*sin(u)+y0) } # Returns an nx2 matrix whose two columns are the x and y coordinates CORRECTION: Csamp - function(n,rad=1,centre=c(0,0)){ x0 - centre[1] ; y0 - centre[2] u - 2*pi*runif(n) r - sqrt(runif(n)) cbind(x=rad*r*cos(u)+x0, y=rad*r*sin(u)+y0) } # Returns an nx2 matrix whose two columns are the x and y coordinates [C] Examples: plot(csamp(100),asp=1) plot(Csamp(1000),asp=1) Ted. E-Mail: (Ted Harding) ted.hard...@manchester.ac.uk Fax-to-email: +44 (0)870 094 0861 Date: 18-Jun-10 Time: 10:33:00 -- XFMail -- __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. E-Mail: (Ted Harding) ted.hard...@manchester.ac.uk Fax-to-email: +44 (0)870 094 0861 Date: 18-Jun-10 Time: 10:48:14 -- XFMail -- [[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] Fw: Re: Why \\ instead of simple / to specify a file path [modified]
Hi, I was following this thread and would like to ask is there any way to save and open a .RData file after using some Password. What I mean to say, how to make my workplace password-protected? Also would like to know how same can be done for .R file. Thanks for your time. Thanks and regards, --- On Tue, 23/3/10, David Winsemius dwinsem...@comcast.net wrote: From: David Winsemius dwinsem...@comcast.net Subject: Re: [R] Why \\ instead of simple / to specify a file path To: Bogaso bogaso.christo...@gmail.com Cc: r-help@r-project.org Date: Tuesday, 23 March, 2010, 1:51 AM On Mar 22, 2010, at 1:22 PM, Bogaso wrote: Hi all, I have saved my workplace in a .RData format. However if I want to open that, I need to use following code : load(C:\\..) Here my question is why \\. In all the time generally we use / like when we use read.delim() function etc. Is there any possibility to have some consistency there? Depends what you mean by consistency. The same rule applies on all current supported OS platforms. Doubling the back-slashes is needed because \ is an escape character. Is there any other way to re-open the .RData file? If your OS supports it you may be able to use drag-drop with file icons or you can use file.choose() --David. Thanks, --View this message in context: http://n4.nabble.com/Why-instead-of-simple-to-specify-a-file-path-tp1677973p1677973.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. New Email names for you! il. [[elided Yahoo spam]] [[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] Creating list from matrix
Hello everyone,  I have a matrix like :  mat - matrix(rnorm(12*3), 3)  Now I want to break that matrix in 4 parts each of them are matrix of (3x3) and put those 4 matrices in a list object of length 4  Can anyone please tell me how to do that? Get your new Email address! Grab the Email name you#39;ve always wanted before someone else does! [[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] Fw: MLE
I made one typo in my previous mail.  May I ask one statistics related question please? I have one query on MLE itself. It's property says that, for large sample size it is normally distributed [i.e. asymptotically normal]. On the other hand it is Consistent as well. My doubt is, how this two asymptotic properties exist simultaneously? If it is consistent then asymptotically it should collapse to truth i.e. for large sample size, variance of MLE should be zero. However asymptotic normality says, MLE have some distribution and hence variance.  Can anyone please clarify me? Your help will be highly appreciated. --- On Wed, 8/10/08, Ron Michael [EMAIL PROTECTED] wrote: From: Ron Michael [EMAIL PROTECTED] Subject: [R] MLE To: [EMAIL PROTECTED] Date: Wednesday, 8 October, 2008, 6:05 PM May I ask one statistics related question please? I have one query on MLE itself. It's property says that, for large sample size it is normally distributed [i.e. asymptotically normal]. On the other hand it is Efficient as well. My doubt is, how this two asymptotic properties exist simultaneously? If it is consistent then asymptotically it should collapse to truth i.e. for large sample size, variance of MLE should be zero. However asymptotic normality says, MLE have some distribution and hence variance.  Can anyone please clarify me? Your help will be highly appreciated.  Get your new Email address! Grab the Email name you#39;ve always wanted before someone else does! [[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. [[elided Yahoo spam]] il. [[elided Yahoo spam]] [[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] MLE
May I ask one statistics related question please? I have one query on MLE itself. It's property says that, for large sample size it is normally distributed [i.e. asymptotically normal]. On the other hand it is Efficient as well. My doubt is, how this two asymptotic properties exist simultaneously? If it is consistent then asymptotically it should collapse to truth i.e. for large sample size, variance of MLE should be zero. However asymptotic normality says, MLE have some distribution and hence variance. Â Can anyone please clarify me? Your help will be highly appreciated. Â Get your new Email address! Grab the Email name you#39;ve always wanted before someone else does! [[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] A Regression question
Dear all, I have statistics related question. What type of modeling technique to be used when dependent variable (Y) is continuous but with 99% zero.The other 1% (+ve , don't have -ve values) values are huge. If I take DGP of dependent variable as Pareto type distribution, will it be ok? Your help will be highly appreciated. 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] All possible pairs of two variables
I have two variables (x,y) : x : it takes all integer values from 0 to y and, y : takes all values from 0, 10 I am looking for some R code to find all possible pairs of (x,y). Can anyone please help me? New Email addresses available on Yahoo! Get the Email name you#39;ve always wanted on the new @ymail and @rocketmail. Hurry before someone else does! [[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] as.Date() clarification
When I use the code as.Date(0) the I get : 1970-01-01. My question is why it is like that? help file on as.Date seems to give no light on that. Can anyone clarify me? Â Regards, Send instant messages to your online friends http://uk.messenger.yahoo.com [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] A regression problem using dummy variables
which group contrasts you want to look at can you clarify me on that statement? --- On Thu, 3/7/08, Peter Dalgaard [EMAIL PROTECTED] wrote: From: Peter Dalgaard [EMAIL PROTECTED] Subject: Re: [R] A regression problem using dummy variables To: rlearner309 [EMAIL PROTECTED] Cc: r-help@r-project.org Date: Thursday, 3 July, 2008, 2:57 PM rlearner309 wrote: I think it is zero, because you have lots of zeros there. It is not like continous variables. Think again. The sum of products may be zero, but that is not the covariance. And don't dismiss Thomas, he is usually right. Anyways, the coefs of dummy variables represent differences to the same base level, and chosing a poorly determined base level (essentially: whose mean is determined by only a few observations) will cause high parameter correlation. It should only affect those parameters though, and it is not really clear what VIF means for dummy variables. One often choses to relevel() to make the largest group the base level, but it really comes down to which group contrasts you want to look at. Thomas Lumley wrote: On Wed, 2 Jul 2008, rlearner309 wrote: I think the covariance between dummy variables or between dummy variables and intercept should always be zero. meaning: no sigularity problem?? No. You can easily check that this is not true using the cov() function. Indicator variables for mutually exclusive groups are negatively correlated. -thomas rlearner309 wrote: This is actually more like a Statistics problem: I have a dataset with two dummy variables controlling three levels. The problem is, one level does not have many observations compared with other two levels (a couple of data points compared with 1000+ points on other levels). When I run the regression, the result is bad. I have unbalanced SE and VIF. Does this kind of problem also belong to near sigularity problem? Does it make any difference if I code the level that lacks data (0,0) in stead of (0,1)? thanks a lot! -- View this message in context: http://www.nabble.com/A-regression-problem-using-dummy-variables-tp18214377p18237666.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. Thomas LumleyAssoc. Professor, Biostatistics [EMAIL PROTECTED]University of Washington, Seattle __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- O__ Peter Dalgaard Ãster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Send instant messages to your online friends http://uk.messenger.yahoo.com [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] A regression problem using dummy variables
VR's MASS book can you give the full name of that book --- On Thu, 3/7/08, Bert Gunter [EMAIL PROTECTED] wrote: From: Bert Gunter [EMAIL PROTECTED] Subject: RE: [R] A regression problem using dummy variables To: [EMAIL PROTECTED] Cc: r-help@r-project.org Date: Thursday, 3 July, 2008, 9:21 PM Contrasts for categorical variables are a technical issue in linear models. They are best understood (imo) as the choice of bases for the vector space of the model matrix. So how good is your linear algebra? A terse but I think very clear treatment of these issues can be found in the relevant chapter of VR's MASS book. FWIW, I have found that even statisticians get confused by these issues (certainly I have!). -- Bert Gunter -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Ron Michael Sent: Thursday, July 03, 2008 2:19 AM To: rlearner309; Peter Dalgaard Cc: r-help@r-project.org Subject: Re: [R] A regression problem using dummy variables which group contrasts you want to look at can you clarify me on that statement? --- On Thu, 3/7/08, Peter Dalgaard [EMAIL PROTECTED] wrote: Send instant messages to your online friends http://uk.messenger.yahoo.com [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Interactive plot
Hi, whenever I try to load the playwith package I am getting following warning : Â library(playwith) Loading required package: lattice Loading required package: grid Warning message: In namespaceImportFrom(self, asNamespace(ns)) : Â replacing previous import: addhandler Can anyone please tell me why I am getting that warning? --- On Sun, 29/6/08, Gabor Grothendieck [EMAIL PROTECTED] wrote: From: Gabor Grothendieck [EMAIL PROTECTED] Subject: Re: [R] Interactive plot To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Date: Sunday, 29 June, 2008, 8:18 PM Install the GTK runtime: http://www.ggobi.org/rgtk2/ On Sun, Jun 29, 2008 at 9:06 AM, Ron Michael [EMAIL PROTECTED] wrote: whenever I try to load playwith package I get following error : library(playwith) Loading required package: lattice Loading required package: grid Error in inDL(x, as.logical(local), as.logical(now), ...) : unable to load shared library 'C:/PROGRA~1/R/R-27~1.1/library/RGtk2/libs/RGtk2.dll': LoadLibrary failure: The specified module could not be found. Error: package/namespace load failed for 'playwith' What to do? --- On Sun, 29/6/08, Liviu Andronic [EMAIL PROTECTED] wrote: From: Liviu Andronic [EMAIL PROTECTED] Subject: Re: [R] Interactive plot To: Ron Michael [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Date: Sunday, 29 June, 2008, 7:46 PM On 6/29/08, Ron Michael [EMAIL PROTECTED] wrote: Now I want to present the plot in some interactive manner. I want to put a slider in the plot where user move the slider for the 1st element of the vector vary and automatically this result will be reflected at the plot window. playwith: A GUI for interactive plots using GTK+ ? [1] [1] http://cran.at.r-project.org/web/packages/playwith/index.html Send instant messages to your online friends http://uk.messenger.yahoo.com [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Send instant messages to your online friends http://uk.messenger.yahoo.com [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Interactive plot
Hi all R users. I already done through some of the examples given with playwith packages and feel nowhere they are matching with my requirement. Can amyone please suggest me how to create my desired interactive plot with tkrplot ? Â I want following. Let look at following codes : Â mat = cbind(c(0.59710430,0.23057380), c(0.23057380, 0.5971089)) set.seed = 1000 vary = runif(dim(mat)[1], 2000, 3000) calc = function(mat, vary) { result = vector(length = (length(vary)+1)) result[1] = sqrt(t(vary) %*% vary) for (i in 1 : length(vary)) { result[(i+1)] = sum(vary)*sum(vary*mat[,i]) } barplot(result) return(result) } Â Now I want to put a slider in the plot where user move the slider for the 1st element of the vector vary and automatically this result will be reflected at the plot window. Can anyone please tell me how to do that with tkrplot or TeachingDemos ? Â Â --- On Sun, 29/6/08, Ron Michael [EMAIL PROTECTED] wrote: From: Ron Michael [EMAIL PROTECTED] Subject: Re: [R] Interactive plot To: Gabor Grothendieck [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Date: Sunday, 29 June, 2008, 11:48 PM Hi, whenever I try to load the playwith package I am getting following warning : Â library(playwith) Loading required package: lattice Loading required package: grid Warning message: In namespaceImportFrom(self, asNamespace(ns)) : Â replacing previous import: addhandler Can anyone please tell me why I am getting that warning? --- On Sun, 29/6/08, Gabor Grothendieck [EMAIL PROTECTED] wrote: From: Gabor Grothendieck [EMAIL PROTECTED] Subject: Re: [R] Interactive plot To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Date: Sunday, 29 June, 2008, 8:18 PM Install the GTK runtime: http://www.ggobi.org/rgtk2/ On Sun, Jun 29, 2008 at 9:06 AM, Ron Michael [EMAIL PROTECTED] wrote: whenever I try to load playwith package I get following error : library(playwith) Loading required package: lattice Loading required package: grid Error in inDL(x, as.logical(local), as.logical(now), ...) : unable to load shared library 'C:/PROGRA~1/R/R-27~1.1/library/RGtk2/libs/RGtk2.dll': LoadLibrary failure: The specified module could not be found. Error: package/namespace load failed for 'playwith' What to do? --- On Sun, 29/6/08, Liviu Andronic [EMAIL PROTECTED] wrote: From: Liviu Andronic [EMAIL PROTECTED] Subject: Re: [R] Interactive plot To: Ron Michael [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Date: Sunday, 29 June, 2008, 7:46 PM On 6/29/08, Ron Michael [EMAIL PROTECTED] wrote: Now I want to present the plot in some interactive manner. I want to put a slider in the plot where user move the slider for the 1st element of the vector vary and automatically this result will be reflected at the plot window. playwith: A GUI for interactive plots using GTK+ ? [1] [1] http://cran.at.r-project.org/web/packages/playwith/index.html Send instant messages to your online friends http://uk.messenger.yahoo.com [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Send instant messages to your online friends http://uk.messenger.yahoo.com [[alternative HTML version deleted]]__ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Send instant messages to your online friends http://uk.messenger.yahoo.com [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Interactive plot
, RGtkObject Error in `[[-.GObject`(`*tmp*`, tooltip-text, value = Zoom out to show 4x plot area) :  Cannot find 'tooltip-text' to set in GtkToolButton, GtkToolItem, GtkBin, GtkContainer, GtkWidget, GtkObject, GInitiallyUnowned, GObject, RGtkObject Error in `[[-.GObject`(`*tmp*`, tooltip-text, value = Show the full scale starting from zero) :  Cannot find 'tooltip-text' to set in GtkToolButton, GtkToolItem, GtkBin, GtkContainer, GtkWidget, GtkObject, GInitiallyUnowned, GObject, RGtkObject   Any idea how to fix that?  --- On Mon, 30/6/08, Gabor Grothendieck [EMAIL PROTECTED] wrote: From: Gabor Grothendieck [EMAIL PROTECTED] Subject: Re: [R] Interactive plot To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Date: Monday, 30 June, 2008, 12:30 AM In ?playwith the third example seems pretty close to what you want. Here it is changed to correspond to your setup. Remove the barplot line from calc since we don't want calc to do any plotting and then try this: library(lattice) playwith(barchart(seq_along(result) ~ result, data = data.frame(result = calc(mat, c(alpha, vary[2], parameters = list(alpha = seq(2000, 3000, by = 10))) On Sun, Jun 29, 2008 at 1:07 PM, Ron Michael [EMAIL PROTECTED] wrote: Hi all R users. I already done through some of the examples given with playwith packages and feel nowhere they are matching with my requirement. Can amyone please suggest me how to create my desired interactive plot with tkrplot ? I want following. Let look at following codes : mat = cbind(c(0.59710430,0.23057380), c(0.23057380, 0.5971089)) set.seed = 1000 vary = runif(dim(mat)[1], 2000, 3000) calc = function(mat, vary) { result = vector(length = (length(vary)+1)) result[1] = sqrt(t(vary) %*% vary) for (i in 1 : length(vary)) { result[(i+1)] = sum(vary)*sum(vary*mat[,i]) } barplot(result) return(result) } Now I want to put a slider in the plot where user move the slider for the 1st element of the vector vary and automatically this result will be reflected at the plot window. Can anyone please tell me how to do that with tkrplot or TeachingDemos ? --- On Sun, 29/6/08, Ron Michael [EMAIL PROTECTED] wrote: From: Ron Michael [EMAIL PROTECTED] Subject: Re: [R] Interactive plot To: Gabor Grothendieck [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Date: Sunday, 29 June, 2008, 11:48 PM Hi, whenever I try to load the playwith package I am getting following warning : library(playwith) Loading required package: lattice Loading required package: grid Warning message: In namespaceImportFrom(self, asNamespace(ns)) : replacing previous import: addhandler Can anyone please tell me why I am getting that warning? --- On Sun, 29/6/08, Gabor Grothendieck [EMAIL PROTECTED] wrote: From: Gabor Grothendieck [EMAIL PROTECTED] Subject: Re: [R] Interactive plot To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Date: Sunday, 29 June, 2008, 8:18 PM Install the GTK runtime: http://www.ggobi.org/rgtk2/ On Sun, Jun 29, 2008 at 9:06 AM, Ron Michael [EMAIL PROTECTED] wrote: whenever I try to load playwith package I get following error : library(playwith) Loading required package: lattice Loading required package: grid Error in inDL(x, as.logical(local), as.logical(now), ...) : unable to load shared library 'C:/PROGRA~1/R/R-27~1.1/library/RGtk2/libs/RGtk2.dll': LoadLibrary failure: The specified module could not be found. Error: package/namespace load failed for 'playwith' What to do? --- On Sun, 29/6/08, Liviu Andronic [EMAIL PROTECTED] wrote: From: Liviu Andronic [EMAIL PROTECTED] Subject: Re: [R] Interactive plot To: Ron Michael [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Date: Sunday, 29 June, 2008, 7:46 PM On 6/29/08, Ron Michael [EMAIL PROTECTED] wrote: Now I want to present the plot in some interactive manner. I want to put a slider in the plot where user move the slider for the 1st element of the vector vary and automatically this result will be reflected at the plot window. playwith: A GUI for interactive plots using GTK+ ? [1] [1] http://cran.at.r-project.org/web/packages/playwith/index.html Send instant messages to your online friends [[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. Send instant messages to your online friends http://uk.messenger.yahoo.com [[alternative HTML version deleted]]__ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Send instant messages to your online friends http
[R] Interactive plot
Hi all, I have created following codes : mat = cbind(c(0.59710430,0.23057380), c(0.23057380, 0.5971089)) set.seed = 1000 vary = runif(dim(mat)[1], 2000, 3000) calc = function(mat, vary) { result = vector(length = (length(vary)+1)) result[1] = sqrt(t(vary) %*% vary) for (i in 1 : length(vary)) { result[(i+1)] = sum(vary)*sum(vary*mat[,i]) } barplot(result) return(result) } Now I want to present the plot in some interactive manner. I want to put a slider in the plot where user move the slider for the 1st element of the vector vary and automatically this result will be reflected at the plot window. I already gone through some examples of tkrplot library, however unfortunately could not figure out how i can apply them in my problem. If anyone here explain me how to do that I would be grateful. Regards, Send instant messages to your online friends http://uk.messenger.yahoo.com [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Need help to draw a plot
can i have some instruction on how to draw this type of plot in R : http://sitmo.com/doc/Image:Ll_ou_conpron.png#filelinks ? Regards, Send instant messages to your online friends http://uk.messenger.yahoo.com [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Interpretation of Variance decomposition in VAR model
Hi all, This question is not really R related, rather on Statistics subject itself. Even I did not do those using R. however still I want to post it here, because my hope is I could get help from great statisticians who are the very active member of this group. My problem is to interpret Variance decomposition of VAR model in layman's language. Using EViews I got following : Variance Decomposition of LN_FU: Period S.E.LN_SPOT LN_FU 1 0.02442293.669596.330413 2 0.03483894.365065.634938 3 0.04228094.607125.392882 4 0.04854094.307255.692747 5 0.05406093.990396.009611 6 0.05904293.675456.324554 7 0.06362193.334056.665951 8 0.06788592.993477.006529 9 0.07189392.659667.340337 10 0.07568792.332667.667341 Variance Decomposition of LN_SPOT: Period S.E.LN_SPOT LN_FU 1 0.023745100.0.00 2 0.03374199.511220.488785 3 0.04101899.253390.746605 4 0.04720498.983541.016462 5 0.05266098.624011.375990 6 0.05760098.249851.750151 7 0.06215597.863032.136970 8 0.06640097.461972.538034 9 0.07039497.056552.943451 10 0.07417696.651023.348978 Cholesky Ordering: LN_SPOT LN_FU Myquestion is How to interpret those result in layman language? If I sayfollowing : 93.66959% of tomorrow's volatility in LN_FU is explainedby LN_SPOT's today volatility and remaining 6.330413% is explained byit's today's Volatility, is this statement correct? Then what will bethe interpretation of remaining numbers like : 94.36506,5.634938,..etc? And also What could be the interpretation of the SE in layman's term? I already gone through Eviews help file however, did not get anything. If u people here help me on this regard, I will be very very grateful. Regards, Send instant messages to your online friends http://uk.messenger.yahoo.com [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Interpretation of Variance decomposition in VAR model
Hi all, This question is not really R related, rather on Statistics subject itself. Even I did not do those using R. however still I want to post it here, because my hope is I could get help from great statisticians who are the very active member of this group. My problem is to interpret Variance decomposition of VAR model in layman's language. Using EViews I got following : Variance Decomposition of LN_FU: Period S.E.LN_SPOT LN_FU 1 0.02442293.669596.330413 2 0.03483894.365065.634938 3 0.04228094.607125.392882 4 0.04854094.307255.692747 5 0.05406093.990396.009611 6 0.05904293.675456.324554 7 0.06362193.334056.665951 8 0.06788592.993477.006529 9 0.07189392.659667.340337 10 0.07568792.332667.667341 Variance Decomposition of LN_SPOT: Period S.E.LN_SPOT LN_FU 1 0.023745100.0.00 2 0.03374199.511220.488785 3 0.04101899.253390.746605 4 0.04720498.983541.016462 5 0.05266098.624011.375990 6 0.05760098.249851.750151 7 0.06215597.863032.136970 8 0.06640097.461972.538034 9 0.07039497.056552.943451 10 0.07417696.651023.348978 Cholesky Ordering: LN_SPOT LN_FU Myquestion is How to interpret those result in layman language? If I sayfollowing : 93.66959% of tomorrow's volatility in LN_FU is explainedby LN_SPOT's today volatility and remaining 6.330413% is explained byit's today's Volatility, is this statement correct? Then what will bethe interpretation of remaining numbers like : 94.36506,5.634938,..etc? And also What could be the interpretation of the SE in layman's term? I already gone through Eviews help file however, did not get anything. If u people here help me on this regard, I will be very very grateful. Regards, Send instant messages to your online friends http://uk.messenger.yahoo.com [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Different results in calculating SD of 2 numbers
Hi all, Can anyone tell me why I am getting different results in calculating SD of 2 numbers ? (1.25-0.95)/2 [1] 0.15 sd(c(1.25, 0.95)) [1] 0.2121320 # why it is different from 0.15? Regards, Send instant messages to your online friends http://uk.messenger.yahoo.com [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.