tag:blogger.com,1999:blog-4946490806848569840.comments2019-12-09T02:30:46.470-08:00R snippetsUnknownnoreply@blogger.comBlogger216125tag:blogger.com,1999:blog-4946490806848569840.post-34425379391820364622019-12-09T02:27:04.176-08:002019-12-09T02:27:04.176-08:00This comment has been removed by a blog administrator.Blog Comment Backlinkshttps://www.blogger.com/profile/11978208268095899570noreply@blogger.comtag:blogger.com,1999:blog-4946490806848569840.post-26680991965838398772019-11-11T11:36:02.938-08:002019-11-11T11:36:02.938-08:00Here is a basic tutorial how to write functions in...Here is a basic tutorial how to write functions in R: https://swcarpentry.github.io/r-novice-inflammation/02-func-R/Bogumił Kamińskihttps://www.blogger.com/profile/06250268799809238730noreply@blogger.comtag:blogger.com,1999:blog-4946490806848569840.post-75936280397662644452019-11-11T10:16:55.514-08:002019-11-11T10:16:55.514-08:00Hi, I am just coming back to this. Thanks for your...Hi, I am just coming back to this. Thanks for your response. How would you rewrite this code (e.g. the Shapley-Shubik code so that it is all in one function? I'm new to writing R functionsSimonhttps://www.blogger.com/profile/05981296362335774054noreply@blogger.comtag:blogger.com,1999:blog-4946490806848569840.post-19905726505208403132018-10-22T07:28:29.626-07:002018-10-22T07:28:29.626-07:00For larger data probably R is not the best tool fo...For larger data probably R is not the best tool for the job.Bogumił Kamińskihttps://www.blogger.com/profile/06250268799809238730noreply@blogger.comtag:blogger.com,1999:blog-4946490806848569840.post-43555592932145209742018-10-22T07:22:55.818-07:002018-10-22T07:22:55.818-07:00Can you help me with visualizing this model on zip...Can you help me with visualizing this model on zip code level data? thanksAnonymoushttps://www.blogger.com/profile/00170846508259360447noreply@blogger.comtag:blogger.com,1999:blog-4946490806848569840.post-87470814008191401422018-06-29T00:36:57.454-07:002018-06-29T00:36:57.454-07:00This comment has been removed by a blog administrator.Anonymoushttps://www.blogger.com/profile/01234746697832066061noreply@blogger.comtag:blogger.com,1999:blog-4946490806848569840.post-75123850753464539102018-06-19T07:01:01.002-07:002018-06-19T07:01:01.002-07:00Spot on with this write-up, I actually suppose thi...Spot on with this write-up, I actually suppose this web site wants far more consideration. I’ll probably be once more to learn far more, thanks for that info. <a href="https://online-casinos.us.org" rel="nofollow">usa online casino</a>fillikir72518https://www.blogger.com/profile/04617626994297367122noreply@blogger.comtag:blogger.com,1999:blog-4946490806848569840.post-81002622042197615502018-06-16T08:09:52.489-07:002018-06-16T08:09:52.489-07:00Once I initially commented I clicked the -Notify m...Once I initially commented I clicked the -Notify me when new comments are added- checkbox and now every time a comment is added I get 4 emails with the identical comment. Is there any method you can remove me from that service? Thanks! <a href="https://online-casinos.us.org" rel="nofollow">casino games</a>yosabrams0918https://www.blogger.com/profile/11140186761749280113noreply@blogger.comtag:blogger.com,1999:blog-4946490806848569840.post-75738759057591525122018-04-18T13:05:40.205-07:002018-04-18T13:05:40.205-07:00The answer is yes to both questionsThe answer is yes to both questionsBogumił Kamińskihttps://www.blogger.com/profile/06250268799809238730noreply@blogger.comtag:blogger.com,1999:blog-4946490806848569840.post-17735139959923283802018-04-18T07:14:41.211-07:002018-04-18T07:14:41.211-07:00HI there: Two questions: 1) do the permutations ne...HI there: Two questions: 1) do the permutations need to match the number of constituencies in the variable constit? 2) Is the number 107 the number required to win the election? Simonhttps://www.blogger.com/profile/05981296362335774054noreply@blogger.comtag:blogger.com,1999:blog-4946490806848569840.post-89503172257600969522017-06-28T01:59:04.178-07:002017-06-28T01:59:04.178-07:00This is exactly how I understand it :) and that is...This is exactly how I understand it :) and that is why I show what programming languages Julia users use.Bogumił Kamińskihttps://www.blogger.com/profile/06250268799809238730noreply@blogger.comtag:blogger.com,1999:blog-4946490806848569840.post-87578045528702245932017-06-28T01:28:03.782-07:002017-06-28T01:28:03.782-07:00Here we have a great example of Simpson's para...Here we have a great example of Simpson's paradox ;).<br />R is used almost 100% by scientific oriented programmers (statistical research, data science...) while python is only used by a fraction as a scientific language, as many people uses as a general purpose language (web programming, OS scripting, apps..). I am almost positive that comparing the people who uses both languages as a scientific oriented language you will obtain similar results (numpy, pandas...).Gabrielhttps://www.blogger.com/profile/09238993347653608368noreply@blogger.comtag:blogger.com,1999:blog-4946490806848569840.post-77979245212621100552017-06-27T22:08:48.505-07:002017-06-27T22:08:48.505-07:00I wanted to say that among all languages R is the ...I wanted to say that among all languages R is the language who's users user Julia most. I agree that the wording is confusing and will correct it.Bogumił Kamińskihttps://www.blogger.com/profile/06250268799809238730noreply@blogger.comtag:blogger.com,1999:blog-4946490806848569840.post-86405451118110973742017-06-27T16:55:45.530-07:002017-06-27T16:55:45.530-07:00I'm confused. It says "most" R users...I'm confused. It says "most" R users also use Julia then it says 2.26%. 2% of R users are "most" R users?Anonymoushttps://www.blogger.com/profile/10525668526999547235noreply@blogger.comtag:blogger.com,1999:blog-4946490806848569840.post-68266099081588945922017-01-16T04:43:49.113-08:002017-01-16T04:43:49.113-08:00great articlegreat articleAnonymoushttps://www.blogger.com/profile/09188944739603626888noreply@blogger.comtag:blogger.com,1999:blog-4946490806848569840.post-31156634314219241572016-12-18T22:07:06.510-08:002016-12-18T22:07:06.510-08:00Thank you very much for your help! I will try to u...Thank you very much for your help! I will try to understand this function.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-4946490806848569840.post-13885661492251314632016-12-18T10:04:06.686-08:002016-12-18T10:04:06.686-08:00My function: unfortunately :(, I think that the be...My function: unfortunately :(, I think that the best advice is to read documentation of all functions I use in R help.<br /><br />Generators: https://en.wikipedia.org/wiki/Generator_(computer_programming)Bogumił Kamińskihttps://www.blogger.com/profile/06250268799809238730noreply@blogger.comtag:blogger.com,1999:blog-4946490806848569840.post-41872857698365228842016-12-18T04:47:53.912-08:002016-12-18T04:47:53.912-08:00Thank you very much! I had attempted to generate a...Thank you very much! I had attempted to generate all subsets of {1,...,200} to test an assumption of EBIC, but I just found it would take at least 2^200 bytes to store its power sets. What should I read to understand your all.subsets.fast() function? What should I read to understand "generator"? I am a grad student in stats, have a bsc in math. Thank you very much!Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-4946490806848569840.post-9285473693288582672016-12-08T00:39:17.578-08:002016-12-08T00:39:17.578-08:00Such a large structure simply does not fit into me...Such a large structure simply does not fit into memory.<br />You would have to use generator rather than materialized structure. Anyway 2^50=1125899906842624 so you will not be able to iterate over such a large number of elements anyway.Bogumił Kamińskihttps://www.blogger.com/profile/06250268799809238730noreply@blogger.comtag:blogger.com,1999:blog-4946490806848569840.post-7839262773817293912016-12-07T19:02:08.590-08:002016-12-07T19:02:08.590-08:00Hi, your code is much faster than the set_power() ...Hi, your code is much faster than the set_power() in sets package, but when I try all.subsets.fast(seq(1:50)), it says:<br />Error: cannot allocate vector of size 4194304.0 Gb. How can I fix it? Thanks!Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-4946490806848569840.post-58607957929094905012016-12-06T22:45:44.517-08:002016-12-06T22:45:44.517-08:00Great post. Thanks. Great post. Thanks. 常青树https://www.blogger.com/profile/09499813030229291918noreply@blogger.comtag:blogger.com,1999:blog-4946490806848569840.post-17136789747140136352016-12-06T08:56:54.244-08:002016-12-06T08:56:54.244-08:00Thanks for a nicer version of gen_data func!
Regar...Thanks for a nicer version of gen_data func!<br />Regarding pam. The post is about optimization in general. pam is limited in functionality and do not handle side constraints. For a real life problem you can check my presentation I gave at EARL 2014 (https://goo.gl/YY1d31). Wit Jakuczunhttps://www.blogger.com/profile/11026188487219287866noreply@blogger.comtag:blogger.com,1999:blog-4946490806848569840.post-82417787117758010962016-12-06T05:47:53.382-08:002016-12-06T05:47:53.382-08:00An absolutely killer-feature of Julia JuMP is the ...An absolutely killer-feature of Julia JuMP is the ability to define lazy-constraints via callbacks in a solver-independent manner. Many of the best algorithms for problems make use of such techniques (such as subtour-elimination in Travelling Salesman) and the ability to easily program them is something that I have not seen in any library other than JuMP.Anonymoushttps://www.blogger.com/profile/07517057242770665359noreply@blogger.comtag:blogger.com,1999:blog-4946490806848569840.post-14996400736357874222016-12-06T04:22:54.917-08:002016-12-06T04:22:54.917-08:00Thank you for the comment about ompr package. This...Thank you for the comment about ompr package. This is exactly what I have been looking for! I will have to check it out in detail, but it looks very good.<br /><br />As for the speed - most of the time is spent in solver and the solver is the same in both cases.Bogumił Kamińskihttps://www.blogger.com/profile/06250268799809238730noreply@blogger.comtag:blogger.com,1999:blog-4946490806848569840.post-73424061757968941182016-12-06T04:09:11.603-08:002016-12-06T04:09:11.603-08:00I really understand that glpkAPI has poor designed...I really understand that glpkAPI has poor designed interface in comparison with JuMP. But why R code is so unnecessary obfuscated and complicated in your example? Especially confusing is two type-castings to data.frame in 'gen_data'. In Julia you use matrix type for your data. Why don't you use matrix in R? Just for completeness - in real life R code for this tasks looks like this:<br /><br />gen_data = function(N, K, scaling) {<br /> alpha = 2 * pi * (1:N) / K<br /> sin_pi_K = 2 * sin(pi / K)<br /> x = matrix(rnorm(n = 2*N), nrow = N)<br /> x + cbind(cos(alpha), sin(alpha)) * scaling / sin_pi_K<br />}<br /><br />set.seed(1)<br />x = gen_data(200, 4, 5)<br /><br />library(cluster)<br />lapply(2:6, function(k) pam(x, k = k))Anonymoushttps://www.blogger.com/profile/09827917062640566527noreply@blogger.com