Posts

r - Variable assignment during re-coding loop -

i importing survey data csv file in r, , want use for-loop reassign periods in cells "na". 1 survey item, have this: survey$q1a <- recode(survey$q1a, "'.'=na") # csv column survey$q1a <- as.numeric(as.character(survey$q1a)) where q1a column title in csv file, , refers question 1, part (i have 137 columns). so, in order make for-loop, need able this: for (n in 1:31){ survey$qna <- recode(survey$qna, "'.'=na") # csv column n survey$qna <- as.numeric(as.character(survey$qna)) } 31 items have part a, means need survey$q1a survey$q31a . sake of simplicity, best keep columns in qna format (ironically). have never used r, have experience python , c, , know use % %s operators in languages achieve similar goals. is there way in r without changing how variable/column labeling system?

python - Finding and utilizing eigenvalues and eigenvectors from PCA in scikit-learn -

i have been utilizing pca implemented in scikit-learn. however, want find eigenvalues , eigenvectors result after fit training dataset. there no mention of both in docs. secondly, can these eigenvalues , eigenvectors utilized features classification purposes? i assuming here eigenvectors mean eigenvectors of covariance matrix. lets have n data points in p-dimensional space, , x p x n matrix of points directions of principal components eigenvectors of covariance matrix xx t . can obtain directions of these eigenvectors sklearn accessing components_ attribute of pca object. can done follows: from sklearn.decomposition import pca import numpy np x = np.array([[-1, -1], [-2, -1], [-3, -2], [1, 1], [2, 1], [3, 2]]) pca = pca() pca.fit(x) print pca.components_ this gives output [[ 0.83849224 0.54491354] [ 0.54491354 -0.83849224]] where every row principal component in p-dimensional space (2 in toy example). each of these rows eigenvector of centered covariance mat...

html - Resizeable text input -

i use bootstrap in site, wan't create this . my html code: <form class="navbar-form navbar-left" role="search"> <div class="form-group"> <input type="text" class="form-control search-input" placeholder="search"> </div> <button type="submit" class="btn btn-default"> 'find'</button> </form> how can resize input? in tutorial specified , css code there : add part html page : demo here <style stype='text/css'> input[type=text].search_form { border: 1px solid #ccc; border-radius: 3px; box-shadow: inset 0 1px 2px rgba(0,0,0,0.1); width:200px; min-height: 28px; padding: 4px 20px 4px 8px; font-size: 12px; -moz-transition: .2s linear; -webkit-transition: .2s linear; transition: .2s linear; } input[type=text]:focus.search_form { width: 400px; border-color: #51a7e8; box-shadow: inset 0 1px 2px rgba(0,0,0,0.1),0 0 5px ...

tk - couldn't load file "/usr/lib/x86_64-linux-gnu/magic/tcl/tclmagic.so" -

Image
i have problem running magic vlsi. problem couldn't load file "/usr/lib/x86_64-linux-gnu/magic/tcl/tclmagic.so": /usr/lib/x86_64-linux-gnu/magic/tcl/tclmagic.so: undefined symbol: tk_getcursorfromdata i think caused by: /usr/lib/x86_64-linux-gnu/magic/tcl/magic.tcl in line 13: load /usr/lib/x86_64-linux-gnu/magic/tcl/tclmagic.so the file /usr/lib/x86_64-linux-gnu/magic/tcl/tclmagic.so exists the error source in running magic qflow in shellscript display.sh : #!/bin/tcsh -f #---------------------------------------------------------- # qflow layout display script using magic-8.0 #---------------------------------------------------------- # tim edwards, april 2013 #---------------------------------------------------------- if ($#argv < 2) echo usage: display.sh [options] <project_path> <source_name> exit 1 endif # split out options main arguments (no options---placeholder only) set argline=(`getopt "" $argv[1-]`) set cmdarg...

Angularjs Google maps connect multiple markers -

i building ionic app , therein have following requirement: want use google maps , want able mark 3 markers on map -> connect 3 markers automatically -> , calculate area covered. i have following (map shown on screen, can add multiple markers): controller: angular.extend($scope, { map: { center: { latitude: 51.718921, longitude: 8.757509 }, zoom: 11, markers: [], events: { click: function (map, eventname, originaleventargs) { var e = originaleventargs[0]; var lat = e.latlng.lat(),lon = e.latlng.lng(); var marker = { id: date.now(), icon: 'http://maps.google.com/mapfiles/ms/icons/blue.png', coords: { latitude: lat, longitude: lon }, }; $scope.map.markers.push(marker); console.log($scope.map.markers); $sc...

CRON JOB - How to grab image from URL ...servlet/byvejr_dag1?by=5466&mode=long -

i want save image server cron job url: http://servlet.dmi.dk/byvejr/servlet/byvejr_dag1?by=5466&mode=long - png image i've tried following codes */5 * * * * curl http://servlet.dmi.dk/byvejr/servlet/byvejr_dag1?by=5466&mode=long > /home/klintweb/public_html/gal.klintmx.dk/images/vejr.png the image saved in folder, can't published because of error - file-size 0 byte there way this the job done php script $profile_image = 'http://servlet.dmi.dk/byvejr/servlet/byvejr_dag1?by=5466&mode=long'; //image url $userimage = 'byvejr_dag1_5466.png'; // renaming image $path = '/home/klintweb/public_html/gal.klintmx.dk/images/vejr'; // saving path $ch = curl_init($profile_image); $fp = fopen($path . $userimage, 'wb'); curl_setopt($ch, curlopt_file, $fp); curl_setopt($ch, curlopt_header, 0); $result = curl_exec($ch); curl_close($ch); fclose($fp); and cron job 0,30 * * * * /usr/bin/php /home/klintweb/publ...

Truth value of a string in python -

if <boolean> : # boolean has either true or false. then why if "poi": print "yes" output: yes i didn't why yes printing , since "poi" nether true or false. python best evaluate "truthiness" of expression when boolean value needed expression. the rule strings empty string considered false , non-empty string considered true . same rule imposed on other containers, empty dictionary or list considered false , dictionary or list 1 or more entries considered true . the none object considered false. a numerical value of 0 considered false (although string value of '0' considered true). all other expressions considered true . details (including how user-defined types can specify truthiness) can found here: http://docs.python.org/release/2.5.2/lib/truth.html .