library(ggplot2)
p <- ggplot(mtcars, aes(wt, mpg))
p + geom_point(size=4)
Run Code Online (Sandbox Code Playgroud)
假设你有上述内容scatterplot
.如何指定>= 25
将绘制mpg 的点,red
一个between 20 and 25
green
和0-20
blue
?
ggplot
具体可以这样做吗?
有一个帖子,其中熊猫数据帧被转换为字典以供进一步处理.
执行此操作的代码是:
df = pd.read_excel(open('data/file.xlsx', 'rb'), sheetname="Sheet1")
dict = df.set_index('id').T.to_dict('dict')
Run Code Online (Sandbox Code Playgroud)
产生这样的东西: {column -> {index -> value}}
有没有一个快速的方法,而不是这个{column -> {index -> value}}
得到这个:OrderedDict(column, value)
作为一个返回值?
目前,我正在使用从pandas生成的字典,并将这些值逐个分配到有序字典中.这不是最佳方式,因为订单是乱码的
示例输入:这样的Excel文件:
Unique_id | column1 | column2 | column3 | column 4
1 | 3 | 4 | 43 | 90
2 | 54 | 6 | 43 | 54
Run Code Online (Sandbox Code Playgroud)
输出应该是一个有序的字典,如下所示:
{1:[3,4,43,90], 2:[54,6,43,54]}
Run Code Online (Sandbox Code Playgroud) protected enum Category { Action, Fiction, Drama, Romance, SciFi, Poems, Kids }
Run Code Online (Sandbox Code Playgroud)
我创建了这个enum
类型,现在我必须为我的类创建一个构造函数.
public Book(String title, int code, List<String> authors, String publisher, int year, Category categ){
this.title = title;
this.code = code;
this.authors = authors;
this.publisher = publisher;
this.year = year;
this.category = ....;
}
Run Code Online (Sandbox Code Playgroud)
我不明白我将如何向构造函数传递枚举类型的值.
有人可以帮忙吗?
我知道这是初学者的问题,但我似乎无法在任何地方找到答案.
所以我正在尝试为我的数据集生成一些图,但我遇到了某些值的某些问题.
有些值非常小:1.62132528761108e-1916
准确度很小,当它在R上读取时,它变成了0.00000000000e+00
我正在阅读我的数据:
df <- read.table("path/to/file", header = T, sep = ' ', numerals = "no.loss")
Run Code Online (Sandbox Code Playgroud)
即使numerals
标志设置为no.loss
,数字也会变为0.
我怎样才能读出确切的数字?
r ×2
constructor ×1
dictionary ×1
enums ×1
ggplot2 ×1
java ×1
pandas ×1
python ×1
read.table ×1