Posts

Showing posts from January, 2014

r - Subset with unique cases, based on multiple columns -

i'd subset dataframe include rows have unique combinations of 3 columns. situation similar 1 presented in this question, i'd preserve other columns in data well. here's example: > df v1 v2 v3 v4 v5 1 7 1 100 98 2 7 2 98 97 3 8 1 c na 80 4 8 1 c 78 75 5 8 1 c 50 62 6 9 3 c 75 75 the requested output this, i'm looking unique cases based on v1, v2, , v3 only: > df.new v1 v2 v3 v4 v5 1 7 1 100 98 2 7 2 98 97 3 8 1 c na 80 6 9 3 c 75 75 if recover non-unique rows great too: > df.dupes v1 v2 v3 v4 v5 3 8 1 c na 80 4 8 1 c 78 75 5 8 1 c 50 62 i saw related question how in sql ( here ), can't in r. i'm sure it's simple messing unique() , subset() hasn't been fruitful. in advance. you can use duplicated() function find unique combinations: > df[!duplicated(df[1:3]),] v1 v2 v3 v4 v5 1 7 1 100 98 2 7 2 98 97 3 8 1 c na 80 6 9 3 c 75 75 to duplicates, can check in both directions: > df[duplicated(df[1:3]) | duplicated(df[1:3], fromlast...

c# - Could not load file or assembly ... An attempt was made to load a program with an incorrect format (System.BadImageFormatException) -

i have 2 projects, projecta , projectb . projectb console application, depends on projecta . yesterday, working fine, today when run projectb this: badimageformatexception unhandled : not load file or assembly 'projecta, version=1.0.0.0, culture=neutral, publickeytoken=null' or 1 of dependencies. attempt made load program incorrect format. both regular projects, no dependencies on other non-.net projects. both .net - there no native code, , no p/invoke. have other projects depend on projecta , still work fine. things have tried: make sure both projects set "any cpu," build checkbox checked. are. make sure both projects same target framework (.net 4.0 client profile) . under projectb --> references --> projecta --> properties, make sure "copy local" set "true" _ (i verified projecta.dll being copied correctly) clean/rebuild solution. tried manually deleting /bin , /obj folders in both projects. restart visual studio. re...

c# - How do you get the text from a listbox by index? -

i trying text entry in winforms listbox index, seem stumped. logical thing can think of is: listbox.items[index].tostring but not return desired result. does know how this? what have in listbox? if there string values in listbox, code correct except missing braces: string value = listbox.items[index].tostring(); if things in listbox sort of object, may need override tostring() desired result, or cast thing out of listbox desired type , access appropriate property. example: myclass = (myclass)listbox.items[index]; string value = my.somepropertyofmyclass;

objective c - Check for first launch of my application -

how check if first launch of of application using nsuserdefaults , running code first time app opens? this should point in right direction: static nsstring* const hasrunapponcekey = @"hasrunapponcekey"; nsuserdefaults* defaults = [nsuserdefaults standarduserdefaults]; if ([defaults boolforkey:hasrunapponcekey] == no) { // code want run on first use... [defaults setbool:yes forkey:hasrunapponcekey]; }

A jar used in android library project is not visible in the project using that library -

i have 3 android projects this, library projecta projectb i have used admob's jar file in library, projecta , b use library project reference, library.jar the admob jar not directly added in project or b. hoping since , b referencing library project , library references admob jar, access classes of admob jar in projects , b without explicitly using admob jar in a/b. project a/b not have specific code classes related admob jar. related code in library , code meant run when projects compiled. so happens runtime crash saying class not found. if add admob jar projects there no runtime problem. please advise me correct way of doing it.. thanks, found answer, in project properties -> java build path -> order , import , checked admob jar file , worked :)

Ruby Asynchronous Net::HTTP? -

does net::http support asynchronous syntax? i'm looking code below. the block called on main thread after net::http has either received response server (in case, error nil ) or encountered error connecting server (in case response nil ). net::http.get('http://stackoverflow.com') |response, error| if error puts "connection error: #{error.message}" elsif response.status_code != httpok puts "unexpected status code: #{response.status_code}" puts response.body else puts "success!" puts response.body end end the following questions provide answers i'm looking block-based solution. asynchronous http request in ruby asynchronous http requests ruby have @ eventmachine , em-http-request gems. equivalent above code be require 'rubygems' require 'eventmachine' require 'em-http' http_ok = 200 em.run http = em::httprequest.new('http://example.com').get http.errback puts "connection error: #{http.er...

javascript - Geolocation Code Not Working for iPhone / iPod Touch / iPad -

we did testing @ apple store, , found out our geolocation code (getting latitude , longitude), not working iphone, ipod touch, or ipad. did have add code work macbook / imac. anyone know code latitude / longitude works sure on ipod touch / iphone / ipad devices? code: // needed iphone / ipad / itouch <script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?key=aizasydrorw0ri-1v-5bixc4t_zlehcbbwgzyuq&amp;sensor=true"></script> // needed imac / macbook <script src="http://code.google.com/apis/gears/gears_init.js" type="text/javascript"></script> <script src="http://gaychat.me/js/geo.js" type="text/javascript" ></script> <script type="text/javascript"><!-- var ua = navigator.useragent.tolowercase(); var isandroid = ua.indexof("android") > -1; var isiphone = ua.indexof("iphone") > -1; var isipod = ua.indexof("ipod")...

windows phone 7 - Block Callers List -

is possible create program let me block calls numbers save in list if not possible in current version there word if may supported in next version releasing later in year links info read appreciated no, windows phone doesn't allow third party apps run in background (restrictive multitasking allowed) , doesn't allow applications interfere phone itself. without sdk wp8 there no way tell if situation has changed yet.

c - Use of resolv.h -

i'm trying find out dns server address reading resolv.h's _res struct. according man 3 resolver setup code should be. #include <netinet/in.h> #include <arpa/nameser.h> #include <resolv.h> extern struct state _res; and read out whatever need. problem trying compile get resolver.c:5:21: error: conflicting types '__res_state' extern struct state _res; ^ /usr/include/resolv.h:251:16: note: expanded macro '_res' #define _res (*__res_state()) ^ /usr/include/resolv.h:249:28: note: previous declaration here extern struct __res_state *__res_state(void) __attribute__ ((__const__)); ^ 1 error generated. by clang. what doing wrong? you shouldn't declare _res - resolv.h includes right declaration (despite man page implies).

android - Changing Map Infowindow from alert dialogue to simple map Info -

i have map application in android. there alert dialogue when click on marker, want convert alert dialogue simple infowindow this: http://3.bp.blogspot.com/-pryuyqmcgcc/ta__3fccw7i/aaaaaaaaagu/xcxjk3slu4k/s1600/google_map_marker_tooltip_popup_android.jpg here code i'm using populate infowindow : public class customitemizedoverlay extends itemizedoverlay<overlayitem> { private arraylist<overlayitem> mapoverlays = new arraylist<overlayitem>(); private context context; public customitemizedoverlay(drawable defaultmarker) { super(boundcenterbottom(defaultmarker)); } public customitemizedoverlay(drawable defaultmarker, context context) { this(defaultmarker); this.context = context; } @override protected overlayitem createitem(int i) { return mapoverlays.get(i); } @override public int size() { return mapoverlays.size(); } @override protected boolean ontap(int index) { overlayitem item = mapoverlays.get(index); alertdialog.builder dialog = new alertdialog.builder(con...

android xml: reference a menu in multiple places. -

Image
i have: <item android:id="@+id/fp_pitcher" android:title="pitcher"> <menu> <item android:id="@+id/caught" android:title="caught"> </item> <item android:id="@+id/not_caught" android:title="not caught"> </item> </menu> </item> <item android:id="@+id/fp_catcher" android:title="catcher"> <menu> <item android:id="@id/caught" android:title="caught"> </item> <item android:id="@id/not_caught" android:title="not caught"> </item> </menu> </item> <item android:id="@+id/fp_firstbaseman" android:title="first baseman"> <menu> <item android:id="@+id/caught" android:title="caught"> </item> <item android:id="@+id/not_caught" android:title="not caught"> </item> </menu> </item> <...

java - creating a command based logger program -

i'm trying make java program creates , writes log file. it has 2 classes (one request, 1 worker code). 1 class has textfield , allows enter command. command should 'log start' or 'log stop'. so request class sends command string, worker class gets command, parses , executes instructions (start logging, stop logging. my problem is: application doesn't stop logging when user enters 'stop' command. well, doesn't stop after 3 log entries (that's problem. want stop time user enters command) understand problem better when take @ code. i know i'm making basic mistake here somehow can't figure out , want opinion on problem. (i showed problematic in code) thank you. error: exception in thread "stoplogging" java.lang.arrayindexoutofboundsexception: 1 @ response$clientprocess$1stopperthread.run(response.java:109) @ java.lang.thread.run(unknown source) request class: public class request extends jframe { private jtextarea consolear...