- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一些库可以与我用 C++ 打包到 DLL 中的 FTDI 芯片进行交互。
我想用 Flutter 创建一个前端并在 Windows 桌面应用程序中使用该库。
这些功能在 Flutter 中仍然是新的,并且文档非常浅薄且特定于移动设备。
遵循指南here ,我用 FFI 创建了一个插件:
import 'dart:ffi';
import 'dart:io';
import 'dart:async';
import 'package:flutter/services.dart';
final DynamicLibrary FT232H = DynamicLibrary.open("");
final int Function() initializeLibrary = FT232H
.lookup<NativeFunction<Uint8 Function()>>("initialize_library")
.asFunction();
final void Function() cleanupLibrary = FT232H
.lookup<NativeFunction<Void Function()>>("cleanup_library")
.asFunction();
final int Function() initializeI2C = FT232H
.lookup<NativeFunction<Uint8 Function()>>("Initialize_I2C")
.asFunction();
final int Function() closeI2C = FT232H
.lookup<NativeFunction<Uint8 Function()>>("Close_I2C")
.asFunction();
final int Function(
Uint8 slaveAddress, Uint8 registerAddress, Uint32 data, Uint32 numBytes)
i2cWriteBytes = FT232H
.lookup<NativeFunction<Uint8 Function(Uint8, Uint8, Uint32, Uint32)>>(
"I2C_write_bytes")
.asFunction();
final int Function(Uint8 slaveAddress, Uint8 registerAddress,
Uint8 bRegisterAddress, Pointer<Uint8> data, Uint32 numBytes)
i2cReadBytes = FT232H
.lookup<
NativeFunction<
Uint8 Function(Uint8, Uint8, Uint8, Pointer<Uint8>,
Uint32)>>("I2C_read_bytes")
.asFunction();
class DllImport {
static const MethodChannel _channel = const MethodChannel('dll_import');
static Future<String> get platformVersion async {
final String version = await _channel.invokeMethod('getPlatformVersion');
return version;
}
}
这是我在另一边的头文件:
#pragma once
/* Include D2XX header*/
#include "ftd2xx.h"
/* Include libMPSSE headers */
#include "libMPSSE_i2c.h"
#include "libMPSSE_spi.h"
#define FT232H_EXPORTS
#ifdef FT232H_EXPORTS
#define FT232H_API __declspec(dllexport)
#else
#define FT232H_API __declspec(dllimport)
#endif
extern "C" FT232H_API uint8 initialize_library();
extern "C" FT232H_API void cleanup_library();
extern "C" FT232H_API FT_STATUS Initialize_I2C();
extern "C" FT232H_API FT_STATUS Close_I2C();
extern "C" FT232H_API FT_STATUS I2C_write_bytes(uint8 slaveAddress, uint8 registerAddress,
const uint8 * data, uint32 numBytes);
extern "C" FT232H_API FT_STATUS I2C_read_bytes(uint8 slaveAddress, uint8 registerAddress,
uint8 bRegisterAddress, uint8 * data, uint32 numBytes);
在这里,我对 Uint8 指针有一些问题,因为我从我的 Dart 代码中得到了这个错误:
The type 'Uint8 Function(Uint8, Uint8, Uint8, Pointer<Uint8>, Uint32)' must be a subtype of 'int
Function(Uint8, Uint8, Uint8, Pointer<Uint8>, Uint32)' for 'asFunction'.
Try changing one or both of the type arguments.dart(must_be_a_subtype)
任何有关如何在 flutter 中实现这一点的指示将不胜感激!
最佳答案
我确实有一个解决方案,它适用于 Flutter-Desktop-Embedding 项目中提供的准系统代码,我假设您将其用于您的桌面应用程序。你在正确的轨道上,但只需要一些最终确定。
为了测试,我使用这个带有几个函数的简单 c 代码来测试传递指针、返回指针、填充内存、分配和释放。
这是我在我的 dll 中使用的 C 代码。
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
__declspec(dllexport) uint8_t* createarray(int32_t size) {
uint8_t* arr = malloc(size);
return arr;
}
__declspec(dllexport) void populatearray(uint8_t* arr,uint32_t size){
for (uint32_t index = 0; index < size; ++index) {
arr[index] = index & 0xff;
}
}
__declspec(dllexport) void destroyarray(uint8_t* arr) {
free(arr);
}
createarray
分配给定大小的 uint8_t 指针并将其返回给调用者。
populatearray
使用 uint8_t 指针参数和 size 并用 index 填充它
destroyarray
简单地释放分配的内存。
main.dart
提供的默认代码在我从这里克隆的 Flutter-Desktop-Embedding 项目中
https://github.com/google/flutter-desktop-embedding.git
(我假设你已经完成了这一步)
// Copyright 2018 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
import 'dart:io' show Platform;
import 'dart:math' as math;
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:menubar/menubar.dart';
import 'package:window_size/window_size.dart' as window_size;
import 'keyboard_test_page.dart';
void main() {
// Try to resize and reposition the window to be half the width and height
// of its screen, centered horizontally and shifted up from center.
WidgetsFlutterBinding.ensureInitialized();
window_size.getWindowInfo().then((window) {
final screen = window.screen;
if (screen != null) {
final screenFrame = screen.visibleFrame;
final width = math.max((screenFrame.width / 2).roundToDouble(), 800.0);
final height = math.max((screenFrame.height / 2).roundToDouble(), 600.0);
final left = ((screenFrame.width - width) / 2).roundToDouble();
final top = ((screenFrame.height - height) / 3).roundToDouble();
final frame = Rect.fromLTWH(left, top, width, height);
window_size.setWindowFrame(frame);
window_size.setWindowMinSize(Size(0.8 * width, 0.8 * height));
window_size.setWindowMaxSize(Size(1.5 * width, 1.5 * height));
window_size
.setWindowTitle('Flutter Testbed on ${Platform.operatingSystem}');
}
});
runApp(new MyApp());
}
/// Top level widget for the application.
class MyApp extends StatefulWidget {
/// Constructs a new app with the given [key].
const MyApp({Key? key}) : super(key: key);
@override
_AppState createState() => new _AppState();
}
class _AppState extends State<MyApp> {
Color _primaryColor = Colors.blue;
int _counter = 0;
static _AppState? of(BuildContext context) =>
context.findAncestorStateOfType<_AppState>();
/// Sets the primary color of the app.
void setPrimaryColor(Color color) {
setState(() {
_primaryColor = color;
});
}
void incrementCounter() {
_setCounter(_counter + 1);
}
void _decrementCounter() {
_setCounter(_counter - 1);
}
void _setCounter(int value) {
setState(() {
_counter = value;
});
}
/// Rebuilds the native menu bar based on the current state.
void updateMenubar() {
setApplicationMenu([
Submenu(label: 'Color', children: [
MenuItem(
label: 'Reset',
enabled: _primaryColor != Colors.blue,
shortcut: LogicalKeySet(
LogicalKeyboardKey.meta, LogicalKeyboardKey.backspace),
onClicked: () {
setPrimaryColor(Colors.blue);
}),
MenuDivider(),
Submenu(label: 'Presets', children: [
MenuItem(
label: 'Red',
enabled: _primaryColor != Colors.red,
shortcut: LogicalKeySet(LogicalKeyboardKey.meta,
LogicalKeyboardKey.shift, LogicalKeyboardKey.keyR),
onClicked: () {
setPrimaryColor(Colors.red);
}),
MenuItem(
label: 'Green',
enabled: _primaryColor != Colors.green,
shortcut: LogicalKeySet(LogicalKeyboardKey.meta,
LogicalKeyboardKey.alt, LogicalKeyboardKey.keyG),
onClicked: () {
setPrimaryColor(Colors.green);
}),
MenuItem(
label: 'Purple',
enabled: _primaryColor != Colors.deepPurple,
shortcut: LogicalKeySet(LogicalKeyboardKey.meta,
LogicalKeyboardKey.control, LogicalKeyboardKey.keyP),
onClicked: () {
setPrimaryColor(Colors.deepPurple);
}),
])
]),
Submenu(label: 'Counter', children: [
MenuItem(
label: 'Reset',
enabled: _counter != 0,
shortcut: LogicalKeySet(
LogicalKeyboardKey.meta, LogicalKeyboardKey.digit0),
onClicked: () {
_setCounter(0);
}),
MenuDivider(),
MenuItem(
label: 'Increment',
shortcut: LogicalKeySet(LogicalKeyboardKey.f2),
onClicked: incrementCounter),
MenuItem(
label: 'Decrement',
enabled: _counter > 0,
shortcut: LogicalKeySet(LogicalKeyboardKey.f1),
onClicked: _decrementCounter),
]),
]);
}
@override
Widget build(BuildContext context) {
// Any time the state changes, the menu needs to be rebuilt.
updateMenubar();
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
primaryColor: _primaryColor,
accentColor: _primaryColor,
),
darkTheme: ThemeData.dark(),
home: _MyHomePage(title: 'Flutter Demo Home Page', counter: _counter),
);
}
}
class _MyHomePage extends StatelessWidget {
const _MyHomePage({required this.title, this.counter = 0});
final String title;
final int counter;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(title),
),
body: LayoutBuilder(
builder: (context, viewportConstraints) {
return SingleChildScrollView(
child: ConstrainedBox(
constraints:
BoxConstraints(minHeight: viewportConstraints.maxHeight),
child: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
const Text(
'You have pushed the button this many times:',
),
new Text(
'$counter',
style: Theme.of(context).textTheme.headline4,
),
TextInputTestWidget(),
new ElevatedButton(
child: new Text('Test raw keyboard events'),
onPressed: () {
Navigator.of(context).push(new MaterialPageRoute(
builder: (context) => KeyboardTestPage()));
},
),
Padding(
padding: const EdgeInsets.all(8.0),
child: Container(
width: 380.0,
height: 100.0,
decoration: BoxDecoration(
border: Border.all(color: Colors.grey, width: 1.0)),
child: Scrollbar(
child: ListView.builder(
padding: EdgeInsets.all(8.0),
itemExtent: 20.0,
itemCount: 50,
itemBuilder: (context, index) {
return Text('entry $index');
},
),
),
),
),
],
),
),
),
);
},
),
floatingActionButton: FloatingActionButton(
onPressed: _AppState.of(context)!.incrementCounter,
tooltip: 'Increment',
child: Icon(Icons.add),
),
);
}
}
/// A widget containing controls to test text input.
class TextInputTestWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Row(
mainAxisAlignment: MainAxisAlignment.center,
children: const <Widget>[
SampleTextField(),
SampleTextField(),
],
);
}
}
/// A text field with styling suitable for including in a TextInputTestWidget.
class SampleTextField extends StatelessWidget {
/// Creates a new sample text field.
const SampleTextField();
@override
Widget build(BuildContext context) {
return Container(
width: 200.0,
padding: const EdgeInsets.all(10.0),
child: TextField(
decoration: InputDecoration(border: OutlineInputBorder()),
),
);
}
}
现在对于我们的代码部分,我们必须为要在 dll 中调用的每个函数创建一个函数指针,我们需要正确的函数名称和正确/正确的参数数量。
import 'dart:ffi'; // For FFI
现在要创建需要加载的库的句柄,需要使用 dll 的名称调用 DynamicLibrary.open。 (dll需要放在dart应用的执行路径或者需要给出绝对路径,执行路径为build/windows/runner/Debug)
final DynamicLibrary nativePointerTestLib = DynamicLibrary.open("dynamicloadtest.dll");
我的句柄叫
nativePointerTestLib
并且 dll 的名称是“dynamicloadtest.dll”(是的,我可能应该使用更好的命名约定)
final Pointer<Uint8> Function(int size) nativeCreateArray =
nativePointerTestLib
.lookup<NativeFunction<Pointer<Uint8> Function(Int32)>>("createarray")
.asFunction();
final void Function(Pointer<Uint8> arr,int size) nativePopulateArray =
nativePointerTestLib
.lookup<NativeFunction<Void Function(Pointer<Uint8>, Int32)>>("populatearray")
.asFunction();
final void Function(Pointer<Uint8> arr) nativeDestroyArray =
nativePointerTestLib
.lookup<NativeFunction<Void Function(Pointer<Uint8>)>>("destroyarray")
.asFunction();
我将函数指针命名为
nativeCreateArray
,
nativePopulateArray
,
nativeDestroyArray
最后,只需调用每个函数并测试它们是否有效。我刚刚在样板代码中选择了一个随机函数,
void _setCounter(int value)
它设置计数器值,然后显示。我只是要向该方法添加额外的代码来执行我们的函数调用以及打印结果以查看它是否有效。
void _setCounter(int value) {
setState(() {
_counter = value;
});
}
我们的函数调用的新方法
void _setCounter(int value) {
setState(() {
Pointer<Uint8> parray = nativeCreateArray(5);
nativePopulateArray(parray,5);
//Now lets print
print(parray);
String str= "";
for(int i = 0 ; i < 5; ++i){
int val = parray.elementAt(i).value;
str+=val.toString() +" ";
}
print(str);
nativeDestroyArray(parray);
_counter = value;
});
}
我调用了大小为 5 的 nativeCreate。dll 将为数组分配 5 个字节。
// Copyright 2018 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
import 'dart:io' show Platform;
import 'dart:math' as math;
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:menubar/menubar.dart';
import 'package:window_size/window_size.dart' as window_size;
import 'keyboard_test_page.dart';
import 'dart:ffi'; // For FFI
final DynamicLibrary nativePointerTestLib = DynamicLibrary.open("dynamicloadtest.dll");
final Pointer<Uint8> Function(int size) nativeCreateArray =
nativePointerTestLib
.lookup<NativeFunction<Pointer<Uint8> Function(Int32)>>("createarray")
.asFunction();
final void Function(Pointer<Uint8> arr,int size) nativePopulateArray =
nativePointerTestLib
.lookup<NativeFunction<Void Function(Pointer<Uint8>, Int32)>>("populatearray")
.asFunction();
final void Function(Pointer<Uint8> arr) nativeDestroyArray =
nativePointerTestLib
.lookup<NativeFunction<Void Function(Pointer<Uint8>)>>("destroyarray")
.asFunction();
void main() {
// Try to resize and reposition the window to be half the width and height
// of its screen, centered horizontally and shifted up from center.
WidgetsFlutterBinding.ensureInitialized();
window_size.getWindowInfo().then((window) {
final screen = window.screen;
if (screen != null) {
final screenFrame = screen.visibleFrame;
final width = math.max((screenFrame.width / 2).roundToDouble(), 800.0);
final height = math.max((screenFrame.height / 2).roundToDouble(), 600.0);
final left = ((screenFrame.width - width) / 2).roundToDouble();
final top = ((screenFrame.height - height) / 3).roundToDouble();
final frame = Rect.fromLTWH(left, top, width, height);
window_size.setWindowFrame(frame);
window_size.setWindowMinSize(Size(0.8 * width, 0.8 * height));
window_size.setWindowMaxSize(Size(1.5 * width, 1.5 * height));
window_size
.setWindowTitle('Flutter Testbed on ${Platform.operatingSystem}');
}
});
runApp(new MyApp());
}
/// Top level widget for the application.
class MyApp extends StatefulWidget {
/// Constructs a new app with the given [key].
const MyApp({Key? key}) : super(key: key);
@override
_AppState createState() => new _AppState();
}
class _AppState extends State<MyApp> {
Color _primaryColor = Colors.blue;
int _counter = 0;
static _AppState? of(BuildContext context) =>
context.findAncestorStateOfType<_AppState>();
/// Sets the primary color of the app.
void setPrimaryColor(Color color) {
setState(() {
_primaryColor = color;
});
}
void incrementCounter() {
_setCounter(_counter + 1);
}
void _decrementCounter() {
_setCounter(_counter - 1);
}
void _setCounter(int value) {
setState(() {
Pointer<Uint8> parray = nativeCreateArray(5);
nativePopulateArray(parray,5);
//Now lets print
print(parray);
String str= "";
for(int i = 0 ; i < 5; ++i){
int val = parray.elementAt(i).value;
str+=val.toString() +" ";
}
print(str);
nativeDestroyArray(parray);
_counter = value;
});
}
/// Rebuilds the native menu bar based on the current state.
void updateMenubar() {
setApplicationMenu([
Submenu(label: 'Color', children: [
MenuItem(
label: 'Reset',
enabled: _primaryColor != Colors.blue,
shortcut: LogicalKeySet(
LogicalKeyboardKey.meta, LogicalKeyboardKey.backspace),
onClicked: () {
setPrimaryColor(Colors.blue);
}),
MenuDivider(),
Submenu(label: 'Presets', children: [
MenuItem(
label: 'Red',
enabled: _primaryColor != Colors.red,
shortcut: LogicalKeySet(LogicalKeyboardKey.meta,
LogicalKeyboardKey.shift, LogicalKeyboardKey.keyR),
onClicked: () {
setPrimaryColor(Colors.red);
}),
MenuItem(
label: 'Green',
enabled: _primaryColor != Colors.green,
shortcut: LogicalKeySet(LogicalKeyboardKey.meta,
LogicalKeyboardKey.alt, LogicalKeyboardKey.keyG),
onClicked: () {
setPrimaryColor(Colors.green);
}),
MenuItem(
label: 'Purple',
enabled: _primaryColor != Colors.deepPurple,
shortcut: LogicalKeySet(LogicalKeyboardKey.meta,
LogicalKeyboardKey.control, LogicalKeyboardKey.keyP),
onClicked: () {
setPrimaryColor(Colors.deepPurple);
}),
])
]),
Submenu(label: 'Counter', children: [
MenuItem(
label: 'Reset',
enabled: _counter != 0,
shortcut: LogicalKeySet(
LogicalKeyboardKey.meta, LogicalKeyboardKey.digit0),
onClicked: () {
_setCounter(0);
}),
MenuDivider(),
MenuItem(
label: 'Increment',
shortcut: LogicalKeySet(LogicalKeyboardKey.f2),
onClicked: incrementCounter),
MenuItem(
label: 'Decrement',
enabled: _counter > 0,
shortcut: LogicalKeySet(LogicalKeyboardKey.f1),
onClicked: _decrementCounter),
]),
]);
}
@override
Widget build(BuildContext context) {
// Any time the state changes, the menu needs to be rebuilt.
updateMenubar();
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
primaryColor: _primaryColor,
accentColor: _primaryColor,
),
darkTheme: ThemeData.dark(),
home: _MyHomePage(title: 'Flutter Demo Home Page', counter: _counter),
);
}
}
class _MyHomePage extends StatelessWidget {
const _MyHomePage({required this.title, this.counter = 0});
final String title;
final int counter;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(title),
),
body: LayoutBuilder(
builder: (context, viewportConstraints) {
return SingleChildScrollView(
child: ConstrainedBox(
constraints:
BoxConstraints(minHeight: viewportConstraints.maxHeight),
child: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
const Text(
'You have pushed the button this many times:',
),
new Text(
'$counter',
style: Theme.of(context).textTheme.headline4,
),
TextInputTestWidget(),
new ElevatedButton(
child: new Text('Test raw keyboard events'),
onPressed: () {
Navigator.of(context).push(new MaterialPageRoute(
builder: (context) => KeyboardTestPage()));
},
),
Padding(
padding: const EdgeInsets.all(8.0),
child: Container(
width: 380.0,
height: 100.0,
decoration: BoxDecoration(
border: Border.all(color: Colors.grey, width: 1.0)),
child: Scrollbar(
child: ListView.builder(
padding: EdgeInsets.all(8.0),
itemExtent: 20.0,
itemCount: 50,
itemBuilder: (context, index) {
return Text('entry $index');
},
),
),
),
),
],
),
),
),
);
},
),
floatingActionButton: FloatingActionButton(
onPressed: _AppState.of(context)!.incrementCounter,
tooltip: 'Increment',
child: Icon(Icons.add),
),
);
}
}
/// A widget containing controls to test text input.
class TextInputTestWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Row(
mainAxisAlignment: MainAxisAlignment.center,
children: const <Widget>[
SampleTextField(),
SampleTextField(),
],
);
}
}
/// A text field with styling suitable for including in a TextInputTestWidget.
class SampleTextField extends StatelessWidget {
/// Creates a new sample text field.
const SampleTextField();
@override
Widget build(BuildContext context) {
return Container(
width: 200.0,
padding: const EdgeInsets.all(10.0),
child: TextField(
decoration: InputDecoration(border: OutlineInputBorder()),
),
);
}
}
运行示例应用程序后,点击增量按钮,然后将打印 0 1 2 3 4 以及指向控制台的指针地址。
关于c++ - 在 Flutter Windows 桌面应用程序中使用 C++ DLL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66877095/
我正在通过 labrepl 工作,我看到了一些遵循此模式的代码: ;; Pattern (apply #(apply f %&) coll) ;; Concrete example user=> (a
我从未向应用商店提交过应用,但我会在不久的将来提交。 到目前为止,我对为 iPhone 而非 iPad 进行设计感到很自在。 我了解,通过将通用PAID 应用放到应用商店,客户只需支付一次就可以同时使
我有一个应用程序,它使用不同的 Facebook 应用程序(2 个不同的 AppID)在 Facebook 上发布并显示它是“通过 iPhone”/“通过 iPad”。 当 Facebook 应用程序
我有一个要求,我们必须通过将网站源文件保存在本地 iOS 应用程序中来在 iOS 应用程序 Webview 中运行网站。 Angular 需要服务器来运行应用程序,但由于我们将文件保存在本地,我们无法
所以我有一个单页客户端应用程序。 正常流程: 应用程序 -> OAuth2 服务器 -> 应用程序 我们有自己的 OAuth2 服务器,因此人们可以登录应用程序并获取与用户实体关联的 access_t
假设我有一个安装在用户设备上的 Android 应用程序 A,我的应用程序有一个 AppWidget,我们可以让其他 Android 开发人员在其中以每次安装成本为基础发布他们的应用程序推广广告。因此
Secrets of the JavaScript Ninja中有一个例子它提供了以下代码来绕过 JavaScript 的 Math.min() 函数,该函数需要一个可变长度列表。 Example:
当我分别将数组和对象传递给 function.apply() 时,我得到 NaN 的 o/p,但是当我传递对象和数组时,我得到一个数字。为什么会发生这种情况? 由于数组也被视为对象,为什么我无法使用它
CFSDN坚持开源创造价值,我们致力于搭建一个资源共享平台,让每一个IT人在这里找到属于你的精彩世界. 这篇CFSDN的博客文章ASP转换格林威治时间函数DateDiff()应用由作者收集整理,如果你
我正在将列表传递给 map并且想要返回一个带有合并名称的 data.frame 对象。 例如: library(tidyverse) library(broom) mtcars %>% spl
我有一个非常基本的问题,但我不知道如何实现它:我有一个返回数据框,其中每个工具的返回值是按行排列的: tmp<-as.data.frame(t(data.frame(a=rnorm(250,0,1)
我正在使用我的 FB 应用创建群组并邀请用户加入我的应用群组,第一次一切正常。当我尝试创建另一个组时,出现以下错误: {"(OAuthException - #4009) (#4009) 在有更多用户
我们正在开发一款类似于“会说话的本”应用程序的 child 应用程序。它包含大量用于交互式动画的 JPEG 图像序列。 问题是动画在 iPad Air 上播放正常,但在 iPad 2 上播放缓慢或滞后
我关注 clojure 一段时间了,它的一些功能非常令人兴奋(持久数据结构、函数式方法、不可变状态)。然而,由于我仍在学习,我想了解如何在实际场景中应用,证明其好处,然后演化并应用于更复杂的问题。即,
我开发了一个仅使用挪威语的应用程序。该应用程序不使用本地化,因为它应该仅以一种语言(挪威语)显示。但是,我已在 Info.plist 文件中将“本地化 native 开发区域”设置为“no”。我还使用
读完 Anthony's response 后上a style-related parser question ,我试图说服自己编写单体解析器仍然可以相当紧凑。 所以而不是 reference ::
multicore 库中是否有类似 sapply 的东西?还是我必须 unlist(mclapply(..)) 才能实现这一点? 如果它不存在:推理是什么? 提前致谢,如果这是一个愚蠢的问题,我们深表
我喜欢在窗口中弹出结果,以便更容易查看和查找(例如,它们不会随着控制台继续滚动而丢失)。一种方法是使用 sink() 和 file.show()。例如: y <- rnorm(100); x <- r
我有一个如下所示的 spring mvc Controller @RequestMapping(value="/new", method=RequestMethod.POST) public Stri
我正在阅读 StructureMap关于依赖注入(inject),首先有两部分初始化映射,具体类类型的接口(interface),另一部分只是实例化(请求实例)。 第一部分需要配置和设置,这是在 Bo
我是一名优秀的程序员,十分优秀!