我正在尝试将R数据框写入Excel并希望添加具有Excel公式和/或数据验证值的其他单元格/列(例如,使用Excel中的"数据/验证"菜单提供允许值的下拉列表细胞)
我看过R包:xlsx,XLConnect和openxlsx.这些非常适合编写单元格,但不适用于公式或数据验证设置.
我目前认为我不得不使用AppleScript(在Mac上)或VBA解决方案来处理xlsx文件.如果可能的话,我想在R中完成所有操作,因此逻辑不必跨程序分割.
在这两者中:为单元格编写数据验证设置(与编写Excel公式相比)更为重要.用例是将R数据框写入Excel并包含用于进行更正的空列.对于空列,我想要为该列提供可接受值的下拉列表(例如"是"/"否").
提前致谢.
我想在每个方面添加两个回归线方程和R2.我采用Jayden的函数来解决问题,但我发现每个方程都是一样的.可能的原因是向函数发送了错误的数据子集.任何建议将被认真考虑!
我的代码:
p <- ggplot(data=df,aes(x=x))+
geom_point(aes(y = y1),size=2.0)+
geom_smooth(aes(y = y1),method=lm,se=FALSE,size=0.5,
fullrange = TRUE)+ # Add regression line;
annotate("text",x = 150,y =320, label = lm_eqn(lm(y1~x,df)), # maybe wrong
size = 2.0, parse = TRUE)+ # Add regression line equation;
geom_point(aes(y = y2),size=2.0)+
geom_smooth(aes(y = y2),method=lm,se=FALSE,size=0.5,
fullrange = TRUE)+ # Add regression line;
annotate("text",x = 225,y =50, label = lm_eqn(lm(y2~x,df)),
size = 2.0, parse = TRUE)+ # Add regression line equation;
facet_wrap(~trt)
Run Code Online (Sandbox Code Playgroud)
我的数据帧:
x y1 y2 trt
22.48349 34.2 …
Run Code Online (Sandbox Code Playgroud) 我正在使用Xamarin.Forms并创建一个拥有后台服务的iOS应用程序,每10分钟获取一个位置.
代码正常,我的问题是当我在IPad上访问App配置时.它显示访问摄像机但不访问当前位置的权限.
我认为,当我提交应用程序进行审核时,这将是一个问题.
用于初始化位置:
this.locMgr = new CLLocationManager();
if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0))
{
locMgr.RequestAlwaysAuthorization(); // works in background
//locMgr.RequestWhenInUseAuthorization (); // only in foreground
}
Run Code Online (Sandbox Code Playgroud)
获取位置:
if (CLLocationManager.LocationServicesEnabled)
{
if (CLLocationManager.Status==CLAuthorizationStatus.Authorized
|| CLLocationManager.Status==CLAuthorizationStatus.AuthorizedAlways)
{
//set the desired accuracy, in meters
LocMgr.DesiredAccuracy = 1;
LocMgr.LocationsUpdated += (object sender, CLLocationsUpdatedEventArgs e) =>
{
_currentLocation = (e.Locations[e.Locations.Length - 1]);
};
LocMgr.AuthorizationChanged += (object sender, CLAuthorizationChangedEventArgs e) =>
{
if (e.Status == CLAuthorizationStatus.Denied
|| e.Status == CLAuthorizationStatus.Restricted)
{
LocMgr.StopUpdatingLocation();
_currentLocation = null;
}
};
LocMgr.StartUpdatingLocation(); …
Run Code Online (Sandbox Code Playgroud) 我在应用程序中使用了相当长的 URL 来接收 XML 数据。我想根据用户时间操纵 URL 中的时间,但我不知道如何解释它。
这是来自 URL 的日期和时间:
2015-04-27T00%3A00%3A00
Run Code Online (Sandbox Code Playgroud)
有没有办法操纵它来显示当前时间?例如,如果我想说现在是 2015 年 4 月 27 日下午 5:30 CST。
对于我在R中的泛型编程问题,我觉得可以通过变量值给出一个向量元素的名称.
例如,
y <- "interesting.value"
Run Code Online (Sandbox Code Playgroud)
我怎样才能以某种形式用y来表达:
c("interesting.value" = 9)
Run Code Online (Sandbox Code Playgroud)
它不起作用
c(y = 9)
Run Code Online (Sandbox Code Playgroud)
这会产生:
y
9
Run Code Online (Sandbox Code Playgroud)
我试过以下一切都没有用.
c(as.name(y) = 9)
Error: unexpected '=' in "c(as.name(y) ="
c(as.symbol(y) = 9)
Error: unexpected '=' in "c(as.symbol(y) ="
c(as.quoted(y) = 9)
Error: unexpected '=' in "c(as.quoted(y) ="
Run Code Online (Sandbox Code Playgroud)
反正有没有实现这个目标?
这只是一个例子.我想学习如何参数化值的名称或列的名称等.
我试图将MainActivity绑定到前台服务,然后得到以下异常,已经搜索了一个多小时,不知道我做错了什么,请救我.
java.lang.ClassCastException: android.os.BinderProxy cannot be cast to com.leonard.sg.okcoin.service.SyncAndTradeService$SyncAndTradeBinder
at com.leonard.sg.okcoin.MainActivity$1.onServiceConnected(MainActivity.java:50)
at android.app.LoadedApk$ServiceDispatcher.doConnected(LoadedApk.java:1101)
at android.app.LoadedApk$ServiceDispatcher$RunConnection.run(LoadedApk.java:1118)
at android.os.Handler.handleCallback(Handler.java:725)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5227)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:795)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:562)
at dalvik.system.NativeStart.main(Native Method)
Run Code Online (Sandbox Code Playgroud)
我的MainActivity中的代码:
private SyncAndTradeService syncAndTradeService;
private boolean hasBounded = false;
private Intent syncAndTradeServiceIntent;
private ServiceConnection syncAndTradeServiceConnection = new ServiceConnection() {
@Override
public void onServiceConnected(ComponentName name, IBinder service) {
SyncAndTradeService.SyncAndTradeBinder syncAndTradeBinder = (SyncAndTradeService.SyncAndTradeBinder) service;
syncAndTradeService = syncAndTradeBinder.getSyncAndTradeService();
hasBounded = true;
}
@Override
public void onServiceDisconnected(ComponentName name) {
syncAndTradeService …
Run Code Online (Sandbox Code Playgroud) 我有一个表视图委托,它检查是否可以选择特定的单元格.如果不是,则中止选择.为了给用户提供视觉反馈,我想将这个细胞的标签染成红色,并在短时间后将其染成黑色:
- (NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if (true) { // Some simplification
MyTableViewCell cell = ... // The correct cell is loaded here
[UIView animateWithDuration:0.5 animations:^{
cellToSelect.labelAmount.textColor = [UIColor redColor];
} completion:^(BOOL finished) {
[UIView animateWithDuration:1.0 animations:^{
cellToSelect.labelAmount.textColor = [UIColor blackColor];
}];
}];
return nil;
}
return indexPath;
}
Run Code Online (Sandbox Code Playgroud)
动画未执行.相反,只是(视觉上)取消选择单元格.
编辑:我刚刚尝试了提出的解决方案,似乎都没有工作.所以我进一步挖掘并发现我可以做动画但是无法更改单元格内任何标签的textColor:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
MyTableViewCell cell = ...
cell.labelAmount.textColor = [UIColor redColor];
// Now, although the property was set (as I can see in …
Run Code Online (Sandbox Code Playgroud) 在编写控制台应用程序时,我正在使用SAP DLL.尝试添加SAP对象时出现以下错误:
附加调试器但未配置为调试此未处理的异常.要调试此异常,请分离当前调试器.
码:
SAPbobsCOM.GeneralService oGeneralService = oCmpSrv.GetGeneralService("WEPPAGE");
SAPbobsCOM.GeneralData oGeneralData = (SAPbobsCOM.GeneralData)oGeneralService.GetDataInterface(di.GeneralServiceDataInterfaces.gsGeneralData);
oGeneralData.SetProperty("U_WebId", "1");
try
{
oGeneralService.Add(oGeneralData);
}
catch (Exception e)
{
Logger.WriteLog("Error Add object " + e.Message);
}
Run Code Online (Sandbox Code Playgroud)
虽然代码用try&catch包装,但IDE崩溃了.
在网络上进行了许多搜索和建议之后,我没有帮助,我遇到了这篇文章并应用了建议的解决方案,并在项目属性调试选项卡下启用了本机代码调试.
勾选此选项的结果是,不是让我调试未知错误,而是异常"消失"并且代码运行时没有干扰.
我使用typesafe配置来读取一些初始配置.
有没有办法检查类型配置中是否存在密钥的一部分.例如,我有以下配置:
foo {
bar {
x = 42
y = 92
}
}
Run Code Online (Sandbox Code Playgroud)
在这里,我想检查我的conf包含foo.bar我不在乎任何配置x
或y
两者都存在一方的存在.
我只想检查配置中是否存在bar的配置.可能吗?
我尝试从另一个包和文件导入类型时遇到问题.我正在尝试导入的结构是下面的结构.
type PriorityQueue []*Item
type Item struct {
value string
priority int
index int
}
Run Code Online (Sandbox Code Playgroud)
如果我将PriorityQueue与其所有方法放在同一个文件中,我将其声明
pq:= &PriorityQueue{}
Run Code Online (Sandbox Code Playgroud)
我一直在寻找互联网,就像一个疯子,在这个简单的问题上找到答案,但我还没有找到答案.我通常用java编程,导入类是如此基础.