-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBIODEX_max_torque.Rmd
More file actions
51 lines (45 loc) · 1.21 KB
/
BIODEX_max_torque.Rmd
File metadata and controls
51 lines (45 loc) · 1.21 KB
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
---
title: "BIODEX_max"
author: "Yagi_Masato"
date: "2020/10/31"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
```{r load}
library(xlsx)
library(dplyr)
library(rlist)
# トルク列のデータを取得
fun_load <- function(files_name){
all_data <- read.table(files_name, skip=5, header=T)
torque <<- all_data$N.M
}
```
```{r data-frame}
# データフレーム作成
n <- 2
df <- data.frame(matrix(rep(NA, n), nrow=1))[numeric(0), ]
# カラム名
colnames(df) <- c("File", "MAX")
```
```{r detect_max}
fun_detect <- function(torques){
max_torque <- max(torques)
print(max_torque)
}
```
```{r ref}
setwd("C:/Users/yagin/Desktop/BIODEX")
#上記のディレクトリ内の全てのCSVファイルを列挙
#list all csv files in above directory
files <- list.files(pattern = "\\.txt$")
for (f in 1:length(files)){ #fileの数だけ実行
max_torque <- 0
print(files[f]) #ファイル名を出力
fun_load(files[f]) #各ファイルからトルクを取り出す
fun_detect(torque) #波形データの取り出し
}
write.xlsx(df, "C:/Users/yagin/Desktop/output_max.xlsx", sheetName="Sheet1", col.names=T, row.names=F)
```