-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathPractice 2.2.Rmd
40 lines (29 loc) · 1.09 KB
/
Practice 2.2.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
---
title: "Practice 2.2"
author: "rpp"
date: "2023-09-19"
output: html_document
---
<<<<<<< HEAD
```{r}
library (tidyr)
library (dplyr)
####testing
#rairuoho<-read.table('D:/R for class/rairuoho.txt',
#header=T, sep='\t', dec='.', na.strings = "n/a")
# read data set from url
rairuoho<-read.table("https://www.dipintothereef.com/uploads/3/7/3/5/37359245/rairuoho.txt",header=T, sep="\t", dec='.')
#Remove variables "row" and "column"
rairuoho$row<-NULL
rairuoho$column<-NULL
#change "nutrient" to "enriched"
rairuoho$treatment<-ifelse(rairuoho$treatment=='nutrient', 'enriched','water')
#Create another variable, "length,", make "day" becomes a single variable
rairuoho_long <- rairuoho%>% pivot_longer(day3:day8,
names_to = ("day"),
values_to = "length")
#rairuoho_rename <-rename(rairuoho_long,c(day=name, lenghth=value))
#Merge variables "Spatial1" and "Spatial2" to create a new variable, "upper_left"
finally <- rairuoho_long %>% unite(upper_left, spatial1, spatial2, sep = " ")
# Display the dataset
finally