2017-12-19 12 views
-1

因子のレベル数に制限があるのでしょうか?RStudioのレベル数に制限はありますか?

私はXingからいくつかのカリキュラムを再構築しようとしています。選択可能な産業はおよそ135種類です。 私のコードは、私の実際のコードには135の異なる業界があると言われているように見えます。

companyIndustryLevels <- c("","ACADEMIA", "ACCOUNTING", "AEROSPACE") 
levels(samples[[1]]$Industry) <- companyIndustryLevels 

次の組み合わせは正常に機能し、リストをフィルタリングするときに選択できます。

genderLevels <- c("M","F") 
companySizeLevels <- c("","1","1-10","11-50","51-200","201-500","501-1000","1001-5000","5001-10000","10001+") 
levels(samples[[1]]$Gender) <- genderLevels 
levels(samples[[1]]$CompanySize) <- companySizeLevels 

だから、問題はリストを表示する際、業界の列が1つのだけのレベルではなく、135のレベルの要因を示していること、です。

EDIT: 私はRStudioバージョン11.1.383及びRバージョン3.4.3を使用しています。 下の再現可能な例でわかるように、「性別」、「Beschäftigungsart」、「位置」、「Unternehmensgroesse」などの他の列にもレベルがあります。 私は「インダストリー」の列を除いて、そのレベルですべての列をフィルタリングすることができる午前RStudioでビューウィンドウでフィルターを選択します。

View(structure(
    list(
    ID = 1, 
    Gender = structure(1L, .Label = c("M", 
             "F"), class = "factor"), 
    Bildungseinrichtungen = structure(1L, .Label = "", class = "factor"), 
    Abschluss = structure(1L, .Label = "", class = "factor"), 
    Studienfach = structure(1L, .Label = "", class = "factor"), 
    Beschäftigungsart = structure(
     1L, 
     .Label = c(
     "", 
     "FULL_TIME_EMPLOYEE", 
     "PART_TIME_EMPLOYEE", 
     "INTERN", 
     "FREELANCER", 
     "OWNER", 
     "PARTNER", 
     "BOARD_MEMBER", 
     "VOLUNTEER" 
    ), 
     class = "factor" 
    ), 
    Station.Start = NA, 
    Station.Ende = NA, 
    Bezeichnung = NA, 
    Position = structure(
     1L, 
     .Label = c(
     "", 
     "STUDENT_INTERN", 
     "ENTRY_LEVEL", 
     "PROFESSIONAL_EXPERIENCED", 
     "MANAGER_SUPERVISOR", 
     "EXECUTIVE", 
     "SENIOR_EXECUTIVE" 
    ), 
     class = "factor" 
    ), 
    Unternehmen = structure(1L, .Label = "AMA", class = "factor"), 
    Unternehmensgroesse = structure(
     1L, 
     .Label = c(
     "", 
     "1", 
     "1-10", 
     "11-50", 
     "51-200", 
     "201-500", 
     "501-1000", 
     "1001-5000", 
     "5001-10000", 
     "10001+" 
    ), 
     class = "factor" 
    ), 
    Industrie = structure(
     1L, 
     .Label = c(
     "ACADEMIA", 
     "ACCOUNTING", 
     "AEROSPACE", 
     "AGRICULTURE", 
     "AIRLINES", 
     "ALTERNATIVE_MEDICINE", 
     "APPAREL_AND_FASHION", 
     "ARCHITECTURE_AND_PLANNING", 
     "ARTS_AND_CRAFTS", 
     "AUTOMOTIVE", 
     "BANKING", 
     "BIOTECHNOLOGY", 
     "BROADCAST_MEDIA", 
     "BUILDING_MATERIALS", 
     "BUSINESS_SUPPLIES_AND_EQUIPMENT", 
     "CHEMICALS", 
     "CIVIC_AND_SOCIAL_ORGANIZATIONS", 
     "CIVIL_ENGINEERING", 
     "CIVIL_SERVICE", 
     "COMPOSITES", 
     "COMPUTER_AND_NETWORK_SECURITY", 
     "COMPUTER_GAMES", 
     "COMPUTER_HARDWARE", 
     "COMPUTER_NETWORKING", 
     "COMPUTER_SOFTWARE", 
     "CONSTRUCTION", 
     "CONSULTING", 
     "CONSUMER_ELECTRONICS", 
     "CONSUMER_GOODS", 
     "CONSUMER_SERVICES", 
     "COSMETICS", 
     "DAYCARE", 
     "DEFENSE_MILITARY", 
     "DESIGN", 
     "EDUCATION", 
     "ELEARNING", 
     "ELECTRICAL_ENGINEERING", 
     "ENERGY", 
     "ENTERTAINMENT", 
     "ENVIRONMENTAL_SERVICES", 
     "EVENTS_SERVICES", 
     "FACILITIES_SERVICES", 
     "FACILITY_MANAGEMENT", 
     "FINANCIAL_SERVICES", 
     "FISHERY", 
     "FOOD", 
     "FUNDRAISING", 
     "FURNITURE", 
     "GARDENING_LANDSCAPING", 
     "GEOLOGY", 
     "GLASS_AND_CERAMICS", 
     "GRAPHIC_DESIGN", 
     "HEALTH_AND_FITNESS", 
     "HOSPITALITY", 
     "HUMAN_RESOURCES", 
     "IMPORT_AND_EXPORT", 
     "INDUSTRIAL_AUTOMATION", 
     "INFORMATION_SERVICES", 
     "INFORMATION_TECHNOLOGY_AND_SERVICES", 
     "INSURANCE", 
     "INTERNATIONAL_AFFAIRS", 
     "INTERNATIONAL_TRADE_AND_DEVELOPMENT", 
     "INTERNET", 
     "INVESTMENT_BANKING", 
     "JOURNALISM", 
     "LEGAL_SERVICES", 
     "LEISURE_TRAVEL_AND_TOURISM", 
     "LIBRARIES", 
     "LOGISTICS_AND_SUPPLY_CHAIN", 
     "LUXURY_GOODS_AND_JEWELRY", 
     "MACHINERY", 
     "MANAGEMENT_CONSULTING", 
     "MARITIME", 
     "MARKETING_AND_ADVERTISING", 
     "MARKET_RESEARCH", 
     "MECHANICAL_INDUSTRIAL_ENGINEERING", 
     "MEDIA_PRODUCTION", 
     "MEDICAL_DEVICES", 
     "MEDICAL_SERVICES", 
     "MEDICINAL_PRODUCTS", 
     "METAL_METALWORKING", 
     "METROLOGY_CONTROL_ENGINEERING", 
     "MINING_AND_METALS", 
     "MOTION_PICTURES", 
     "MUSEUMS_AND_CULTURAL_INSTITUTIONS", 
     "MUSIC", 
     "NANOTECHNOLOGY", 
     "NON_PROFIT_ORGANIZATION", 
     "NURSING_AND_PERSONAL_CARE", 
     "OIL_AND_ENERGY", 
     "ONLINE_MEDIA", 
     "OTHERS", 
     "OUTSOURCING_OFFSHORING", 
     "PACKAGING_AND_CONTAINERS", 
     "PAPER_AND_FOREST_PRODUCTS", 
     "PHOTOGRAPHY", 
     "PLASTICS", 
     "POLITICS", 
     "PRINTING", 
     "PRINT_MEDIA", 
     "PROCESS_MANAGEMENT", 
     "PROFESSIONAL_TRAINING_AND_COACHING", 
     "PSYCHOLOGY_PSYCHOTHERAPY", 
     "PUBLIC_HEALTH", 
     "PUBLIC_RELATIONS_AND_COMMUNICATIONS", 
     "PUBLISHING", 
     "RAILROAD", 
     "REAL_ESTATE", 
     "RECREATIONAL_FACILITIES_AND_SERVICES", 
     "RECYCLING_AND_WASTE_MANAGEMENT", 
     "RENEWABLES_AND_ENVIRONMENT", 
     "RESEARCH", 
     "RESTAURANTS_AND_FOOD_SERVICE", 
     "RETAIL", 
     "SECURITY_AND_INVESTIGATIONS", 
     "SEMICONDUCTORS", 
     "SHIPBUILDING", 
     "SPORTS", 
     "STAFFING_AND_RECRUITING", 
     "TAX_ACCOUNTANCY_AUDITING", 
     "TELECOMMUNICATION", 
     "TEXTILES", 
     "THEATER_STAGE_CINEMA", 
     "TIMBER", 
     "TRAFFIC_ENGINEERING", 
     "TRANSLATION_AND_LOCALIZATION", 
     "TRANSPORT", 
     "VENTURE_CAPITAL_AND_PRIVATE_EQUITY", 
     "VETERINARY", 
     "WELFARE_AND_COMMUNITY_HEALTH", 
     "WHOLESALE", 
     "WINE_AND_SPIRITS", 
     "WRITING_AND_EDITING", 
     "PHARMACEUTICALS" 
    ), 
     class = "factor" 
    ) 
), 
    .Names = c(
    "ID", 
    "Gender", 
    "Bildungseinrichtungen", 
    "Abschluss", 
    "Studienfach", 
    "Beschäftigungsart", 
    "Station.Start", 
    "Station.Ende", 
    "Bezeichnung", 
    "Position", 
    "Unternehmen", 
    "Unternehmensgroesse", 
    "Industrie" 
), 
    row.names = 1L, 
    class = "data.frame" 
)) 
+2

コードの問題点は何ですか? – lukeA

+0

135のレベル – atix

+1

は(http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible- [再現性]を提供し、工業用カラムは1つのレベルの係数であるリストを表示しません例: 'dput(head(samples))'または 'str(samples)' – zx8754

答えて

2

レベル(nlevels())のその数未満65ときRStudioのデータビューア(View())でフィルタリングオプションは、factorのためのドロップダウンメニューを提供していますかのように思えます。それ以外の場合は、デフォルトで検索フィールドになります。

df <- data.frame(x=as.factor(1:64)) 
View(df) 
# "filter" yields a drop down menu 

df <- data.frame(x=as.factor(1:65)) 
View(df) 
# "filter" yields a search field 

RStudio.Version()$version 
# [1] ‘1.0.143’ 

これは、コメントで既に述べたように、R自体とは関係ありません。

+0

ありがとう!次に、検索フィールドに行くか、64以上のレベルのドロップダウンメニューを表示する方法がありますか? – atix

+0

@atix RStudioのデータビューアでこれが可能なら、私は気にしません。しかし、あなたのデータセットがそれほど大きくなければ、 'DT :: datatable(df、filter =" top ")'を代わりに使うことができますか? – lukeA

関連する問題