我用react redux创造了一个tic tac toe游戏.
我正在使用create-react-app.
我有以下商店:
import {createStore, combineReducers} from 'redux';
import gameSettingsReducer from './reducers/gameSettings.js';
import gameStatusReducer from './reducers/gameStatus.js';
const rootReducer = combineReducers({gameSettings: gameSettingsReducer,
gameStatus: gameStatusReducer});
export const defaultGameStatus = {
currentPlayerSymbol: "X",
turnNumber: 0,
currentView: "start-menu", //one of "start-menu", "in-game", "game-over"
winner: "draw", //one of "X", "O", "draw"
board: [["E", "E", "E"],
["E", "E", "E"],
["E", "E", "E"]],
lastMove: []
};
const store = createStore(rootReducer, {
gameSettings:{
playerSymbol: "X", //one of "X", "O"
difficulty: "easy" //one of …Run Code Online (Sandbox Code Playgroud) 当试图绘制这样的东西时:
library(ggplot2)
d <- ggplot(diamonds, aes(carat, price)) +
xlim(0, 2) + geom_point()
d + facet_wrap(~ color)
Run Code Online (Sandbox Code Playgroud)
您会注意到x轴标签仅显示第一列.我希望他们在第二和第三栏重复.这可能吗?
如果在facet_wrap上我使用选项scales ="free",
d + facet_wrap(~ color, scales="free")
Run Code Online (Sandbox Code Playgroud)
然后我在所有图上都得到x轴标签,这也是我不想要的.我只希望底行中的标签重复列
如果要绘制的面板数量是这样的,所有列具有相同数量的绘图,则轴将以我想要的方式重复.但我不能总是拥有适当数量的面板.
我是Sublime Text 2的新手.我想在ST2中编写脚本并运行/发送到R控制台.我不想用SublimeREPL(大多数论坛的解决这个问题),因为我想有我 - [R控制台上的一侧开口.我试图安装"R工具",这个包的安装似乎工作.但是,当我打开我的script.r文件并尝试运行它时,没有任何反应.我还尝试在TOols>构建系统>新构建系统中指定转到R的路径...成功.有人能给我一个解决这个问题的伎俩吗?
非常感谢!
我正在尝试在tkinter中创建一个savefile对话框.我需要保存文件名以便以后使用.但是,我不希望filedialog接受选择已存在的文件名.
到目前为止我只有这个:
from tkinter import filedialog
my_file = filedialog.asksaveasfilename(defaultextension = ".myfile",
filetypes = [("MY SUPER FILE", ".myfile"),
("All files", ".*")])
Run Code Online (Sandbox Code Playgroud)
一种可能性是获取文件名,检查文件名是否存在(使用os.path.isfile),如果已存在具有相同名称的文件,则再次询问用户新名称.但是,tkinter filedialog会询问用户"文件是否已存在.是否要覆盖?".因此,如果稍后我告诉用户我不接受文件名选择,这似乎令人困惑.有没有办法强制tkinter filedialog不要求用户覆盖?
编辑:根据答案中的建议,我尝试创建自己的保存文件对话框.
我基本上只在tkinter保存对话框中添加了一个警告:
class MySaveFileDialog(filedialog.FileDialog):
""" File save dialog that does not allow overwriting of existing file"""
def ok_command(self):
file = self.get_selection()
if os.path.exists(file):
if os.path.isdir(file):
self.master.bell()
return
messagebox.showarning("The current file name already exists. Please give another name to save your file.")
else:
head, tail = os.path.split(file)
if not os.path.isdir(head):
self.master.bell()
return
self.quit(file)
Run Code Online (Sandbox Code Playgroud)
所以,它看起来很简单.然后我想:我需要创建自己的asksaveasfilename …
如何读取R中不属于格式表的文件?
数据包含某些值的空白数据.空白需要有价值.
"关于"和"名称"是唯一永远存在的价值观.
例如,文本文件如下:
Name
Type
Color
About
Spiderman
Marvel
Red
Swings from webs
Superman
DC
Likes to fly around
Hulk
Marvel
Green
I told you not top make him mad.
Batman
Black
He is a good fighter and detective
Martian Manhunter
DC
He is from Mars
Deadpool
Black Red
Kinda Crazy
Run Code Online (Sandbox Code Playgroud)
第一个条目是标题.我想把它变成一个数据框
Name Type Color About
Spiderman Marvel Red Swings from webs
Superman DC Likes to fly around
Hulk Marvel Green I told you not top make him mad. …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用Polymer 项目中的PWA Starter Kit制作一个小应用程序。
是否可以在我的 LitElement 中使用来自https://material.io/develop/web/components/input-controls/text-field/的 Web 组件?我想使用文本区域。
我尝试过的:
import {html, customElement, LitElement} from "lit-element";
//
import {MDCTextField} from '@material/textfield';
@customElement('text-editor')
export class TextEditor extends LitElement {
protected render() {
return html`<div class="mdc-text-field mdc-text-field--textarea">
<textarea id="textarea" class="mdc-text-field__input" rows="8" cols="40"></textarea>
<div class="mdc-notched-outline">
<div class="mdc-notched-outline__leading"></div>
<div class="mdc-notched-outline__notch">
<label for="textarea" class="mdc-floating-label">Textarea Label</label>
</div>
<div class="mdc-notched-outline__trailing"></div>
</div>
</div>`
}
}
Run Code Online (Sandbox Code Playgroud)
但是,因为我不在任何地方使用“MDCTextField”,TypeScript 编译器抱怨“'MDCTextField' 已声明,但它的值从未被读取。”。
我确实在 HTML 中呈现了一个文本区域,但没有应用任何样式。
如何在 LitElement 中重用 MDCTextField Web 组件?
我正在尝试使用包中的cut2()函数来创建基于时间段的因子.Hmisc
这是一些代码:
library(Hmisc)
i.time <- as.POSIXct("2013-07-16 13:55:14 CEST")
f.time <- i.time+as.difftime(1, units="hours")
data.points <- seq(from=i.time, to=f.time, by="1 sec")
cut.points <- seq(from=i.time, to=f.time, by="60 sec")
intervals <- cut2(x=data.points, cuts=cut.points, minmax=TRUE)
Run Code Online (Sandbox Code Playgroud)
我期望创建间隔,使data.point中的每个点都放在一个时间间隔内.但最后有一些NA值:
> tail(intervals, 1)
[1] <NA>
60 Levels: [2013-07-16 13:55:14,2013-07-16 13:56:14) ... [2013-07-16 14:54:14,2013-07-16 14:55:14]
Run Code Online (Sandbox Code Playgroud)
我期待这个选项minmax=TRUE能确保hte cut包含所有的值data.points.
谁能澄清这里发生了什么?如何使用cut2函数生成包含数据中所有值的因子?
我正在使用RStudio将我的R markdown文档编织成一个word文件.
我在文档的开头有这个块:
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE, warnings=FALSE, messages=FALSE, results="hide")
```
Run Code Online (Sandbox Code Playgroud)
但是,在直方图之后我仍然在我的文档中保留这些消息:
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## Warning: Removed 686 rows containing non-finite values (stat_bin).
Run Code Online (Sandbox Code Playgroud)
我怎么能让它们消失?
我在R中有一个向量F2:
Run Code Online (Sandbox Code Playgroud)F2 [,1] [1,] 0.125 [2,] 0.875
当我提示F2 [1]时,我得到0.125.当我提示F2 [2]时,我得到0.875
但是当我提示F2 [1]*F [2]时,我得到NA.
我想知道为什么会这样,以及正确的语法是什么.
我有一组值作为这样的回复。由此
4,0,1581664239228,6,799,0,845,253,0,0,0,0,0,0,0,0,0,0,1448,594,0,1276257,0,0,0,0,1100,0,0,0,0,0,0,0,2047,2158,0,13,1
Run Code Online (Sandbox Code Playgroud)
我必须将这些值映射到一个以下......顺序应该与 version: 4 , build: 0, tuneStartBaseUTCMS: 1581664239228 等相同
version,build,tuneStartBaseUTCMS,ManifestDLStartTime,ManifestDLTotalTime,ManifestDLFailCount,VideoPlaylistDLStartTime,VideoPlaylistDLTotalTime,VideoPlaylistDLFailCount,AudioPlaylistDLStartTime,AudioPlaylistDLTotalTime,AudioPlaylistDLFailCount,VideoInitDLStartTime,VideoInitDLTotalTime,VideoInitDLFailCount,AudioInitDLStartTime,AudioInitDLTotalTime,AudioInitDLFailCount,VideoFragmentDLStartTime,VideoFragmentDLTotalTime,VideoFragmentDLFailCount,VideoBitRate,AudioFragmentDLStartTime,AudioFragmentDLTotalTime,AudioFragmentDLFailCount,AudioBitRate,drmLicenseAcqStartTime,drmLicenseAcqTotalTime,drmFailErrorCode,LicenseAcqPreProcessingDuration,LicenseAcqNetworkDuration,LicenseAcqPostProcDuration,VideoFragmentDecryptDuration,AudioFragmentDecryptDuration,gstPlayStartTime,gstFirstFrameTime,contentType,streamType,firstTune
Run Code Online (Sandbox Code Playgroud)
我写如下...但它不像前那样工作
String abcd = "4,0,1581664239228,6,799,0,845,253,0,0,0,0,0,0,0,0,0,0,1448,594,0,1276257,0,0,0,0,1100,0,0,0,0,0,0,0,2047,2158,0,13,1";
Run Code Online (Sandbox Code Playgroud)
String valueName = "version,build,tuneStartBaseUTCMS,ManifestDLStartTime,ManifestDLTotalTime,ManifestDLFailCount,VideoPlaylistDLStartTime,VideoPlaylistDLTotalTime,VideoPlaylistDLFailCount,AudioPlaylistDLStartTime,AudioPlaylistDLTotalTime,AudioPlaylistDLFailCount,VideoInitDLStartTime,VideoInitDLTotalTime,VideoInitDLFailCount,AudioInitDLStartTime,AudioInitDLTotalTime,AudioInitDLFailCount,VideoFragmentDLStartTime,VideoFragmentDLTotalTime,VideoFragmentDLFailCount,VideoBitRate,AudioFragmentDLStartTime,AudioFragmentDLTotalTime,AudioFragmentDLFailCount,AudioBitRate,drmLicenseAcqStartTime,drmLicenseAcqTotalTime,drmFailErrorCode,LicenseAcqPreProcessingDuration,LicenseAcqNetworkDuration,LicenseAcqPostProcDuration,VideoFragmentDecryptDuration,AudioFragmentDecryptDuration,gstPlayStartTime,gstFirstFrameTime,contentType,streamType,firstTune";
String[] valueArr = abcd.split(",");
String[] valueNameArr = valueName.split(",");
List<String> valueList = Arrays.asList(valueArr);
List<String> valueNameList = Arrays.asList(valueNameArr);
System.out.println(valueList.size() + "jjj: " + "valueNameList::: " + valueNameList.size());
LinkedHashMap<String, String> result = new LinkedHashMap<String, String>();
for (String name : valueNameList) {
System.out.println("name: " + name);
for (String value : valueList) {
System.out.println("value: " + value);
result.put(name, value);
}
}
System.out.println("RESULT::::::::::::::::::::::::::::" + result); …Run Code Online (Sandbox Code Playgroud) r ×6
ggplot2 ×2
hmisc ×1
java ×1
knitr ×1
lit-element ×1
python ×1
python-3.x ×1
react-redux ×1
reactjs ×1
redux ×1
sublimetext2 ×1
tkinter ×1