/
.Rhistory
111 lines (111 loc) · 4.21 KB
/
.Rhistory
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
library(SURGE)
?check.curves
x<-5
class(x)
is.integer(x)
as.integer(x)
x<-5.3
as.integer(x)
col.names <- c("lm1","lm2","ptswanted")
cdat1<-
read.csv(/Users/felice/Google Drive/NHM/crocs/data/croc_curves_july.csv")
library("tidyverse")
cdat<-read.csv("/Users/felice/Google Drive/NHM/crocs/data/croc_curves_july.csv")
cdat<-read_csv("/Users/felice/Google Drive/NHM/crocs/data/croc_curves_july.csv")
colnames(cdat)
setdiff(col.names, colnames(cdat))
setdiff(colnames(cdat), col.names)
##' Create curve info object
#'
#' @param curvedata a dataframe or tibble with columns "lm1", "lm2" and "ptswanted".
#' @param n_fixed a number indicating how many landmarks are fixed anatomical landmarks
#' @return The sum of \code{x} and \code{y}.
#' @examples
#' my_curvedata <- read_csv("curvedatafile.csv")
#' my_curves <- create_curve_info(curvedata = my_curvedata, n_fixed = 32)
create_curve_info<-function(curvedata, n_fixed){
#define the curves using the 'curvedata' object
if (class(n_fixed) != "numeric"){
stop("n_fixed must be a number")
}
c.names <- c("lm1","lm2","ptswanted")
if (length(setdiff(col.names, colnames(cdat))) != 0)
{stop("curvedata must contain columns lm1 lm2 and ptswanted ")
}
fixed <- c(1:n_fixed)
subsampled.curve<-sapply(paste("SC",c(1:nrow(curvedata)),sep=""),function(x) NULL)
subsampled.curve[[1]]<-c(curvedata$lm1[1],((length(fixed)+1):(length(fixed)+curvedata$ptswanted[1])),curvedata$lm2[1])
for (i in 2:length(subsampled.curve)){
subsampled.curve[[i]]<-c(curvedata$lm1[i],((max(unlist(subsampled.curve))+1):(max(unlist(subsampled.curve))+curvedata$ptswanted[i])),curvedata$lm2[i])
}
subsampled.curve.in<-subsampled.curve
for(i in 1:length(subsampled.curve.in)){
subsampled.curve.in[[i]]<-tail(head(subsampled.curve[[i]],-1),-1)
}
slidings.sub<-c((max(fixed)+1):max(unlist(subsampled.curve)))
list("Curves" = subsampled.curve, "Curve.in" = subsampled.curve.in, "Sliding.LMs" = slidings.sub, "Fixed" = c(1:n_fixed))
}
mycurves <- create_curve_info(cdat, 102)
mycurves
class(mycurves$Sliding.LMs)
library(SURGE)
library(SURGE)
?create_curve_info
library(Morpho)
?placePatch
install.packages("usethis")
library(usethis)
use_readme_rmd(open = interactive())
curve_table<-read_csv("curvedata<-read_csv("~/Google Drive/NHM/crocs/data/croc_curves_july.csv")
curvedata<-read_csv("~/Google Drive/NHM/crocs/data/croc_curves_july.csv")
ptsfolder<-"~/Dropbox/Crocs/pts3"
ptslist <- dir(ptsfolder, pattern='.pts', recursive=F)
ptslist
?create_curve_info
my_curves <- create_curve_info(curve_table, n_fixed = 102)
curve_table<-read_csv("~/Google Drive/NHM/crocs/data/croc_curves_july.csv")
my_curves <- create_curve_info(curve_table, n_fixed = 102)
my_curves
getwd(
)
x1 <- import_chkpt_data(ptslist, my_curves, subsampl = TRUE)
paste0(ptsfolder,ptslist)
x1 <- import_chkpt_data(paste0(ptsfolder,ptslist), my_curves, subsampl = TRUE)
setwd
setwd(ptsfolder)
x1 <- import_chkpt_data(ptslist, my_curves, subsampl = TRUE)
##' Utility function to test whether there are any curves missing from specimens
#'
#' @param lm.tibble a tibble of landmark data
#' @return just used inside of \code{import_chkpt_data} really
check_curves <- function(lm.tibble){
uniques <- lm.tibble %>% group_by(spec.id) %>% filter(class == "C") %>% summarise(Unique_Elements = n_distinct(id))
max_curves <- max(uniques$Unique_Elements)
too_few <- which(uniques$Unique_Elements != max_curves)
if (length(too_few)==0){
writeLines("You have no missing curves! Great job!")
}
else{
for (i in 1:length(too_few)){
name <- uniques$spec.id[too_few[i]]
present <- pts_tibble %>% group_by(spec.id) %>% filter(class == "C") %>% filter(spec.id == name) %>% distinct(id) %>% pull(id) %>% as.vector()
absent <- setdiff(as.character(1:max_curves), present)
writeLines("WARNING!!!!!")
writeLines(paste(name, "is missing curve number", absent))
}
}
}
x1 <- import_chkpt_data(ptslist, my_curves, subsampl = TRUE)
source("~/Google Drive/utlity_scripts/resamplingsV3.R")
x1 <- import_chkpt_data(ptslist, my_curves, subsampl = TRUE)
x1
library(SURGE)
use_gpl3_license(name = find_name())
library(usethis)
use_gpl3_license(name = find_name())
use_gpl3_license()
use_gpl3_license(name = "Ryan Felice")
options(usethis.full_name = "Ryan Felice")`
options(usethis.full_name = "Ryan Felice")
options(usethis.full_name = "Ryan N. Felice")
library(usethis)