我正在尝试做理论上应该是最简单的事情,但我犯了一些我什至无法理解的错误。
我想在散点图上绘制 $Month 的 $Number of Fatalities(最终绘制 $State 的facet_wrap,但这不是我遇到问题的地方)。
这是我的尝试:
Run Code Online (Sandbox Code Playgroud)library(tidyverse) fatalities <- read.csv(filename.csv) fatalities = as.data.frame(fatalities) ggplot(data = fatalities)+ geom_point(mapping = aes(x = Month, y = Number of Fatalities))
...这是输出:
错误:意外符号:“ggplot(data = fatalities) + geom_point(mapping = aes(x = Month, y = Number of”)
非常感谢您对此问题的帮助或我如何重新表述该问题 - 谢谢!
我有一个如下所示的数据框:
# A tibble: 6 x 4
# Groups: IND_LOC [1]
year_month total_this_month mean_this_month IND_LOC
<S3: yearmon> <dbl> <dbl> <fct>
1 Jan 2013 3960268. 360024. 8_9
2 Feb 2013 3051909. 277446. 8_9
3 Mar 2013 3504636. 318603. 8_9
4 Apr 2013 3234451. 294041. 8_9
5 May 2013 3409146. 284096. 8_9
6 Jun 2013 3619219. 301602. 8_9
Run Code Online (Sandbox Code Playgroud)
最后一列'IND_LOC'有89个唯一值(1_1,1_2 ... 8_9)
我想生成一个与这些'IND_LOC'值对应的时间序列列表,以便它具有以下结构(这只是一个使用不同数据集的示例,用'$ 1_1'代替'$ Germany'等):
> str(time_series)
List of 9
$ Germany : Time-Series [1:52] from 1960 to 2011: 684721 716424 749838 ... …Run Code Online (Sandbox Code Playgroud) 我正在尝试显示此数据集 - > https://mtgjson.com/json/AllSets.json.zip
不过,我想展平数据,以便它不会作为一堆 JSON 数据嵌套在列表中、列表中、列表中。
更具体地说,我试图将数据显示为数据框,按$releaseDate(变量之一)的顺序排列。
到目前为止,这是我的尝试:
library(jsonlite)
library(tidyjson)
mtgdata <- fromJSON("~/path/to/file.json")
Run Code Online (Sandbox Code Playgroud)
mtgdata 的结果显示了这个列表列表:
summary(mtgdata)
Length Class Mode
UST 9 -none- list
UNH 10 -none- list
UGL 11 -none- list
pWOS 8 -none- list
pWOR 8 -none- list
pWCQ 8 -none- list
pSUS 8 -none- list
pSUM 10 -none- list
pREL 8 -none- list
pPRO 8 -none- list
pPRE 8 -none- list
pPOD 7 -none- list
pMPR 8 -none- list
pMGD 8 -none- list
pMEI 8 …Run Code Online (Sandbox Code Playgroud) 您好我想创建只有四家运营商一个简单的计算器+, -, /和*出于某种原因,我的实现不工作。
我已经看到了几种可行的实现方式(包括一些值得混淆的地方),但是我很好奇的是,为什么以下各项无法实现?
#!/usr/bin/perl
my $num1 = $ARGV[0];
my $num2 = $ARGV[2];
my $operator = $ARGV[1];
print "$operator \n";
if($operator == '-')
{
$num3 = $num1 - $num2;
print "$num1 - $num2 = $num3\n";
}
elsif($operator == "+")
{
$num3 = $num1 + $num2;
print "$num1 + $num2 = $num3\n";
}
elsif($operator == "/")
{
$num3 = $num1 / $num2;
print "$num1 / $num2 = $num3\n";
}
elsif($operator == "*")
{ …Run Code Online (Sandbox Code Playgroud)