Rに文字列値ラベル(職業グループ)を持つ変数がありますが、変数の実際の値は数値です。ヒストグラムにラベルを表示する(値)R
変数をヒストグラムとして表示すると、特定の数値に付けられたラベルが表示されます。現在、数値の値を棒に付けることしかできませんでした( "hist(occgroupsn、labels = ) ")TRUE Histogram with numbers
これは私が)汚いコードの(ごめん値ラベルを追加する方法です:
occgroups <- ordered(IscoGroups,
levels = c("01",
"02",
"03",
"11",
"12",
"13",
"14",
"21",
"22",
"23",
"24",
"25",
"26",
"31",
"32",
"33",
"34",
"35",
"41",
"42",
"43",
"44",
"51",
"52",
"53",
"54",
"61",
"62",
"63",
"71",
"72",
"73",
"74",
"75",
"81",
"82",
"83",
"91",
"92",
"93",
"94",
"95",
"96"),
labels = c("Commissioned armed forces officers"
, "Non-commissioned armed forces officers"
, "Armed forces occupations, other ranks"
, "Chief executives, senior officials and legislators"
, "Administrative and commercial managers"
, "Production and specialised services managers"
, "Hospitality, retail and other services managers"
, "Science and engineering professionals"
, "Health professionals"
, "Teaching professionals"
, "Business and administration professionals"
, "Information and communications technology professionals"
, "Legal, social and cultural professionals"
, "Science and engineering associate professionals"
, "Health associate professionals"
, "Business and administration associate professionals"
, "Legal, social, cultural and related associate professionals"
, "Information and communications technicians"
, "General and keyboard clerks"
, "Customer services clerks"
, "Numerical and material recording clerks"
, "Other clerical support workers"
, "Personal service workers"
, "Sales workers"
, "Personal care workers"
, "Protective services workers"
, "Market-oriented skilled agricultural workers"
, "Market-oriented skilled forestry, fishery and hunting workers"
, "Subsistence farmers, fishers, hunters and gatherers"
, "Building and related trades workers, excluding electricians"
, "Metal, machinery and related trades workers"
, "Handicraft and printing workers"
, "Electrical and electronic trades workers"
, "Food processing, wood working, garment and other craft and related trades workers"
, "Stationary plant and machine operators"
, "Assemblers"
, "Drivers and mobile plant operators"
, "Cleaners and helpers"
, "Agricultural, forestry and fishery labourers"
, "Labourers in mining, construction, manufacturing and transport"
, "Food preparation assistants"
, "Street and related sales and service workers"
, "Refuse workers and other elementary workers"))
occgroupsn <- as.numeric(occgroups)
hist(occgroupsn, labels = TRUE)
それらを表示させるには?それとも私は別のやり方でそれをするべきですか?
編集:ここでは、
SampleVar <- c(1, 1, 2, 2, 2, 2, 3, 3, 3, 4)
SampleVarLabeled <- ordered(SampleVar,
levels = c("1", "2", "3", "4"),
labels = c("Commissioned armed forces officers" ,
"Noncommissioned armed forces officers" ,
"Armed forces, other ranks" ,
"Chief executives"))
SampleVarLabeledn <- as.numeric(SampleVarLabeled)
hist(SampleVarLabeledn, labels = TRUE)
である:ここで、私は
table
を用いて周波数をカウントしていますか? http://stackoverflow.com/questions/19417760/histogram-of-factor-with-labels-on-frequency-bars – Jealieあなたのデータは再現性がありません。私たちはIscoGroupsにアクセスすることはできません。この質問には、より小さなサンプルデータセットを使用する必要があります。 –
@Yealieヒストグラムのラベル= TRUEを使用して、私が既に行っていることをポスターが望んでいることを祈っています。 –