-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathtester.Rmd
57 lines (43 loc) · 894 Bytes
/
tester.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
---
title: "Tester"
author: "Emma Rand"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
This file should help you discover if you are set up for the tutorial.
Hit the knit button on bar above.
![knit button](pics/knit.png)
```{r pkgs}
library(reticulate)
library(ggplot2)
library(readxl)
```
```{python mods}
import os
import pandas as pd
# for PCA
from sklearn.decomposition.pca import PCA
# for plotting
import matplotlib.pyplot as plt
```
```{r make-data}
df <- data.frame(x = rnorm(50), y = rnorm(50), gp = rep(c("A","B"), each = 25))
```
```{python calc}
# summarise
r.df.shape
r.df["x"].mean()
r.df["y"].mean()
type(r.df)
```
```{python fig}
a = r.df.loc[r.df['gp'] == "A"]
b = r.df.loc[r.df['gp'] == "B"]
plt.figure()
plt.scatter(a['x'], b['y'], label = "A")
plt.scatter(b['x'], b['y'], label = "B")
plt.legend()
plt.show()
```