Lattice Multivariate Data Visualization with R
x <- matrix(c(2,0,1,1, 0,0,2,0, 1,2,0,2), nrow = 4) rownames(x) <- c("W1","W2","W3", "W4") ## ターム名とする colnames(x) <- c("D1","D2","D3") ## 文書名とする x ## D1 D2 D3 ## W1 2 0 1 ## W2 0 0 2 ## W3 1 2 0 ## W4 1 0 2 ## 行名のタームに対して,列名のタームが出現した回数 ## 左右対称行列ではない y <- diag(rowSums(x)) colnames(y) <- rownames(y) <- rownames(x) for(i in 1:(nrow(x)-1)){ for(j in 4:2){ if(i == j) break y[i,j] <- sum(x[i, x[j,]> 0]) y[j,i] <- sum(x[i, x[j,]> 0]) } } y ## W1 W2 W3 W4 ## W1 3 1 2 3 ## W2 1 2 0 2 ## W3 2 0 3 1 ## W4 3 2 1 3 ## 行名のタームと列名のタームが共起した回数 ## 左右対称行列である y <- diag(nrow(x)) colnames(y) <- rownames(y) <- rownames(x) for(i in 1:(nrow(x)-1)){ for(j in 4:2){ if(i == j) break y[j,i] <- y[i,j] <- sum(x[i, x[j,]> 0] > 0 ) } } y ## W1 W2 W3 W4 ## W1 1 1 1 2 ## W2 1 1 0 1 ## W3 1 0 1 1 ## W4 2 1 1 1 ### 行名のタームと列名のタームが共起したか否か ## 左右対称行列である y[y > 0] <- 1 y ## W1 W2 W3 W4 ## W1 1 1 1 1 ## W2 1 1 0 1 ## W3 1 0 1 1 ## W4 1 1 1 1
NSString* request = [[NSString stringWithFormat:@"%@%@", Url, query] stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding];
NSXMLParserErrorDomain error 5.
と出る。この中身はここによれば
Code: NSXMLParserPrematureDocumentEndError The document ended unexpectedly. Available in Mac OS X v10.3 and later. Declared in NSXMLParser.h
ということなのだが。さらに検索するとこういう情報もあった。
The problem is that is an invalid xmll document. There is only one root elment allowed in the XML document. Most if not all parsers will fail on that. Try chaning you xml from:
だとすると NSXMLParserは使えないということになる.しかしクエリーの結果をファイルに保存して、これを読み込ませるとうまくいく。
Hehehe, fileURLWithPath? statt URLWithString?, dann geht's, hab das hier mal ausprobiert.
NSString * mystring; mystring = [[ NSString alloc] initWithString:@"iPod Touch" autorelease];
とする。以下でもいいらしい。
mystring = [NSString stringWithString:@"iPod Touch"];
が,引数が増えてくると,とたんに混乱してくる.