Permalink
Browse files

sorting files

  • Loading branch information...
1 parent ddb591f commit 22f119b57b26793f88a0ef9f530cd98498fe96aa Jenn committed Aug 6, 2013
@@ -0,0 +1,115 @@
+require(graphics)
+x <- rbind(matrix(rnorm(100, sd = 0.3), ncol = 2),
+ matrix(rnorm(100, mean = 1, sd = 0.3), ncol = 2))
+x
+colnames(x) <- c("x", "y")
+x
+(cl <- kmeans(x, 2))
+(cl <- kmeans(x, 3))
+plot(x, col = cl$cluster)
+points(cl$centers, col = 1:2, pch = 8, cex=2)
+fitted.x <- fitted(cl); head(fitted.x)
+resid.x <- x - fitted(cl)
+cbind(cl[c("betweenss", "tot.withinss", "totss")], # the same two columns
+ c(ss(fitted.x), ss(resid.x), ss(x)))
+ss <- function(x) sum(scale(x, scale = FALSE)^2)
+plot(x, col = cl$cluster)
+points(cl$centers, col = 1:2, pch = 8, cex=2)
+fitted.x <- fitted(cl); head(fitted.x)
+resid.x <- x - fitted(cl)
+cbind(cl[c("betweenss", "tot.withinss", "totss")], # the same two columns
+ c(ss(fitted.x), ss(resid.x), ss(x)))
+stopifnot(all.equal(cl$ totss, ss(x)),
+ all.equal(cl$ tot.withinss, ss(resid.x)),
+ ## these three are the same:
+ all.equal(cl$ betweenss, ss(fitted.x)),
+ all.equal(cl$ betweenss, cl$totss - cl$tot.withinss),
+ ## and hence also
+ all.equal(ss(x), ss(fitted.x) + ss(resid.x))
+ )
+(cl <- kmeans(x, 5, nstart = 25))
+plot(x, col = cl$cluster)
+points(cl$centers, col = 1:5, pch = 8)
+setwd('C:/somethingnull/git/tools/hyades/')
+simbadO = read.table('simbad.csv', header=T, sep=';')
+hipparcosO = read.table('HIPPARCOS.csv', header=T, sep=';')
+#cut columns
+a = matrix(c(RA_J2000 = simbadO$RA_J2000, DE_J2000=simbadO$DE_J2000))
+b = matrix(c(RA_J2000=hipparcosO$RA_J2000, DE_J2000=hipparcosO$DE_J2000))
+rownames(a) <- simbadO$identifier
+rownames(b) <- hipparcosO$HIP
+# C�lculo de las distancias m�nimas
+min.dist <- array()
+min.dist.name <- array()
+a = matrix(c(RA_J2000 = simbadO$RA_J2000, DE_J2000=simbadO$DE_J2000))
+nrow(simbadO$identifier)
+length(simbadO$identifier)
+rownames(a) <-c(simbadO$identifier)
+dimnames()
+dimnames(a)
+a = matrix(c(RA_J2000 = simbadO$RA_J2000, DE_J2000=simbadO$DE_J2000), nrow=nrow(simbadO), byrow=T)
+head(a)
+rownames(a) <-c(simbadO$identifier)
+b = matrix(c(RA_J2000=hipparcosO$RA_J2000, DE_J2000=hipparcosO$DE_J2000), nrow=nrow(hipparcosO), byrow=T)
+head(b)
+rownames(b) <- hipparcosO$HIP
+head(a)
+head(b)
+# C�lculo de las distancias m�nimas
+min.dist <- array()
+min.dist.name <- array()
+for (i in 1:nrow(a)){
+ for (j in 1:nrow(b)) {
+ dists.ab[j] <- rbind(rbind(a[i,],b[j,])) #almaceno las distancias
+ }
+min.dist.name[i] <- which.min(dists.ab)
+min.dist[i] <- min(dists.ab)
+}
+min.dist <- array()
+min.dist.name <- array()
+dists.ab <- array()
+for (i in 1:nrow(a)){
+ for (j in 1:nrow(b)) {
+ dists.ab[j] <- rbind(rbind(a[i,],b[j,])) #almaceno las distancias
+ }
+min.dist.name[i] <- which.min(dists.ab)
+min.dist[i] <- min(dists.ab)
+}
+warnings()
+for (i in 1:nrow(a)){
+ for (j in 1:nrow(b)) {
+ dists.ab[j] <- dist(rbind(a[i,],b[j,])) #almaceno las distancias
+ }
+min.dist.name[i] <- which.min(dists.ab)
+min.dist[i] <- min(dists.ab)
+}
+nrow(dists.ab)
+length(dists.ab)
+length(min.dist)
+head(min.dist)
+#getting the limit
+cruzados = read.table('id_cruzados.csv', header=T, sep=',')
+mcruzados = as.matrix(cruzados)
+for (i in 1:nrow(mcruzados)) {
+ #create a mini matrix with one row.
+ mnewmini = rbind(mcruzados[i,3:4], mcruzados[i,5:6])
+ #matriz distance
+ disti = dist(mnewmini)
+ ##adding distance to dataframe.
+ #format sci
+ cruzados$distancia[i] = format(disti , sci = FALSE)
+ #printdataframe
+ cruzados$distancia[i]
+}
+maxjoindist = max(cruzados$distancia)
+head(min.dist)
+(min.dist
+)
+names(x=min.dist)
+names(min.dist)
+head(min.dist)
+is(min.dist)
+is(min.dist.name)
+head(min.dist.name)
+sink(file='Scriptnuevo.txt')
+save.image('scriptnuevo2.txt')
@@ -0,0 +1,23 @@
+ #!/usr/bin/perl -w
+use strict;
+use common::sense;
+use Data::Dumper;
+
+open (FILE, '<' , 'uniqflisol2011_2012.txt' );
+open (FILEOUT, '>' , 'screennameMention2011_2012.txt' );
+
+my @screen_names;
+
+
+while (<FILE>) {
+ my $line = $_;
+ my @words = split(' ', $line);
+ foreach my $word (@words) {
+ if ($word=~/@(_?\w*_?)/g) {
+ push(@screen_names, $word);
+ print FILEOUT $word."\n";
+ }
+ }
+}
+close(FILE);
+close(FILEOUT);
@@ -0,0 +1,22 @@
+#!/usr/bin/perl -w
+use strict;
+use common::sense;
+
+open(FILE, '<', 'onlyText.txt');
+open(FILEOUT, '>', 'uniq_item_flisol2013.txt');
+
+while(<FILE>) {
+ my @wordsline;
+ my %words_unique_line;
+ my @words;
+
+ @wordsline = split(' ', $_);
+ foreach my $word (@wordsline) {
+ $words_unique_line{$word} = 1;
+ }
+ foreach my $key (keys(%words_unique_line)) {
+ push(@words, $key);
+ }
+ print FILEOUT join(';', @words)."\n";
+}
+
@@ -0,0 +1,27 @@
+# -*- coding: utf-8 -*-
+import tweepy
+import sys
+import os
+import time
+
+s = ', '.encode('utf-8')
+file = open('tweetabout.csv','w')
+file.write('source; screen_name; text; retweet_count; follower_count');
+
+#while True:
+# x = tweepy.api.search('somethingToSearch')
+# for y in x:
+# line = str(y.created_at) + s +str(y.from_user) + s + str(y.from_user_id) + s + y.from_user_name + s + y.id_str + s + y.profile_image_url + s + y.profile_image_url_https + s + y.source + s+ y.text + "\n"
+# file.write(line.encode('utf-8'))
+# print line.encode('utf-8')
+# time.sleep(360)
+
+file = open("idsflisol2012.txt");
+
+for line in file:
+ line.rstrip("\n");
+ tweet = tweepy.status(line);
+ time.sleep(5);
+
+
+

0 comments on commit 22f119b

Please sign in to comment.