我正在尝试编写一个等效的函数scales::dollar,在图的开头添加一个英镑(£)符号.由于比例代码非常强大,我将它用作框架并简单地将$替换为£.
一个精简的功能示例:
pounds<-function(x) paste0("£",x)
Run Code Online (Sandbox Code Playgroud)
当我运行CHECK时,我得到以下内容:
Found the following file with non-ASCII characters:
pounds.R
Portable packages must use only ASCII characters in their R code,
except perhaps in comments.
Use \uxxxx escapes for other characters.
Run Code Online (Sandbox Code Playgroud)
通过编写R扩展指南,它没有提供很多帮助(IMO)如何解决此问题.它提到\ uxxxx并说它引用了Unicode字符.
查找unicode字符会产生代码,£但我能找到的指导\uxxxx很少,并且与W3schools上的Java有关.
我的问题是:
如何使用\ uxxxx转义在R函数中实现非unicode字符的使用?在使用该函数后,使用情况如何影响这些字符的显示?
默认情况下,使用闪亮的DataTable中的数千个分隔符渲染大数字.
文档读(对我来说)应该已经显示了千位分隔符.我是否遇到了兼容性问题,或者我是否需要在代码中添加更多内容,如果是,那又怎么样?
[更新]还有另一个SO问题,试图解决闪亮的预格式化数据的排序.问题尚未解决,但建议另一条路线 - 事先格式化.这是一条可取的路线,如果是这样,如何正确解决其他OP的排序问题?
我试图改善闪亮表的输出,以提高可读性.我已成功使用另一个SO问题来冻结标题,但我正在努力使数字格式正确.
library(shiny)
runApp(
list(ui = fluidPage(
tagList(
singleton(tags$head(tags$script(src='//cdn.datatables.net/fixedheader/2.1.2/js/dataTables.fixedHeader.min.js',type='text/javascript'))),
singleton(tags$head(tags$link(href='//cdn.datatables.net/fixedheader/2.1.2/css/dataTables.fixedHeader.css',rel='stylesheet',type='text/css')))
),
dataTableOutput("mytable")
)
, server = function(input, output, session){
output$mytable <- renderDataTable(iris*1000,
options = list(
pageLength = 50,
language.thousands=",",
initComplete = I("function(settings, json){
new $.fn.dataTable.FixedHeader(this, {
left: true
} );
}")
)
)
})
)
Run Code Online (Sandbox Code Playgroud)

看看DataTable文档,它看起来就像设置语言一样.数千就足够了:
DataTables的内置数字格式化程序(formatNumberDT)用于格式化表信息中使用的大数字.
默认情况下,DataTables将使用language.thousandsDT中指定的字符(反过来,默认情况下是逗号)作为千位分隔符.
在formatNumber中它有一个可以添加的函数,但是,这对我来说是一个新的,所以我不确定在现有代码的上下文中如何使用这个函数.
$('#example').dataTable( {
"formatNumber": function ( toFormat ) {
return toFormat.toString().replace(
/\B(?=(\d{3})+(?!\d))/g, "'"
);
};
} …Run Code Online (Sandbox Code Playgroud) 我正在尝试处理在添加新属性之前插入Azure表存储的记录.在LINQ的支持是有限的,我努力得到这个工作.
如何使用LINQ(或其他方法)过滤Azure表以仅记录缺少给定实体的属性?
我在Azure函数中编写它,并且在尝试字段的默认值时,此处的行计数返回0.
#r "Microsoft.WindowsAzure.Storage"
using System.Net;
using Microsoft.WindowsAzure.Storage.Table;
public static HttpResponseMessage Run(HttpRequestMessage req, IQueryable<ts_webhit> inTable, TraceWriter log)
{
IEnumerable<ts_webhit> recs = (from r in inTable
where "2016-11-21 12:45" == r.PartitionKey
&& "" == r.Category //The filter I need to run
select r);
log.Info($"{recs.Count()}");
return req.CreateResponse(HttpStatusCode.OK, recs.ToList());
}
public class ts_webhit : TableEntity
{
public string Category { get; set; } = ""; //Attempting a default value
}
Run Code Online (Sandbox Code Playgroud)
r.Category is nothing 生成编译错误String.IsNullOrEmpty(r.Category) 返回它不受支持r.Category == …我需要可以从PS-Gallery获得的AWS模块,但是当我尝试在Azure功能中运行安装步骤时,它不起作用.-verbose参数标志未向控制台写入任何内容.
在Azure功能中获取和使用其他PowerShell模块的正确方法是什么?
[Console]::WriteLine("PowerShell Timer trigger function executed at:$(get-date)");
if (-not (Get-Module -Name "AWSPowerShell")) {
[Console]::WriteLine("AWSPowerShell not installed");
Install-Module -Name AWSPowerShell -Scope CurrentUser -ErrorAction Continue -Verbose
}
if (-not (Get-Module -Name "AWSPowerShell")){
[Console]::WriteLine("AWSPowerShell install step failed");
}
Run Code Online (Sandbox Code Playgroud)
2016-06-09T11:24:31.108 Function started (Id=e09be687-2e13-4754-942e-eab75c8516e5)
2016-06-09T11:24:32.788 Powershell Timer trigger function executed at:06/09/2016 11:24:32
AWSPowerShell not installed
AWSPowerShell install step failed
2016-06-09T11:24:32.788 Function completed (Success, Id=e09be687-2e13-4754-942e-eab75c8516e5)
Run Code Online (Sandbox Code Playgroud)
根据@travis的回答,我添加了建议的代码,包括nuget包管理器行.这仍然无效.我添加了另一个调试行,发现即使在尝试添加nuget之后也没有模块提供者!
[Console]::WriteLine("Powershell Timer trigger function executed at:$(get-date)");
Get-PackageProvider -Name nuget -ForceBootstrap
$pkg=Get-PackageProvider -ListAvailable
if …Run Code Online (Sandbox Code Playgroud) 我有一个数据集(mydata),其中包含多个列,这些列可以适合存储在另一个数据集(mycomparison)中的范围内.
我想加入mycomparison到mydata了哪里mydata值都在范围内mycomparison.
library(data.table)
mydata<-data.table(
id=1:5,
val1=seq(10000, 50000, by=10000),
val2=floor(rnorm(5,mean=400,sd=100)),
val3=rnorm(5,mean=.7,sd=.1)
)
mycomparison<-data.table(
Name=LETTERS[1:3],
minval1=c(0,30000,10000),
maxval1=c(50000,80000,30000),
minval2=c(300,400,300),
maxval2=c(800,800,800),
minval3=c(0,.5,.2),
maxval3=c(1,.9,.8),
correspondingval=c(.1,.2,.3)
)
Run Code Online (Sandbox Code Playgroud)
> mydata.withmatches
id val1 val2 val3 Name minval1 maxval1 minval2 maxval2 minval3 maxval3 correspondingval
1: 1 10000 387 0.4844319 A 0 50000 300 800 0 1 0.1
2: 2 20000 425 0.7856313 NA NA NA NA NA NA NA NA
3: 3 30000 324 0.8063969 …Run Code Online (Sandbox Code Playgroud) 我在ubuntu服务器上安装了闪亮的服务器.我在开发服务器上做了类似的安装工作.当他们打开R会话加载一些包.该应用程序在本地运行正常,但我收到的消息是,它在发光服务器上运行时找不到包.
应用程序上的错误
During startup - Warning messages:
1: In library(package, lib.loc = lib.loc, character.only = TRUE, logical.return = TRUE, :
there is no package called ‘shiny’
2: package ‘shiny’ in options("defaultPackages") was not found
3: In library(package, lib.loc = lib.loc, character.only = TRUE, logical.return = TRUE, :
there is no package called ‘data.table’
4: package ‘data.table’ in options("defaultPackages") was not found
5: In library(package, lib.loc = lib.loc, character.only = TRUE, logical.return = TRUE, :
there is no package called ‘optiRum’ …Run Code Online (Sandbox Code Playgroud) 我正在尝试在data.table中做一些glm来生成按关键因素分割的建模结果.
我一直在做这个成功的:
高水平的glm
glm(modellingDF,formula =结果~IntCol + DecCol,family =二项式(link = logit))
单列旋转glm
modellingDF [,list(结果,拟合= glm(x,公式=结果~IntCol,family =二项式(link = logit))$拟合),by = variable]
带有两个整数列的scmped glm
modellingDF [,list(结果,拟合= glm(x,公式=结果~IntCol + IntCol2,family =二项式(link = logit))$拟合),by = variable]
但是,当我尝试使用我的十进制列在范围内执行高级别的glm时,会产生此错误
Error in model.frame.default(formula = Outcome ~ IntCol + DecCol, data = x, :
variable lengths differ (found for 'DecCol')
Run Code Online (Sandbox Code Playgroud)
我想也许是因为分区长度不一,所以我测试了一个可重复的例子:
library("data.table")
testing<-data.table(letters=sample(rep(LETTERS,5000),5000),
letters2=sample(rep(LETTERS[1:5],10000),5000),
cont.var=rnorm(5000),
cont.var2=round(rnorm(5000)*1000,0),
outcome=rbinom(5000,1,0.8)
,key="letters")
testing.glm<-testing[,list(outcome,
fitted=glm(x,formula=outcome~cont.var+cont.var2,family=binomial(link=logit))$fitted)
),by=list(letters)]
Run Code Online (Sandbox Code Playgroud)
但这没有错误.我想也许这是由于NAs或其他东西,但数据摘要.table modellingDF没有表明应该有任何问题:
DecCol
Min. :0.0416
1st Qu.:0.6122
Median :0.7220
Mean :0.6794
3rd Qu.:0.7840
Max. :0.9495
nrow(modellingDF[is.na(DecCol),]) # results …Run Code Online (Sandbox Code Playgroud) 我在Windows上具有Rstudio(sessionInfo()如下),并且正在尝试使用markdown构建r演示文稿。当我尝试编织HTML或PDF时,似乎并没有保留应从中生成绘图的文件夹,结果,我的演示文稿丢失了绘图。我已经确认它确实适用于基本的html_document。
有人对解决方法有任何想法吗?
MWE(rstudio默认带有幻灯片标题)
---
title: "plottest2"
author: "AN Other"
date: "Monday, June 30, 2014"
output: html_document
---
## Area 1 ##
This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see <http://rmarkdown.rstudio.com>.
When you click the **Knit** button a document will be generated that includes both content as well as the output of any embedded R code chunks within …Run Code Online (Sandbox Code Playgroud) 我试图通过R中的REST API使用Azure存储.我正在使用httr覆盖Curl 的包.
您可以使用R-fiddle:http://www.r-fiddle.org/#/fiddle?id = vh8uqGmM
library(httr)
requestdate<-format(Sys.time(),"%a, %d %b %Y %H:%M:%S GMT")
url<-"https://preconstuff.blob.core.windows.net/pings?restype=container&comp=list"
sak<-"Q8HvUVJLBJK+wkrIEG6LlsfFo19iDjneTwJxX/KXSnUCtTjgyyhYnH/5azeqa1bluGD94EcPcSRyBy2W2A/fHQ=="
signaturestring<-paste0("GET",paste(rep("\n",12),collapse=""),
"x-ms-date:",requestdate,"
x-ms-version:2009-09-19
/preconstuff/pings
comp:list
restype:container")
headerstuff<-add_headers(Authorization=paste0("SharedKey preconstuff:",
RCurl::base64(digest::hmac(key=sak,
object=enc2utf8(signaturestring),
algo= "sha256"))),
`x-ms-date`=requestdate,
`x-ms-version`= "2009-09-19")
Run Code Online (Sandbox Code Playgroud)
试图列出blob:
content(GET(url,config = headerstuff, verbose() ))
Run Code Online (Sandbox Code Playgroud)
在HTTP请求'Q8HvUVJLBJK + wkrIEG6LlsfFo19iDjneTwJxX /KXSnUCtTjgyyhYnH/5azeqa1bluGD94EcPcSRyBy2W2A/fHQ =='中找到的MAC签名与任何计算签名不同.
[1] "<?xml version=\"1.0\" encoding=\"utf-8\"?><Error>
<Code>AuthenticationFailed</Code><Message>Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature.\nRequestId:1ab26da5-0001-00dc-6ddb-15e35c000000\nTime:2015-03-26T17:51:42.7190620Z</Message>
<AuthenticationErrorDetail>The MAC signature found in …Run Code Online (Sandbox Code Playgroud) 我有一个大数据集和一个查找表。我需要为数据集中的每一行返回满足条件的查找中行的最小值。
鉴于我的数据集的大小,我不愿意通过交叉连接来破解一个不确定的解决方案,因为这会创建数百万条记录。我希望有人可以提出一个(理想情况下)利用 base r 或 data.table 的解决方案,因为它们已经以有效的方式使用。
例子
A<-seq(1e4,9e4,1e4)
B<-seq(0,1e4,1e3)
dt1<-data.table(expand.grid(A,B),ID=1:nrow(expand.grid(A,B)))
setnames(dt1, c("Var1","Var2"),c("A","B"))
lookup<-data.table(minA=c(1e4,1e4,2e4,2e4,5e4),
maxA=c(2e4,3e4,7e4,6e4,9e4),
minB=rep(2e3,5),
Val=seq(.1,.5,.1))
# Sample Desired Value
A B ID Val
99: 90000 10000 99 0.5
Run Code Online (Sandbox Code Playgroud)
在 SQL 中,我会写一些类似的东西
SELECT ID, A, B, min(Val) as Val
FROM dt1
LEFT JOIN lookup on dt1.A>=lookup.minA
and dt1.A<=lookup.maxA
and dt1.B>=lookup.minB
GROUP BY ID, A, B
Run Code Online (Sandbox Code Playgroud)
这将连接从lookupto 开始的所有匹配记录dt1并返回最小的Val.
更新
到目前为止,我的解决方案如下:
CJ.table<-function(X,Y) setkey(X[,c(k=1,.SD)],k)[Y[,c(k=1,.SD)],allow.cartesian=TRUE][,k:=NULL]
dt1.lookup<- CJ.table(dt1,lookup)[A>=minA & A<=maxA & B>=minB,
list(Val=Val[which.min( Val)]),
by=list(ID,A,B)]
dt1.lookup<-rbind.fill(dt1.lookup, dt1[!ID %in% …Run Code Online (Sandbox Code Playgroud) r ×8
data.table ×3
azure ×2
shiny ×2
ascii ×1
c# ×1
datatables ×1
glm ×1
httr ×1
linq ×1
powershell ×1
r-markdown ×1
rstudio ×1
shiny-server ×1
string ×1
unicode ×1