我的数据框Hosp_coord
包含173家医院及其位置,在映射之前,我们只想保留那些以“#34; Trust"在他们的名字中(变量" Hosp
")
HC <- read.csv("DrivetimesforR_Hosp_clean.csv",header=TRUE, stringsAsFactors=FALSE)
Hosp_coord <- data.frame(HC)
dput(Hosp_coord)
structure(list(Hosp_code = c("RRK", "RLU", "5MX", "NO0", "NLU",
"NXX", "AGL", "5M1", "NQR", "RXT", "RRJ", "RXK", "RQ3", "RYW",
"5PG", "NIT", "RR1", "NIS", "NDT", "5PF", "TAJ", "NEP", "NL7",
"NNT", "5QW", "NR9", "RYK", "5PE", "AD9", "RYA", "RNA", "NQ0",
"RBK", "AJ0", "NVY", "NCW", "5M3", "NY1", "RL4", "NL6", "5MV",
"AHK", "NW9", "AG8", "NP6", "ADD", "AJ4", "AEY", "5MD", "NIB",
"RJC", "5PM", "RYG", "ADV", "NT1", "RLT", "NT9", "5PK", "RWP",
"RKB", "5PL", "NP2", "R1A", "NKA", "5MK", "NIE", "AJT", "RJD",
"NRX", "RRE", "AH8", "NXJ", "AEF", "RJF", "AJQ", "NPF", "NKL",
"NXD", "NY5", "5PA", "AJL", "NLI", "NBB", "NES", "8J2", "AEJ",
"AJP", "NYL", "5PC", "RTG", "RXM", "RLY", "NX7", "NGJ", "NLS",
"NHG", "AH9", "AHH", "RWE", "5N7", "NI0", "RT5", "NNJ", "AHP",
"NDW", "NNQ", "AFY", "RTE", "5PJ", "AC7", "RJE", "R1D", "5M2",
"RXW", "R1E", "NX3", "AAN", "NCA", "RLQ", "NE0", "NNO", "NGX",
"5QH", "RTQ", "NLR", "R1J", "NHE", "NGG", "NPA", "NMF", "5CN",
"AAM", "5PH", "NRG", "AAA", "NFE", "NRW", "RX1", "NFK", "NQE",
"NLV", "AGQ", "5PD", "NFA", "NYN", "NJW", "NFR", "NGN", "RX9",
"RNS", "NFJ", "NL0", "ADN", "NYA", "ACW", "AE5", "5EM", "NGQ",
"AA8", "NR3", "NYV", "ADA", "RHA", "NNP", "RNQ", "AAG", "RYE",
"ACY", "RP1", "AH7", "AGK", "NTM", "NFM"), Hosp = c("RRK - UNIVERSITY HOSPITALS BIRMINGHAM NHS FOUNDATION TRUST",
"RLU - BIRMINGHAM WOMEN'S NHS FOUNDATION TRUST", "5MX - HEART OF BIRMINGHAM TEACHING PCT",
"NO0 - HEALTHHARMONIE LIMITED", "NLU - SK:N (LASERCARE CLINICS LTD)",
"NXX - SCRIVENS LTD", "AGL - ADDITIONAL COMMUNITY MEDICAL SERVICES LTD",
"5M1 - SOUTH BIRMINGHAM PCT", "NQR - PRIMECARE PRIMARY CARE",
"RXT - BIRMINGHAM AND SOLIHULL MENTAL HEALTH NHS FOUNDATION TRUST",
"RRJ - THE ROYAL ORTHOPAEDIC HOSPITAL NHS FOUNDATION TRUST",
"RXK - SANDWELL AND WEST BIRMINGHAM HOSPITALS NHS TRUST", "RQ3 - BIRMINGHAM CHILDREN'S HOSPITAL NHS FOUNDATION TRUST",
"RYW - BIRMINGHAM COMMUNITY HEALTHCARE NHS TRUST", "5PG - BIRMINGHAM EAST AND NORTH PCT",
"NIT - SOUTH DOC SERVICES LIMITED HQ", "RR1 - HEART OF ENGLAND NHS FOUNDATION TRUST",
"NIS - COVENTRY AND WARWICKSHIRE DIAGNOSTIC SERVICES LIMITED",
"NDT - WEST MIDLANDS DIAGNOSTIC SERVICES LTD", "5PF - SANDWELL PCT",
"TAJ - BLACK COUNTRY PARTNERSHIP NHS FOUNDATION TRUST", "NEP - TICCS ULTRASOUND LIMITED",
"NL7 - ASSURA VERTIS URGENT CARE CENTRES (BIRMINGHAM)", "NNT - ASSURA KINGSTANDING",
"5QW - SOLIHULL PCT", "NR9 - JOHN TAYLOR HOSPICE COMMUNITY INTEREST COMPANY",
"RYK - DUDLEY AND WALSALL MENTAL HEALTH PARTNERSHIP NHS TRUST",
"5PE - DUDLEY PCT", "AD9 - GREENBROOK HEALTHCARE", "RYA - WEST MIDLANDS AMBULANCE SERVICE NHS FOUNDATION TRUST",
"RNA - THE DUDLEY GROUP NHS FOUNDATION TRUST", "NQ0 - BROMSGROVE HEALTHCARE INNOVATIONS LTD",
"RBK - WALSALL HEALTHCARE NHS TRUST", "AJ0 - COMPLETE SURVEYING SOLUTIONS LTD",
"NVY - ASSURA WYRE FOREST LLP", "NCW - SUTTON MEDICAL CONSULTING CENTRE",
"5M3 - WALSALL TEACHING PCT", "NY1 - AIR LIQUIDE LIMITED", "RL4 - THE ROYAL WOLVERHAMPTON NHS TRUST",
"NL6 - FRATERDRIVE LTD", "5MV - WOLVERHAMPTON CITY PCT", "AHK - HUMANITAS HEALTHCARE SERVICES LIMITED",
"NW9 - CLINICENTA LIMITED", "AG8 - PHYSIO & HEALTH MATTERS LTD",
"NP6 - WHITMORE REANS HEALTH SERVICES LTD", "ADD - VOYAGE CARE",
"AJ4 - SOUTH WORCESTERSHIRE PRIMARY CARE LIMITED", "AEY - STARFISH HEALTH AND WELLBEING HQ",
"5MD - COVENTRY TEACHING PCT", "NIB - BREWOOD MEDICAL SERVICES LTD",
"RJC - SOUTH WARWICKSHIRE NHS FOUNDATION TRUST", "5PM - WARWICKSHIRE PCT",
"RYG - COVENTRY AND WARWICKSHIRE PARTNERSHIP NHS TRUST", "ADV - BROMSGROVE PHYSIOTHERAPY LTD",
"NT1 - BRITISH PREGNANCY ADVISORY SERVICE (BPAS) HEAD OFFICE",
"RLT - GEORGE ELIOT HOSPITAL NHS TRUST", "NT9 - ALLIANCE MEDICAL",
"5PK - SOUTH STAFFORDSHIRE PCT", "RWP - WORCESTERSHIRE ACUTE HOSPITALS NHS TRUST",
"RKB - UNIVERSITY HOSPITALS COVENTRY AND WARWICKSHIRE NHS TRUST",
"5PL - WORCESTERSHIRE PCT", "NP2 - MEDICAL IMAGING UK LTD", "R1A - WORCESTERSHIRE HEALTH AND CARE NHS TRUST",
"NKA - SHUROPODY FOOTCARE LTD", "5MK - TELFORD AND WREKIN PCT",
"NIE - WARD ANNE KATHLEEN DR (DERMATOLOGY)", "AJT - NORTH WEST LEICESTERSHIRE GP LIMITED",
"RJD - MID STAFFORDSHIRE NHS FOUNDATION TRUST", "NRX - MIDLANDS PSYCHOLOGY CIC",
"RRE - SOUTH STAFFORDSHIRE AND SHROPSHIRE HEALTHCARE NHS FOUNDATION TRUST",
"AH8 - ADVANTAGE HEALTHCARE", "NXJ - HEALTHCARE AT HOME", "AEF - MIDLANDS EYE CARE LIMITED",
"RJF - BURTON HOSPITALS NHS FOUNDATION TRUST", "AJQ - HINCKLEY & BOSWORTH MEDICAL ALLIANCE LIMITED",
"NPF - THE INDUSTRIAL DIAGNOSTICS COMPANY [HQ]", "NKL - SHEPHERD CHIROPODY",
"NXD - ASSURA WEST LEICESTERSHIRE LLP", "NY5 - ASSURA COVENTRY LLP",
"5PA - LEICESTERSHIRE COUNTY AND RUTLAND PCT", "AJL - PRIMARY CARE WARWICKSHIRE LTD",
"NLI - CASP PSYCHOLOGY SERVICES", "NBB - THE HELPING HAND COMPANY",
"NES - LIGHTHOUSE HEALTHCARE LIMITED", "8J2 - SHAW HEALTHCARE (LEDBURY) LTD",
"AEJ - LLR NHS PARTNER ALLIANCE", "AJP - OPTYCO LTD", "NYL - ONE TO ONE PHYSIOTHERAPY & REHABILITATION CENTRE",
"5PC - LEICESTER CITY PCT", "RTG - DERBY TEACHING HOSPITALS NHS FOUNDATION TRUST",
"RXM - DERBYSHIRE HEALTHCARE NHS FOUNDATION TRUST", "RLY - NORTH STAFFORDSHIRE COMBINED HEALTHCARE NHS TRUST",
"NX7 - VEINCENTRE LIMITED", "NGJ - LOUGHBOROUGH PHYSIOTHERAPY AND SPORTS INJURIES CLINIC LTD",
"NLS - TRENT PTS", "NHG - VANSCAN LTD HQ", "AH9 - CLINICAL DIAGNOSTIX LTD",
"AHH - FOSCOTE COURT (BANBURY) TRUST LTD", "RWE - UNIVERSITY HOSPITALS OF LEICESTER NHS TRUST",
"5N7 - DERBY CITY PCT", "NI0 - LEICESTER, LEICESTERSHIRE & RUTLAND PROVIDER COMPANY",
"RT5 - LEICESTERSHIRE PARTNERSHIP NHS TRUST", "NNJ - DERBYSHIRE HEALTH UNITED LTD",
"AHP - ST MICHAEL'S CLINIC LIMITED", "NDW - RIPPLEZ CIC", "NNQ - ARKANUM",
"AFY - ICALL CARE LTD", "RTE - GLOUCESTERSHIRE HOSPITALS NHS FOUNDATION TRUST",
"5PJ - STOKE ON TRENT PCT", "AC7 - COBALT HEALTH", "RJE - UNIVERSITY HOSPITALS OF NORTH MIDLANDS NHS TRUST",
"R1D - SHROPSHIRE COMMUNITY HEALTH NHS TRUST", "5M2 - SHROPSHIRE COUNTY PCT",
"RXW - SHREWSBURY AND TELFORD HOSPITAL NHS TRUST", "R1E - STAFFORDSHIRE AND STOKE ON TRENT PARTNERSHIP NHS TRUST",
"NX3 - BASFORD CONSULTING LIMITED", "AAN - ALEXIN HEALTHCARE LTD",
"NCA - MK GP PHYSIOTHERAPY (B.J. WETHERELL LTD)", "RLQ - WYE VALLEY NHS TRUST",
"NE0 - HEREFORD OSTEOPATHIC PRACTICE LTD", "NNO - GLOUCESTERSHIRE GP PROVIDER COMPANY LTD",
"NGX - TAURUS HEALTHCARE LTD", "5QH - GLOUCESTERSHIRE PCT", "RTQ - 2GETHER NHS FOUNDATION TRUST",
"NLR - GLOUCESTERSHIRE CARE SERVICES CIC", "R1J - GLOUCESTERSHIRE CARE SERVICES NHS TRUST",
"NHE - VANGUARD GROUP LTD", "NGG - 188 HQ", "NPA - CAMBIAN ANSEL CLINIC",
"NMF - BRACKLEY HOSPITAL", "5CN - HEREFORDSHIRE PCT", "AAM - PERSONALISED 4 AUTISM",
"5PH - NORTH STAFFORDSHIRE PCT", "NRG - BABY WAYS COMMUNITY INTEREST COMPANY",
"AAA - BOOTS UK LIMITED", "NFE - CARE ASSURE NORTHAMPTON LTD",
"NRW - CHANGING MINDS PARTNERSHIPS", "RX1 - NOTTINGHAM UNIVERSITY HOSPITALS NHS TRUST",
"NFK - MAPLYN CARE SERVICES (MCS)", "NQE - NENE COMMISSIONING COMMUNITY INTEREST COMPANY",
"NLV - NEMS HEALTHCARE", "AGQ - NEMS COMMUNITY BENEFIT SERVICES LTD",
"5PD - NORTHAMPTONSHIRE TEACHING PCT", "NFA - NABIDA CARE MANAGEMENT",
"NYN - SPECSAVERS HEARCARE GROUP LTD", "NJW - NORTHANTS ACCOMMODATION SOCIAL CARE",
"NFR - STEPPING STONE CARE HOMES", "NGN - WELLINGTON SUPPORT LTD",
"RX9 - EAST MIDLANDS AMBULANCE SERVICE NHS TRUST", "RNS - NORTHAMPTON GENERAL HOSPITAL NHS TRUST",
"NFJ - ST MATTHEWS HEALTHCARE", "NL0 - JOHN MUNROE HOSPITAL",
"ADN - PRIMARY INTEGRATED COMMUNITY SERVICES LTD", "NYA - ST ANDREW'S HEALTHCARE",
"ACW - ADVANCE PHYSIOTHERAPY", "AE5 - RESPONSE PHYSIOTHERAPY LTD HQ",
"5EM - NOTTINGHAM CITY PCT", "NGQ - THE PINNACLE PRACTICE", "AA8 - SMART CJS",
"NR3 - NOTTINGHAM CITYCARE PARTNERSHIP", "NYV - AIR PRODUCTS HEALTHCARE",
"ADA - BAYWATER HEALTHCARE LTD", "RHA - NOTTINGHAMSHIRE HEALTHCARE NHS FOUNDATION TRUST",
"NNP - HERITAGE HEARING", "RNQ - KETTERING GENERAL HOSPITAL NHS FOUNDATION TRUST",
"AAG - SOLICITUDE LTD", "RYE - SOUTH CENTRAL AMBULANCE SERVICE NHS FOUNDATION TRUST",
"ACY - NORTHAMPTONSHIRE FORENSIC MEDICAL SERVICES", "RP1 - NORTHAMPTONSHIRE HEALTHCARE NHS FOUNDATION TRUST",
"AH7 - LAKESIDE + LTD", "AGK - INDEPENDENT COMMUNITY CARE MANAGEMENT LTD",
"NTM - FRESENIUS MEDICAL CARE (UK) LTD", "NFM - GREAT GLENS FACILITY LTD"
), Hosplat = c(52.4532708, 52.45318395, 52.47157468, 52.47096507,
52.47083776, 52.47148, 52.47734319, 52.4459217, 52.48411271,
52.48411271, 52.42113309, 52.48982016, 52.48517338, 52.48732296,
52.49136865, 52.40179585, 52.47787596, 52.46250361, 52.46250361,
52.52332846, 52.51925453, 52.51001729, 52.5420906, 52.5420906,
52.39169464, 52.52734149, 52.5083120004317, 52.5092294644311,
52.46517494, 52.4858072933998, 52.5023051816703, 52.348566, 52.582185023118,
52.3920756, 52.33060443, 52.5772813, 52.5978982380199, 52.51584626,
52.5977252558695, 52.585563335121, 52.5845433898226, 52.5868748903748,
52.5869546665942, 52.3854478804695, 52.5957184432615, 52.6526397957022,
52.2669297750123, 52.6875941392097, 52.4059427752099, 52.6759127843655,
52.2899489852885, 52.2811024679095, 52.4571190230277, 52.2659935115968,
52.200259811068, 52.5119982312026, 52.2740959464635, 52.7495229452825,
52.1912009117257, 52.4214225137538, 52.1871031902653, 52.1856252409082,
52.1950674688854, 52.3801561967713, 52.6400871974839, 52.794937979326,
52.7047969830976, 52.8113171412312, 52.8105111453519, 52.8105880727578,
52.6856214591177, 52.802596593851, 52.8006289288246, 52.8171781213604,
52.6346379304771, 52.649111573018, 52.7029233332887, 52.6051743217721,
52.6051743217721, 52.5945973085097, 52.6013016035563, 52.9109199391518,
52.0506812532277, 52.8617091884672, 52.0361578508759, 52.6278153900129,
52.6372475889056, 52.2487440327206, 52.6315527230181, 52.9103438169505,
52.9167241015446, 52.9683723556782, 52.9257360606287, 52.7660504153809,
52.9248137524315, 52.9243111502303, 52.9243111502303, 52.0533357535822,
52.6306099272782, 52.9243589256468, 52.6723547837429, 52.6765025782059,
52.9145920026474, 52.7173452050548, 52.9310855448385, 51.8976413881021,
52.6440171953512, 51.8908521142672, 53.0023319169627, 51.888478954327,
53.0067521468483, 52.7074097296907, 52.7074097296907, 52.7093558298627,
53.0101534816072, 53.0165755544101, 52.989080303422, 52.2075853616114,
52.0569407344173, 52.0569401032789, 51.8624774068583, 52.0553011333712,
51.8484680439189, 51.8604180637703, 51.8470629263512, 51.8470629263512,
51.8461803104114, 52.2511773333088, 52.9074525788226, 52.0309193778848,
52.0390588744387, 52.2525188305398, 53.1075321343173, 52.282799001457,
52.9271370464762, 52.1943470615538, 52.2719902251023, 52.9434377142608,
52.2770129652745, 52.2775563536626, 52.9476206753401, 52.9476206753401,
52.2767922300425, 52.2425498248103, 52.9416089588885, 52.2463232160797,
52.2463232160797, 52.2450827884219, 52.9814592933024, 52.2371311931188,
52.2510387908205, 53.1248349196001, 53.0169173497282, 52.2381408617474,
52.935318201845, 52.9346568254409, 52.9517420681384, 52.9534898914217,
51.8945096750874, 52.9742504621175, 53.0911316149475, 53.0911316149475,
52.9795676868099, 53.0920564258137, 52.4027816654381, 52.3880588016267,
51.8918931513795, 52.3972916306225, 52.3940986750739, 52.4902298465789,
52.3749639546144, 53.1223859078782, 52.3009686287607), Hosplon = c(-1.936283476,
-1.942243239, -1.936772401, -1.924319231, -1.92208185, -1.91341,
-1.917197014, -1.892891458, -1.917316874, -1.917316874, -1.96082729,
-1.92942684, -1.894460401, -1.885810784, -1.886035976, -1.962020147,
-1.827530513, -1.815933622, -1.815933622, -2.002638849, -2.018805309,
-1.811315225, -1.877898507, -1.877898507, -1.808175195, -1.823401553,
-2.08445331628071, -2.08376258849685, -1.752497554, -2.11908990859548,
-2.11774981713296, -2.061217, -1.99918928953703, -1.739386942,
-2.056349361, -1.806836093, -2.0146613405522, -1.706914409, -2.09594932221235,
-2.1236114283278, -2.13554867799906, -2.13278102365979, -2.1337849402663,
-1.64828726258253, -2.14256606908075, -1.8348122253565, -2.1536255491886,
-2.03191191788445, -1.51093368358996, -2.17190440602197, -1.58321519995598,
-1.59092040417202, -1.48652627879978, -2.27348492247396, -1.72377079132697,
-1.47513069127883, -1.56734494060987, -1.91281694364725, -2.18114349682672,
-1.44350305687487, -2.17989813752372, -2.17627937171019, -2.21299366825247,
-1.38687353003726, -2.42301671003337, -2.1265782272244, -1.50924399833574,
-2.09774059427026, -2.10468180665019, -2.10908815031961, -2.44237743041811,
-1.65844636755479, -1.63171926073125, -1.65552780304429, -1.34330965289449,
-1.3085199279646, -2.51857567995444, -1.23202813311806, -1.23202813311806,
-1.18816067895774, -1.18914415566687, -2.25052960308199, -2.43471991140889,
-1.43990956289488, -2.42581759881328, -1.13480281992317, -1.13380404328069,
-1.14771629940694, -1.12710503501623, -1.51382488678545, -1.51329244435424,
-2.16779328377247, -2.3555132448661, -1.21321002764857, -1.49373077710622,
-1.48762319819169, -1.48762319819169, -1.33099361153774, -1.08553196350419,
-1.47386365726927, -1.10375363653395, -1.10301798631517, -1.42813392784829,
-2.7456941155623, -1.44864019197964, -2.08255878649065, -1.06064433436328,
-2.07058746650929, -2.18693907031324, -2.06987176376717, -2.19949139318458,
-2.79305029517291, -2.79305029517291, -2.79375166286606, -2.22758606624075,
-2.21091012684258, -1.48995597985722, -1.01382392061429, -2.70553272840021,
-2.71012695583171, -2.24012678338168, -2.71205526185648, -2.17476849339939,
-2.24468992596494, -2.17646149696921, -2.17646149696921, -2.17745967312515,
-0.950790780294288, -1.18579031822761, -1.14311686830465, -2.75471786942518,
-0.918120502097409, -2.02424781489939, -0.897651859823274, -1.18409719250471,
-0.939737350514506, -0.883088324203225, -1.18579963152504, -0.878022526134149,
-0.87371412210524, -1.18359287488464, -1.18359287488464, -0.872780760004513,
-0.885438596903114, -1.1645098532006, -0.882297418749623, -0.882297418749623,
-0.882328582952221, -1.23812415357399, -0.886687281182311, -0.878970821569071,
-2.08497320217093, -1.30636816419477, -0.873701525940205, -1.13338590158241,
-1.13145003961041, -1.15587528986051, -1.15768698746555, -1.26144853925928,
-1.16204891747625, -2.42317368422002, -2.42317368422002, -1.12643923124051,
-2.48909392415639, -0.741293112518693, -0.728207742466238, -1.14952657242498,
-0.725649536587708, -0.722199662885844, -0.712596291023563, -0.713673486856335,
-1.30908027356376, -0.684962133695598), x = c(1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L)), .Names = c("Hosp_code",
"Hosp", "Hosplat", "Hosplon", "x"), row.names = c(NA, -173L), class = "data.frame")
我已经尝试了以下代码,但它没有识别文本(虽然它确实适用于数值条件!)。
x <- subset(Hosp_coord, Hosp=="Foundation Trust")
和x
返回" 0 obs. of 5 variables"
思想?
谢谢:)
答案 0 :(得分:0)
我们可以使用grep
SubHosp_coord <- Hosp_coord[grepl("TRUST", Hosp_coord$Hosp),]
nrow(SubHosp_coord)
#[1] 44