2011-09-10 2 views
13

格子プロットのストリップに表示されるテキストを変更するにはどうすればよいですか? 例:私はテキスト「A」と「B」とのプロットを与える格子プロット格子プロットのストリップのテキストを変更する

xyplot(a~x | y,data=test) 

に3列

x 
[1] 1 2 3 4 5 6 7 8 9 10 

y 
[1] "A" "A" "A" "A" "A" "B" "B" "B" "B" "B" 

a 
[1] -1.9952066 -1.7292978 -0.8789127 -0.1322849 -0.1046782 0.4872866 
[7] 0.5199228 0.5626998 0.6392686 1.6604549 

通常呼からなるデータフレームのテストがあると ストリップ上に別のテキストを書くにはどうしたらよいですか?

strip.custom()

xyplot(a~x | y,data=test,strip=strip.custom(var.name=z)) 

別の文字ベクトル

z 
[1] "a" "a" "a" "a" "a" "b" "b" "b" "b" "b" 

とatteptとコールは、所望の結果を与えるものではありません。

実際には国際化の問題です。

答えて

8

あなたの文字ベクトル係数その後、あなただけ変更できるレベルにする場合:

> xyplot(a~x | y,data=test)  # your plot 
> test$y=as.factor(test$y)  # convert y to factor 
> xyplot(a~x | y,data=test)  # should be identical 
> levels(test$y)=c("Argh","Boo") # change the level labels 
> xyplot(a~x | y,data=test)  # new panel labels! 
14

私はあなたがすることによって得ることができる何をしたいと思います:

z <-c("a" , "b") # Same number of values as there are panels 
xyplot(a~x | y,data=test,strip=strip.custom(factor.levels=z)) 
+1

あなたは必要ありません " z '変数:factor.levels = c( "a"、 "b")がそれを行います。 – Spacedman

+1

私は、データポイントの数ではなく、パネルと同じ数のレベルを持つ必要があることを強調しようとしていました –

関連する問題