Давайте создадим некоторые игрушечные данные. Четыре лечения с разными вероятностями. 100 пациентов посещают 1000 раз.
set.seed(123)
df<-data.frame(A = sample(c("MRI", "ECG", "Echo", "PET"), 1000,
prob=c(0.05, 0.8, 0.13, 0.02), replace=TRUE),
p = sample(1:100, 1000, replace=TRUE))
Теперь мы агрегируем данные
df %>%
# group by Treatment and patients
group_by(A, p) %>%
# first summary is the number of a specific treatments for each patient
summarise(n = n()) %>%
# next summary we sum the number distinct patients in the group
# and divide by sum the number of distinct patients to get the rel.freq of the treatment.
# Then we take the mean value of the number of treatment pr. patient
summarise(rel.freq = n_distinct(p)/n_distinct(df$p),
avg.hcu.pt = mean(n))
Результат
# A tibble: 4 x 3
A rel.freq avg.hcu.pt
<fct> <dbl> <dbl>
1 ECG 1 8.02
2 Echo 0.76 1.72
3 MRI 0.37 1.30
4 PET 0.17 1.12
Следующий код работает для меня:
IServiceProvider serviceProvider = (IServiceProvider)HttpContext.Current;
HttpWorkerRequest workerRequest = (HttpWorkerRequest)serviceProvider.GetService(typeof(HttpWorkerRequest));
string realUrl = workerRequest.GetServerVariable("HTTP_URL");
Обратите внимание, что это работает только при работе на IIS, а не под fx ASP.NET Development Server!
Благодаря Lucero за ответ в другой ветке и Жаф за указание мне на тему.
Я не смог проверить это, потому что он работает только в IIS, а не на сервере разработки ASP.NET, который является частью Visual Studio, но попробуйте:
Request.ServerVariables [" HTTP_URL "]
Server.HtmlEncode(Request.RawUrl);
Необработанный URL-адрес определяется как часть URL-адреса, следующего за информацией о домене. В строке URL-адреса http://www.contoso.com/articles/recent.aspx необработанным URL-адресом является /articles/recent.aspx. Необработанный URL-адрес включает строку запроса, если она имеется.
см. Также: текст ссылки
I can't test here, but this might be what you need:
Request.Url.AbsoluteUri
Request.RawUrl
вернет относительный путь к приложению (включая информацию о строке запроса), в то время как Request.Url
вернет полный путь (включая информация строки запроса).
Для получения дополнительной информации см. « Определение путей ASP.NET ».
Well, you could just encode it back to the url-encoded version.
Get the url from the request and urlencode only the query string part and then concatenate them