Skip to content

Commit

Permalink
update fake data format to app requirements
Browse files Browse the repository at this point in the history
  • Loading branch information
Chuck Thompson authored and Chuck Thompson committed Oct 7, 2017
1 parent 4742e1b commit 449bd1f
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions generate_fake_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,32 +8,35 @@ N <- 5 # number of points per individual
lng <- c(13.0, 16.6)
lat <- c(45.4, 46.88)
date <- as.Date(c("01.01.2010", "31.12.2017"), format = "%d.%m.%Y")
type <- c("scat", "urine", "saliva", "tissue")
sample_type <- c("scat", "urine", "saliva", "tissue")
sex <- c("M", "F")

ind.pt <- data.frame(lat = runif(NIND, min = min(lat), max = max(lat)),
lng = runif(NIND, min = min(lng), max = max(lng)))
lng = runif(NIND, min = min(lng), max = max(lng)))

ind.pt <- split(ind.pt, f = 1:nrow(ind.pt))

xy <- sapply(ind.pt, FUN = function(x, N) {
out <- data.frame(lng = rnorm(N, mean = x$lng, sd = 0.05),
lat = rnorm(N, mean = x$lat, sd = 0.05))
out <- data.frame(x = rnorm(N, mean = x$lng, sd = 0.05),
y = rnorm(N, mean = x$lat, sd = 0.05))
tm <- sample(seq(from = min(date), to = max(date), by = "day"), 1)
typ <- sample(type, 5, replace = TRUE)
out$time <- tm + (1:N)
out$type <- typ
typ <- sample(sample_type, 5, replace = TRUE)
sex <- sample(sex, 5, replace = TRUE)
out$date <- tm + (1:N)
out$sample_type <- typ
out$sex <- sex
out
}, N = N, simplify = FALSE)

xy <- do.call(rbind, xy)

xy$animal <- sprintf("%.3d", rep(1:NIND, each = N))
xy$id <- as.character(1:nrow(xy))
xy$sample_name <- as.character(1:nrow(xy))

offspring <- data.frame(sibling = sprintf("%.3d", 5:NIND),
mother = c("001", "002"),
father = c("003", "004"),
cluster = c("1", "2"))
mother = c("001", "002"),
father = c("003", "004"),
cluster = c("1", "2"))

write.table(x = xy, file = "data.csv", sep = ",", row.names = FALSE, quote = FALSE)
write.table(x = offspring, file = "offspring.csv", sep = ",", row.names = FALSE, quote = FALSE)

0 comments on commit 449bd1f

Please sign in to comment.