我是TypeScript的新手.我开始写一本名为Typescript Revealed(Pub Feb.2013)的书.在第2章中有一个名为"Casts"的部分,其中包含以下示例:
var a : int = <int>SomeNumberAsAString;
我试着应用这个例子,如下:
var SomeNumberAsAString = "1000";
var a: int = <int>SomeNumberAsAString;
Run Code Online (Sandbox Code Playgroud)
但编译器给了我一个错误:
hello.ts(2,8):错误TS2304:找不到名称'int'.
hello.ts(2,15):错误TS2304:找不到名称'int'.
我想知道如何进行此演员表,或者是否更改了Typescript的规范?
我试图用透明背景和png格式保存ar情节.我在stackoverflow中遵循了几个推荐的方法,但每次我仍然得到白色背景.我的考试日期如下:
structure(list(wd = c(7.5, 22.5, 37.5, 52.5, 67.5, 82.5, 97.5,
112.5, 127.5, 142.5, 157.5, 172.5, 187.5, 202.5, 217.5, 232.5,
247.5, 262.5, 277.5, 292.5, 307.5, 322.5, 337.5, 352.5), MP1 = c(17.6,
21, 20.5, 26.5, 32.7, 38.3, 40.7, 41.8, 41.6, 44.4, 52.4, 62.5,
70.7, 74.4, 71.1, 66.9, 66.9, 69.4, 69.4, 67.4, 63.4, 55.9, 43.9,
33.9)), .Names = c("wd", "MP1"), class = "data.frame", row.names = c(NA,
-24L))
Run Code Online (Sandbox Code Playgroud)
我尝试了两种方法但都无法删除背景.
方法1:
library(ggplot2)
library(cairo)
ggplot(dat, aes(wd, MP1)) +
coord_polar( start = 0, direction = 1) + …
Run Code Online (Sandbox Code Playgroud) 我试图在同一个图上绘制多组数据.例如,下面,我有两组设置实验:"P-0.1"和"P-0.2",如因子B所示.对于每个实验,我有三个输出值"P","Q","O" ",如因子A所示.我按填充颜色对实验进行分组,并按颜色,线型和形状对输出进行分组.
library(ggplot2)
dat <- data.frame(
A = factor(c("O", "O", "P", "P", "Q", "Q", "O", "O", "P", "P", "Q", "Q"), levels=c("O", "O", "P", "P", "Q", "Q","O", "O", "P", "P", "Q", "Q")),
B = factor(c("P-0.1", "P-0.1", "P-0.1", "P-0.1","P-0.1", "P-0.1", "P-0.2", "P-0.2", "P-0.2", "P-0.2", "P-0.2", "P-0.2"), levels = c("P-0.1", "P-0.1", "P-0.1", "P-0.1","P-0.1", "P-0.1", "P-0.2", "P-0.2", "P-0.2", "P-0.2", "P-0.2", "P-0.2")),
X = c( 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1),
Y = c(10, 15, 12, 13, 9, 14, …
Run Code Online (Sandbox Code Playgroud) 我有一个可能是零的数字.我除以那个数字,所以我想测试它是否为零以防止NaN和无穷大.由于分区内的舍入错误,我是否仍然可以创建NaNs /无穷大?
double x; // might be zero
double y;
if(x != 0) return y / x;
Run Code Online (Sandbox Code Playgroud)
编辑
谢谢你的回复.我会添加一些子问题.
1)假设x和y都不是NaN/+ INF或-INF,会导致-INF/+ INF导致更多的CPU周期或任何其他不希望的行为的分割?(会崩溃吗?)
2)有没有办法防止分裂导致无穷大?使用偏移等.
我正在使用markdown编写我的简历,并希望有多个参考书目部分(一个用于期刊文章,另一个用于书籍章节等).我正在使用该RefManagerR
程序包执行此操作并且它运行良好.
library("RefManageR")
BIB <- structure(list(structure(list(title = "Quantitative palaeotemperature records inferred from fossil pollen and chironomid assemblages from Lake Gilltjarnen, northern central Sweden", author = structure(list(structure(list(given = "K", family = "Antonsson", role = NULL, email = NULL, comment = NULL), .Names = c("given", "family", "role", "email", "comment")), structure(list(given = "SJ", family = "Brooks", role = NULL, email = NULL, comment = NULL), .Names = c("given", "family", "role", "email", "comment")), structure(list(given = "H", family = "Seppa", role = NULL, email …
Run Code Online (Sandbox Code Playgroud) 我获得了一个带有该功能的地图,dismo::gmap()
并希望用ggplot2绘制它,因为我想使用geom_point和其他ggplot函数添加不同的功能.我更喜欢使用dismo::gmap
而不是ggmap::get_map()
下载谷歌地图图层.这是因为dismo::gmap()
,与ggmap::get_map()
包括完整CRS信息的包栅格返回栅格图层不同,因此应该可以修改图层的投影.
> head(data_info$latitude, 20)
#[1] 49.11306 49.39333 48.78083 51.85000 53.57361 50.67806 52.69083 52.21389 53.46361 50.99917 53.99750 53.54528 53.61417 48.00556 48.01306 53.45000
#[17] 51.93667 54.53083 51.95500 54.29639
> head(data_info$longitude, 20)
#[1] 13.134722 12.323056 13.803889 12.177778 14.143611 13.175833 12.649444 13.454167 11.629722 10.906111 11.415556 8.426944 7.160000 11.123889 10.786111
#[16] 12.766667 11.987222 13.091389 10.967500 13.684167
e = extent(-14 , 58 , 28 , 64)
mapImageData2 <- gmap(e, type = c("terrain"), lonlat = TRUE,
path …
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用gganimate
覆盖90年的数据集来创建GIF ,即我希望GIF运行90个州/年.然而,似乎gganimate
只能处理不到50个州.
所以这是一个例子:
library(tidyverse)
# devtools::install_github('thomasp85/gganimate')
library(gganimate)
df = expand.grid( x = 1,
y = c(2,3),
year = 1670:1760) %>% mutate( z = 0.03* year,
u = .2 * year)
Run Code Online (Sandbox Code Playgroud)
这一切都运作49年:
ggplot(data=df %>% filter(., year %in% 1670:1719) , aes()) +
geom_point( aes(x = x, y = y, fill = z, size = u), shape = 21 ) +
labs( title = 'Year: {closest_state}') +
enter_appear() +
transition_states(year, transition_length = 1, state_length = 2)
Run Code Online (Sandbox Code Playgroud)
然而,当我包括50(或更多)年时,它变得奇怪:
ggplot(data=df %>% …
Run Code Online (Sandbox Code Playgroud) 我正在绘制 2013 年、2014 年、2015 年三个不同年份的时间序列。
require(quantmod)
require(ggplot2)
getSymbols("AAPL", from='2013-01-1')
aapl.df = data.frame(date=time(AAPL), coredata(AAPL.Close))
ggplot(data=aapl.df, aes(x=date, y=AAPL.Close, group=1))+geom_line()
Run Code Online (Sandbox Code Playgroud)
如何在 ggplot 中绘制收盘价,以便每年在绘图上都有不同的背景颜色图块?
我正在绘制一张挪威地图,其中一个感兴趣的区域用红色矩形突出显示ggplot2
.如果我省略了geom_rect
或者coord_map
,地图会非常快速地绘制(<1秒).如果我同时使用 - 我需要 - 它的打印和渲染速度极慢(大约五分钟).
我认为这与咀嚼有关 - 将矩形投影到新的坐标系上.有没有办法控制这个?
library(ggplot2)
library(maps)
library(mapdata)
xlim <- c(5, 10)
ylim <- c(60, 62)
norwaymap <- map_data("worldHires", "Norway")
a <- ggplot(norwaymap, aes(x = long, y = lat, group = group)) +
geom_polygon(colour = NA, fill = "grey60") +
geom_rect(xmin = xlim[1], xmax = xlim[2], ymin = ylim[1], ymax = ylim[2],
colour = "red", fill = NA) +
coord_map(xlim = c(3, 33), ylim = c(57, 72))
print(a) # super slow …
Run Code Online (Sandbox Code Playgroud) 什么是"零均值和单位方差"以及如何计算/标准化R中的单列文件?我还想将规范化的值分为两类:
谢谢
r ×8
ggplot2 ×6
c++ ×1
cairo ×1
casting ×1
division ×1
gganimate ×1
google-maps ×1
infinity ×1
nan ×1
plot ×1
quantmod ×1
r-markdown ×1
time-series ×1
typescript ×1