PianoAssistenzialeResidenzialeClient ws_Client = new PianoAssistenzialeResidenzialeClient("PianoAssistenzialeResidenzialePort", "https://edottotest.sanita.regione.rsr.rupar.puglia.it/nsisr/PianoAssistenzialeResidenzialeService");
ws_Client.ClientCredentials.ClientCertificate.Certificate=certificatoLocale;
ws_Client.ClientCredentials.ServiceCertificate.DefaultCertificate = certificatoLocale;
ws_Client.ClientCredentials.ServiceCertificate.Authentication.CertificateValidationMode = X509CertificateValidationMode.None;
EndpointIdentity identity = EndpointIdentity.CreateDnsIdentity("HEALTHNETBR");
EndpointAddress address = new EndpointAddress(new Uri("https://edottotest.sanita.regione.rsr.rupar.puglia.it/nsisr/PianoAssistenzialeResidenzialeService"), identity);
ws_Client.Endpoint.Address = address;
ws_Client.getElencoPAIDomiciliare(attributi, request);
是R
a
我希望“翻译”为(临时)字符串向量,以便> a <- c(1, 2, 3, 3, 2, 3, 1, 2, 1)
变为1
,"foo"
变为2
,"bar"
变为3
。
我可以使用"baz"
:
sapply
但是,我认为应该有另一种方法可以在没有(我认为是误用)> sapply(a, function(x) {if (x==1) return ('foo'); if (x==2) return ('bar'); return ('baz')})
[1] "foo" "bar" "baz" "baz" "bar" "baz" "foo" "bar" "foo"
的情况下做到这一点。是这种情况吗?
答案 0 :(得分:5)
试试吧:
c("foo","bar","baz")[a]
#[1] "foo" "bar" "baz" "baz" "bar" "baz" "foo" "bar" "foo"
答案 1 :(得分:2)
另一个明显的解决方案是将数据视为因素:
$("#type > option:contains('"+calEvent.visitortype+"')").attr("selected", "selected");
用factor(a, c(1, 2, 3), c("foo", "bar", "baz"))
# [1] foo bar baz baz bar baz foo bar foo
# Levels: foo bar baz
换行表示字符:
as.character