R - plot temperature profile over time - r

I have the following data frame containing water temperature measurements for multiple depths and dates:
wtemp <- structure(list(Date = structure(c(12604, 12604, 12604, 12604,
12604, 12604, 12604, 12604, 12604, 12604, 12604, 12604, 12604,
12604, 12604, 12680, 12680, 12680, 12680, 12680, 12680, 12680,
12680, 12680, 12680, 12680, 12680, 12680, 12680, 12680, 12714,
12714, 12714, 12714, 12714, 12714, 12714, 12714, 12714, 12714,
12714, 12714, 12714, 12714, 12714, 12751, 12751, 12751, 12751,
12751, 12751, 12751, 12751, 12751, 12751, 12751, 12751, 12751,
12751, 12751, 12770, 12770, 12770, 12770, 12770, 12770, 12770,
12770, 12770, 12770, 12770, 12770, 12770, 12770, 12770, 12806,
12806, 12806, 12806, 12806, 12806, 12806, 12806, 12806, 12806,
12806, 12806, 12806, 12806, 12806, 12848, 12848, 12848, 12848,
12848, 12848, 12848, 12848, 12848, 12848, 12848, 12848, 12848,
12848, 12848, 12885, 12885, 12885, 12885, 12885, 12885, 12885,
12885, 12885, 12885, 12885, 12885, 12885, 12885, 12885, 12918,
12918, 12918, 12918, 12918, 12918, 12918, 12918, 12918, 12918,
12918, 12918, 12918, 12918, 12918, 12987, 12987, 12987, 12987,
12987, 12987, 12987, 12987, 12987, 12987, 12987, 12987, 12987,
12987, 12987, 13015, 13015, 13015, 13015, 13015, 13015, 13015,
13015, 13015, 13015, 13015, 13015, 13015, 13015, 13015, 13051,
13051, 13051, 13051, 13051, 13051, 13051, 13051, 13051, 13051,
13051, 13051, 13051, 13051, 13051, 13103, 13103, 13103, 13103,
13103, 13103, 13103, 13103, 13103, 13103, 13103, 13103, 13103,
13103, 13103), class = "Date"), Depth = structure(c(1L, 7L, 15L,
16L, 17L, 2L, 3L, 4L, 5L, 6L, 8L, 9L, 10L, 11L, 12L, 1L, 7L,
15L, 16L, 17L, 2L, 3L, 4L, 5L, 6L, 8L, 9L, 10L, 11L, 12L, 1L,
7L, 15L, 16L, 17L, 2L, 3L, 4L, 5L, 6L, 8L, 9L, 10L, 11L, 12L,
1L, 7L, 15L, 16L, 17L, 2L, 3L, 4L, 5L, 6L, 8L, 9L, 10L, 11L,
12L, 1L, 7L, 15L, 16L, 17L, 2L, 3L, 4L, 5L, 6L, 8L, 9L, 10L,
11L, 12L, 1L, 7L, 15L, 16L, 17L, 2L, 3L, 4L, 5L, 6L, 8L, 9L,
10L, 11L, 12L, 1L, 7L, 15L, 16L, 17L, 2L, 3L, 4L, 5L, 6L, 8L,
9L, 10L, 11L, 12L, 1L, 7L, 15L, 16L, 17L, 2L, 3L, 4L, 5L, 6L,
8L, 9L, 10L, 11L, 12L, 1L, 7L, 15L, 16L, 17L, 2L, 3L, 4L, 5L,
6L, 8L, 9L, 10L, 11L, 12L, 1L, 7L, 15L, 16L, 17L, 2L, 3L, 4L,
5L, 6L, 8L, 9L, 10L, 11L, 12L, 1L, 7L, 15L, 16L, 17L, 2L, 3L,
4L, 5L, 6L, 8L, 9L, 10L, 11L, 12L, 1L, 7L, 15L, 16L, 17L, 2L,
3L, 4L, 5L, 6L, 8L, 9L, 10L, 11L, 12L, 1L, 7L, 15L, 16L, 17L,
2L, 3L, 4L, 5L, 6L, 8L, 9L, 10L, 11L, 12L), .Label = c("0", "10",
"12", "14", "16", "18", "2", "20", "22", "24", "26", "28", "30",
"32", "4", "6", "8", "AR"), class = "factor"), T_water = c(33L,
33L, 32L, 32L, 31L, 31L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L,
29L, 32L, 32L, 32L, 32L, 31L, 31L, 30L, 30L, 30L, 30L, 30L, 30L,
30L, 30L, 30L, 33L, 33L, 32L, 32L, 31L, 31L, 30L, 30L, 30L, 30L,
30L, 30L, 30L, 30L, 30L, 32L, 32L, 32L, 31L, 31L, 31L, 31L, 31L,
31L, 31L, 31L, 31L, 31L, 30L, 30L, 31L, 31L, 31L, 31L, 31L, 31L,
31L, 31L, 31L, 31L, 31L, 31L, 31L, 31L, 32L, 30L, 30L, 30L, 30L,
30L, 30L, 30L, 30L, 30L, 31L, 31L, 31L, 31L, 31L, 31L, 30L, 30L,
30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 29L, 29L, 28L, 28L, 28L,
30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L,
30L, 30L, 29L, 29L, 29L, 29L, 29L, 29L, 29L, 29L, 29L, 29L, 29L,
29L, 29L, 29L, 29L, 29L, 29L, 29L, 29L, 29L, 29L, 29L, 29L, 29L,
29L, 29L, 28L, 28L, 28L, 28L, 31L, 31L, 31L, 31L, 30L, 30L, 30L,
30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 32L, 32L, 32L, 32L, 31L,
31L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 33L, 33L, 32L,
32L, 31L, 31L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L)), .Names = c("Date",
"Depth", "T_water"), row.names = c(1L, 2L, 3L, 4L, 5L, 6L, 7L,
8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 17L, 18L, 19L, 20L, 21L,
22L, 23L, 24L, 25L, 26L, 27L, 28L, 29L, 30L, 31L, 33L, 34L, 35L,
36L, 37L, 38L, 39L, 40L, 41L, 42L, 43L, 44L, 45L, 46L, 47L, 49L,
50L, 51L, 52L, 53L, 54L, 55L, 56L, 57L, 58L, 59L, 60L, 61L, 62L,
63L, 65L, 66L, 67L, 68L, 69L, 70L, 71L, 72L, 73L, 74L, 75L, 76L,
77L, 78L, 79L, 81L, 82L, 83L, 84L, 85L, 86L, 87L, 88L, 89L, 90L,
91L, 92L, 93L, 94L, 95L, 97L, 98L, 99L, 100L, 101L, 102L, 103L,
104L, 105L, 106L, 107L, 108L, 109L, 110L, 111L, 113L, 114L, 115L,
116L, 117L, 118L, 119L, 120L, 121L, 122L, 123L, 124L, 125L, 126L,
127L, 131L, 132L, 133L, 134L, 135L, 136L, 137L, 138L, 139L, 140L,
141L, 142L, 143L, 144L, 145L, 149L, 150L, 151L, 152L, 153L, 154L,
155L, 156L, 157L, 158L, 159L, 160L, 161L, 162L, 163L, 167L, 168L,
169L, 170L, 171L, 172L, 173L, 174L, 175L, 176L, 177L, 178L, 179L,
180L, 181L, 185L, 186L, 187L, 188L, 189L, 190L, 191L, 192L, 193L,
194L, 195L, 196L, 197L, 198L, 199L, 203L, 204L, 205L, 206L, 207L,
208L, 209L, 210L, 211L, 212L, 213L, 214L, 215L, 216L, 217L), class = "data.frame")
On the x-axis I need to show the dates, on the y-axis the temperature, and the multiple lines correspond to the depths. Specifically, I am trying to reproduce this figure:
I am trying to use this command:
library(lattice)
xyplot(T_water ~ Date, data = wtemp, type = "l", auto.key=TRUE)
which works only partially. I need to plot the other lines too. It doesn't need to be using lattice, other libraries (such as ggplot2) can be used too.
How to achieve that?
Thanks

Based on the comments, I came out with the following answer:
xyplot(T_water ~ Date, group = Depth, data = wtemp, t='l')
However, the plot had too many lines, and I wanted to keep only depths 0,12 and 24. This is how I've done it:
# Select depths
wtemp <- wtemp[wtemp$Depth %in% c("0","12","24"),]
# Drop old depths
wtemp$Depth <- levels(droplevels(wtemp$Depth))
# Plot new data
xyplot(T_water ~ Date, group = Depth, data = wtemp, t='b',auto.key =list(points = FALSE, columns=3, lines = TRUE))
Thanks to those who helped.

Here is my proposal. I am using the normal plot function and this should work:
# First get a subset of your dataframe of the rows where depth=0
sub <- wtemp[wtemp$Depth==0,]
# Define line colours
colours <- rainbow(14)
# And draw the respective plot
plot(sub$Date,sub$T_water,type="l",col=colours[1], xaxt='n')
# Draw nicer ticks
minDate <- as.Date("2004-07-05")
maxDate <- as.Date("2005-11-16")
axis.Date(1, at=seq(minDate,maxDate ,"month"), format="%m/%d/%Y")
# Loop through all other subsets and create a line which gets added to the plot
for(i in 2:28){
sub <- wtemp[wtemp$Depth==i,]
lines(sub$Date,sub$T_water,col=colours[i/2+1])
}
# Add a legend: http://www.r-bloggers.com/adding-a-legend-to-a-plot/
legend(as.Date("2005-05-05"),33, # legend position
seq(0,28,2), # what to display: values 0 to 28 with an interval of 2
lty=1, # gives the legend appropriate symbols (lines)
lwd=2.5, # line width
col=colours) # gives the legend lines the correct colour as defined above
Update: If you only want to display selected values:
# Define values to display
valueDsp <- c(0,12,24)
# First get a subset of your dataframe of the rows where depth=0
sub <- wtemp[wtemp$Depth==valueDsp[1],]
# Define line colours
colours <- rainbow(length(valueDsp))
# And draw the respective plot
plot(sub$Date,sub$T_water,type="l",col=colours[1], xaxt='n')
# Draw nicer ticks
minDate <- as.Date("2004-07-05")
maxDate <- as.Date("2005-11-16")
axis.Date(1, at=seq(minDate,maxDate ,"month"), format="%m/%d/%Y")
# Loop through all other subsets and create a line which gets added to the plot
for(i in 2:length(valueDsp)){
sub <- wtemp[wtemp$Depth==valueDsp[i],]
lines(sub$Date,sub$T_water,col=colours[i])
}
# Add a legend: http://www.r-bloggers.com/adding-a-legend-to-a-plot/
legend(as.Date("2005-05-05"),33, # legend position
valueDsp, # what to display: values 0 to 28 with an interval of 2
lty=1, # gives the legend appropriate symbols (lines)
lwd=2.5, # line width
col=colours) # gives the legend lines the correct colour as defined above
You can easily adjust the script to change colours, displayed values, legend and so on.
Ps. Are you aware that following months are missing in the dataset:
2004-08
2005-02
2005-06
2005-10
Kind Regards

Related

Loop with multiple subset of data frame

I have a data.frame fish.test0 for which I want to grep specific variables (in varlist) matching the group column to create a sub-data.frame that will undergo a statistical test. The results of the test is saved in tests.res.t. I want to loop the varlist so that I get one results for each input in varlist
Script:
varlist <- c("Abiotrophia","Alphatorquevirus")
for (i in varlist) {
fish.test <- fish.test0[grep("i",fish.test0$group),]
column <- c("ACDC")
tests <- list()
dat_test <- sapply( column, function(colx)
lapply( unique(fish.test$Merge), function(x)
fisher.test( data.frame(
a=c(( fish.test[ which(fish.test$Merge %in% x)[2],"Present"] -
fish.test[ which(fish.test$Merge %in% x)[2], colx] ),fish.test[ which(fish.test$Merge %in% x)[2], colx]
),
b=c(( fish.test[ which(fish.test$Merge %in% x)[1],"NotPresent"] -
fish.test[ which(fish.test$Merge %in% x)[1], colx] ), fish.test[ which(fish.test$Merge %in% x)[1], colx]))) #,alternative = "greater"
) )
rownames(dat_test) <- unique(fish.test$Merge )
colnames(dat_test) <- column
tests.res <- sapply(dat_test[1:dim(dat_test)[1],1], function(x) {
c(x$estimate[1],
x$estimate[2],
ci.lower = x$conf.int[1],
ci.upper = x$conf.int[2],
p.value = x$p.value)
})
tests.res.t <- as.data.frame(t(tests.res))
}
test-data:
fish.test0 <- structure(list(Present = c(4L, 4L, 9L, 9L, 57L, 57L, 146L, 146L,
91L, 91L, 26L, 26L, 6L, 6L, 12L, 12L, 33L, 33L, 10L, 10L, 66L,
66L, 4L, 4L, 4L, 4L, 9L, 9L, 18L, 18L, 19L, 19L, 51L, 51L, 50L,
50L, 12L, 12L, 7L, 7L, 14L, 14L, 27L, 27L, 9L, 9L, 5L, 5L, 6L,
6L, 22L, 22L, 3L, 3L, 14L, 14L, 4L, 4L, 15L, 15L, 6L, 6L, 8L,
8L, 4L, 4L), NotPresent = c(11L, 11L, 44L, 44L, 126L, 126L, 532L,
532L, 382L, 382L, 97L, 97L, 14L, 14L, 43L, 43L, 85L, 85L, 41L,
41L, 336L, 336L, 19L, 19L, 27L, 27L, 67L, 67L, 108L, 108L, 81L,
81L, 240L, 240L, 258L, 258L, 47L, 47L, 31L, 31L, 82L, 82L, 110L,
110L, 63L, 63L, 178L, 178L, 672L, 672L, 451L, 451L, 120L, 120L,
104L, 104L, 47L, 47L, 387L, 387L, 94L, 94L, 300L, 300L, 133L,
133L), group = c("G__Abiotrophia_NotPresent_Anus", "G__Abiotrophia_Present_Anus",
"G__Abiotrophia_NotPresent_Bile duct", "G__Abiotrophia_Present_Bile duct",
"G__Abiotrophia_NotPresent_Bone/Soft tissue", "G__Abiotrophia_Present_Bone/Soft tissue",
"G__Abiotrophia_NotPresent_Breast", "G__Abiotrophia_Present_Breast",
"G__Abiotrophia_NotPresent_Colorectum", "G__Abiotrophia_Present_Colorectum",
"G__Abiotrophia_NotPresent_Esophagus", "G__Abiotrophia_Present_Esophagus",
"G__Abiotrophia_NotPresent_Gallbladder", "G__Abiotrophia_Present_Gallbladder",
"G__Abiotrophia_NotPresent_Head and neck", "G__Abiotrophia_Present_Head and neck",
"G__Abiotrophia_NotPresent_Kidney", "G__Abiotrophia_Present_Kidney",
"G__Abiotrophia_NotPresent_Liver", "G__Abiotrophia_Present_Liver",
"G__Abiotrophia_NotPresent_Lung", "G__Abiotrophia_Present_Lung",
"G__Abiotrophia_NotPresent_Lymphoid tissue", "G__Abiotrophia_Present_Lymphoid tissue",
"G__Abiotrophia_NotPresent_Mesothelium", "G__Abiotrophia_Present_Mesothelium",
"G__Abiotrophia_NotPresent_Nervous system", "G__Abiotrophia_Present_Nervous system",
"G__Abiotrophia_NotPresent_Ovary", "G__Abiotrophia_Present_Ovary",
"G__Abiotrophia_NotPresent_Pancreas", "G__Abiotrophia_Present_Pancreas",
"G__Abiotrophia_NotPresent_Prostate", "G__Abiotrophia_Present_Prostate",
"G__Abiotrophia_NotPresent_Skin", "G__Abiotrophia_Present_Skin",
"G__Abiotrophia_NotPresent_Small intestine", "G__Abiotrophia_Present_Small intestine",
"G__Abiotrophia_NotPresent_Stomach", "G__Abiotrophia_Present_Stomach",
"G__Abiotrophia_NotPresent_Unknown", "G__Abiotrophia_Present_Unknown",
"G__Abiotrophia_NotPresent_Urothelial tract", "G__Abiotrophia_Present_Urothelial tract",
"G__Abiotrophia_NotPresent_Uterus", "G__Abiotrophia_Present_Uterus",
"G__Alphatorquevirus_NotPresent_Bone/Soft tissue", "G__Alphatorquevirus_Present_Bone/Soft tissue",
"G__Alphatorquevirus_NotPresent_Breast", "G__Alphatorquevirus_Present_Breast",
"G__Alphatorquevirus_NotPresent_Colorectum", "G__Alphatorquevirus_Present_Colorectum",
"G__Alphatorquevirus_NotPresent_Esophagus", "G__Alphatorquevirus_Present_Esophagus",
"G__Alphatorquevirus_NotPresent_Kidney", "G__Alphatorquevirus_Present_Kidney",
"G__Alphatorquevirus_NotPresent_Liver", "G__Alphatorquevirus_Present_Liver",
"G__Alphatorquevirus_NotPresent_Lung", "G__Alphatorquevirus_Present_Lung",
"G__Alphatorquevirus_NotPresent_Pancreas", "G__Alphatorquevirus_Present_Pancreas",
"G__Alphatorquevirus_NotPresent_Skin", "G__Alphatorquevirus_Present_Skin",
"G__Alphatorquevirus_NotPresent_Urothelial tract", "G__Alphatorquevirus_Present_Urothelial tract"
), ABCD = c(3L, 2L, 17L, 6L, 34L, 18L, 240L, 53L, 321L, 73L,
87L, 25L, 6L, 3L, 20L, 8L, 15L, 7L, 19L, 4L, 265L, 42L, 6L, 1L,
4L, 2L, 22L, 4L, 70L, 13L, 54L, 12L, 116L, 33L, 58L, 11L, 6L,
2L, 26L, 6L, 42L, 8L, 74L, 18L, 19L, 3L, 52L, 0L, 288L, 5L, 377L,
17L, 110L, 2L, 19L, 3L, 21L, 2L, 298L, 9L, 60L, 6L, 68L, 1L,
89L, 3L), Total = c(15L, 15L, 53L, 53L, 183L, 183L, 678L, 678L,
473L, 473L, 123L, 123L, 20L, 20L, 55L, 55L, 118L, 118L, 51L,
51L, 402L, 402L, 23L, 23L, 31L, 31L, 76L, 76L, 126L, 126L, 100L,
100L, 291L, 291L, 308L, 308L, 59L, 59L, 38L, 38L, 96L, 96L, 137L,
137L, 72L, 72L, 183L, 183L, 678L, 678L, 473L, 473L, 123L, 123L,
118L, 118L, 51L, 51L, 402L, 402L, 100L, 100L, 308L, 308L, 137L,
137L), Merge = c("Abiotrophia_Anus", "Abiotrophia_Anus", "Abiotrophia_Bile duct",
"Abiotrophia_Bile duct", "Abiotrophia_Bone/Soft tissue", "Abiotrophia_Bone/Soft tissue",
"Abiotrophia_Breast", "Abiotrophia_Breast", "Abiotrophia_Colorectum",
"Abiotrophia_Colorectum", "Abiotrophia_Esophagus", "Abiotrophia_Esophagus",
"Abiotrophia_Gallbladder", "Abiotrophia_Gallbladder", "Abiotrophia_Head and neck",
"Abiotrophia_Head and neck", "Abiotrophia_Kidney", "Abiotrophia_Kidney",
"Abiotrophia_Liver", "Abiotrophia_Liver", "Abiotrophia_Lung",
"Abiotrophia_Lung", "Abiotrophia_Lymphoid tissue", "Abiotrophia_Lymphoid tissue",
"Abiotrophia_Mesothelium", "Abiotrophia_Mesothelium", "Abiotrophia_Nervous system",
"Abiotrophia_Nervous system", "Abiotrophia_Ovary", "Abiotrophia_Ovary",
"Abiotrophia_Pancreas", "Abiotrophia_Pancreas", "Abiotrophia_Prostate",
"Abiotrophia_Prostate", "Abiotrophia_Skin", "Abiotrophia_Skin",
"Abiotrophia_Small intestine", "Abiotrophia_Small intestine",
"Abiotrophia_Stomach", "Abiotrophia_Stomach", "Abiotrophia_Unknown",
"Abiotrophia_Unknown", "Abiotrophia_Urothelial tract", "Abiotrophia_Urothelial tract",
"Abiotrophia_Uterus", "Abiotrophia_Uterus", "Alphatorquevirus_Bone/Soft tissue",
"Alphatorquevirus_Bone/Soft tissue", "Alphatorquevirus_Breast",
"Alphatorquevirus_Breast", "Alphatorquevirus_Colorectum", "Alphatorquevirus_Colorectum",
"Alphatorquevirus_Esophagus", "Alphatorquevirus_Esophagus", "Alphatorquevirus_Kidney",
"Alphatorquevirus_Kidney", "Alphatorquevirus_Liver", "Alphatorquevirus_Liver",
"Alphatorquevirus_Lung", "Alphatorquevirus_Lung", "Alphatorquevirus_Pancreas",
"Alphatorquevirus_Pancreas", "Alphatorquevirus_Skin", "Alphatorquevirus_Skin",
"Alphatorquevirus_Urothelial tract", "Alphatorquevirus_Urothelial tract"
)), row.names = c(1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 10L, 9L, 12L,
11L, 13L, 14L, 16L, 15L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L,
25L, 26L, 28L, 27L, 29L, 30L, 31L, 32L, 34L, 33L, 35L, 36L, 38L,
37L, 40L, 39L, 42L, 43L, 45L, 44L, 47L, 46L, 1011L, 1012L, 1014L,
1013L, 1015L, 1016L, 1017L, 1018L, 1019L, 1020L, 1022L, 1021L,
1023L, 1024L, 1026L, 1025L, 1027L, 1028L, 1029L, 1030L), class = "data.frame")
This is probably not an answer but it should help to improve you code. If I'm terribly wrong, I'll remove my answer right away. I have loeft out the test business which I don't understand, but your problem seems to be extraction.
The first thing is that you need to remove the quotation marks in your grep command, try:
varlist <- c("Abiotrophia","Alphatorquevirus")
for( i in varlist )
{
# extract rows which contain the variable
fish.test <- fish.test0[ grep( i, fish.test0$group ), ]
print( head( fish.test ) )
}
From what I understand, you need to define column and tests outside your loop. Does that give you more of what you want:
varlist <- c("Abiotrophia","Alphatorquevirus")
column <- "ACDC"
tests <- list()
for( i in 1 : length( varlist ) ) # index can be used later to fill the list
{
# extract rows which contain the variable
fish.test <- fish.test0[ grep( varlist[ i ], fish.test0$group ), ]
# add a column with your name of choice
fish.test <- cbind( fish.test, c( 1: length( fish.test$group ) ) )
colnames( fish.test )[ length( fish.test ) ] <- column
# write each result into your defined list
tests[[ i ]] <- fish.test
}

Conditional replace values in a column

I am trying to replace some key numbers with their respective people names.
Despite my two attempts, I cannot change the numbers (characters) into names, any suggestions?
Here is what I tried so far:
setDT(df)[person == "447745939698" , person := "John"]
and
df <- df %>% mutate(person=ifelse(person=="447745939698","John",person))
Dataset:
structure(list(person = c("Pavel", "Anna", "Julian", "Bernardo",
"Bryony", "KJ", "Filippo", "Duncan", "‪447761633878‬", "Josh",
"Alex", "Berna", "Melina", "Martha", "‪447999592975‬", "‪48512044757‬",
"Don", "‪447404192025‬", "Sofia", "Jonas", "Chantal", "‪447441458269‬",
"‪447745939698‬", "Sungjoo", "‪447850449670‬", "Blanche",
"Vedo", "‪966554857666‬", "‪447787327724‬", "‪447407102816‬",
"‪447972826119‬", "‪447516428644‬", "‪447973747720‬",
"‪447383865362‬", "‪447478422564‬", "‪447543834973‬",
"Cris", "‪31642688469‬", "‪447921148041‬", "‪447865832098‬",
"Steve", "‪447492829467‬", "Andrea", "‪447878829919‬",
"‪447880747575‬", "‪34635960936‬", "‪447464871555‬",
"‪31640838890‬", "‪46707218515‬", "‪4528822826‬",
"‪393480848355‬", "‪447568552037‬", "‪4580211317‬",
"‪551198299‑2336‬", "‪447935988040‬", "‪447340827646‬"
)), class = c("data.table", "data.frame"), row.names = c(NA,
-56L), index = structure(integer(0), "`__person`" = c(11L,
43L, 2L, 12L, 4L, 26L, 5L, 21L, 37L, 17L, 8L, 7L, 20L, 10L, 3L,
6L, 14L, 13L, 1L, 19L, 41L, 24L, 27L, 48L, 38L, 46L, 51L, 56L,
40L, 34L, 30L, 18L, 47L, 35L, 22L, 42L, 32L, 36L, 52L, 23L, 9L,
29L, 44L, 45L, 25L, 39L, 55L, 31L, 33L, 15L, 50L, 53L, 49L, 16L,
54L, 28L)))

Kendall Correlation P-Value

I want to test correlation for 9 different columns using kendall and extract p-value
for correlation between v9 and 7 other columns (v2 until v8).
Date v1 v2 v3 v4 v5 v6 v7 v8
1 2014-01-05 39 4 84 75 41 6 83 610
2 2014-01-12 40 6 86 77 44 6 84 765
3 2014-01-19 39 5 82 73 40 6 81 713
4 2014-01-26 37 5 100 71 39 6 90 685
5 2014-02-02 39 5 83 70 37 5 79 601
6 2014-02-09 44 6 82 78 40 6 78 535
AllData <- structure(list(Date = structure(c(16075, 16082, 16089, 16096,
16103, 16110, 16117, 16124, 16131, 16138, 16145, 16152, 16159,
16166, 16173, 16180, 16187, 16194, 16201, 16208, 16215, 16222,
16229, 16236, 16243, 16250, 16257, 16264, 16271, 16278, 16285,
16292, 16299, 16306, 16313, 16320, 16327, 16334, 16341, 16348,
16355, 16362, 16369, 16376, 16383, 16390, 16397, 16404, 16411,
16418, 16425, 16432, 16439, 16446, 16453, 16460, 16467, 16474,
16481, 16488, 16495, 16502, 16509, 16516, 16523, 16530, 16537,
16544, 16551, 16558, 16565, 16572, 16579, 16586, 16593, 16600,
16607, 16614, 16621, 16628, 16635, 16642, 16649, 16656, 16663,
16670, 16677, 16684, 16691, 16698, 16705, 16712, 16719, 16726,
16733, 16740, 16747, 16754, 16761, 16768, 16775, 16782, 16789,
16796, 16803, 16810, 16817, 16824, 16831, 16838, 16845, 16852,
16859, 16866, 16873, 16880, 16887, 16894, 16901, 16908, 16915,
16922, 16929, 16936, 16943, 16950, 16957, 16964, 16971, 16978,
16985, 16992, 16999, 17006, 17013, 17020, 17027, 17034, 17041,
17048, 17055, 17062, 17069, 17076, 17083, 17090, 17097, 17104,
17111, 17118, 17125, 17132, 17139, 17146, 17153, 17160, 17167,
17174, 17181, 17188, 17195, 17202, 17209, 17216, 17223, 17230,
17237, 17244, 17251, 17258, 17265, 17272, 17279, 17286, 17293,
17300, 17307, 17314, 17321, 17328, 17335, 17342, 17349, 17356,
17363, 17370, 17377, 17384, 17391, 17398, 17405, 17412, 17419,
17426, 17433, 17440, 17447, 17454, 17461, 17468, 17475, 17482,
17489, 17496, 17503, 17510, 17517, 17524, 17531, 17538, 17545,
17552, 17559, 17566, 17573, 17580, 17587, 17594, 17601, 17608,
17615, 17622, 17629, 17636, 17643, 17650, 17657, 17664, 17671,
17678, 17685, 17692, 17699, 17706, 17713, 17720, 17727, 17734,
17741, 17748, 17755, 17762, 17769, 17776, 17783, 17790, 17797,
17804, 17811, 17818, 17825, 17832, 17839, 17846, 17853, 17860,
17867, 17874, 17881, 17888, 17895, 17902, 17909, 17916, 17923,
17930, 17937, 17944, 17951, 17958, 17965, 17972, 17979, 17986,
17993, 18000, 18007, 18014, 18021, 18028, 18035, 18042, 18049,
18056, 18063, 18070, 18077, 18084, 18091, 18098, 18105, 18112,
18119, 18126, 18133, 18140, 18147, 18154, 18161, 18168, 18175,
18182, 18189, 18196, 18203, 18210, 18217, 18224, 18231, 18238,
18245, 18252, 18259, 18266, 18273, 18280, 18287, 18294, 18301,
18308, 18315), class = "Date"), v1 = c(39L, 40L, 39L, 37L,
39L, 44L, 41L, 40L, 35L, 39L, 35L, 32L, 36L, 34L, 32L, 34L, 32L,
34L, 32L, 30L, 36L, 34L, 35L, 32L, 35L, 32L, 33L, 35L, 35L, 35L,
35L, 36L, 41L, 36L, 34L, 32L, 33L, 30L, 33L, 36L, 34L, 39L, 36L,
34L, 35L, 40L, 46L, 40L, 41L, 44L, 48L, 45L, 32L, 28L, 31L, 29L,
32L, 31L, 33L, 33L, 33L, 31L, 28L, 30L, 29L, 25L, 25L, 25L, 26L,
26L, 24L, 24L, 26L, 25L, 28L, 32L, 32L, 32L, 32L, 35L, 36L, 32L,
31L, 32L, 32L, 35L, 36L, 33L, 30L, 32L, 37L, 42L, 36L, 36L, 33L,
33L, 31L, 46L, 49L, 63L, 77L, 56L, 58L, 57L, 71L, 44L, 36L, 39L,
35L, 35L, 35L, 32L, 33L, 36L, 33L, 33L, 34L, 29L, 30L, 30L, 28L,
27L, 31L, 29L, 28L, 29L, 29L, 100L, 64L, 42L, 48L, 43L, 39L,
36L, 33L, 30L, 32L, 31L, 34L, 34L, 31L, 35L, 35L, 40L, 40L, 40L,
39L, 38L, 50L, 46L, 48L, 47L, 40L, 43L, 43L, 44L, 60L, 54L, 50L,
51L, 61L, 55L, 55L, 62L, 51L, 54L, 51L, 45L, 45L, 46L, 45L, 48L,
47L, 44L, 42L, 42L, 42L, 43L, 44L, 54L, 53L, 48L, 51L, 47L, 45L,
45L, 47L, 49L, 51L, 44L, 43L, 46L, 42L, 46L, 44L, 100L, 62L,
54L, 53L, 45L, 93L, 61L, 76L, 60L, 52L, 53L, 62L, 56L, 54L, 21L,
19L, 21L, 21L, 20L, 82L, 100L, 62L, 38L, 34L, 31L, 35L, 27L,
23L, 21L, 21L, 20L, 21L, 21L, 22L, 22L, 20L, 19L, 20L, 19L, 21L,
20L, 20L, 19L, 21L, 21L, 20L, 18L, 22L, 19L, 18L, 18L, 17L, 20L,
19L, 20L, 21L, 24L, 26L, 25L, 32L, 24L, 25L, 25L, 28L, 27L, 25L,
53L, 53L, 49L, 50L, 49L, 52L, 53L, 58L, 53L, 56L, 52L, 50L, 49L,
52L, 62L, 46L, 45L, 52L, 41L, 45L, 50L, 48L, 48L, 49L, 50L, 50L,
47L, 49L, 44L, 54L, 100L, 67L, 58L, 45L, 60L, 51L, 56L, 50L,
50L, 48L, 48L, 49L, 48L, 54L, 57L, 67L, 74L, 58L, 60L, 64L, 77L,
70L, 82L, 72L, 77L, 74L, 67L, 79L, 74L, 88L), v2 = c(4L,
6L, 5L, 5L, 5L, 6L, 5L, 5L, 4L, 4L, 5L, 5L, 6L, 6L, 6L, 5L, 5L,
5L, 5L, 4L, 5L, 5L, 4L, 6L, 5L, 4L, 5L, 5L, 6L, 4L, 4L, 4L, 5L,
5L, 5L, 5L, 4L, 5L, 6L, 5L, 6L, 6L, 4L, 6L, 6L, 6L, 6L, 5L, 6L,
4L, 7L, 6L, 5L, 5L, 7L, 5L, 5L, 5L, 5L, 4L, 5L, 5L, 4L, 5L, 4L,
4L, 6L, 4L, 4L, 4L, 4L, 4L, 5L, 5L, 3L, 5L, 4L, 4L, 4L, 5L, 4L,
4L, 4L, 5L, 4L, 4L, 4L, 5L, 5L, 5L, 5L, 4L, 4L, 5L, 5L, 4L, 6L,
5L, 7L, 7L, 5L, 7L, 9L, 7L, 6L, 6L, 5L, 5L, 5L, 4L, 6L, 5L, 6L,
4L, 5L, 5L, 5L, 4L, 4L, 5L, 4L, 5L, 4L, 4L, 4L, 5L, 3L, 5L, 4L,
5L, 4L, 5L, 4L, 4L, 5L, 4L, 5L, 4L, 5L, 4L, 4L, 4L, 4L, 5L, 5L,
5L, 5L, 5L, 4L, 4L, 7L, 6L, 5L, 4L, 5L, 7L, 8L, 8L, 8L, 8L, 7L,
7L, 8L, 8L, 8L, 8L, 7L, 7L, 7L, 7L, 7L, 7L, 6L, 5L, 7L, 8L, 6L,
6L, 6L, 6L, 6L, 6L, 8L, 7L, 7L, 8L, 7L, 8L, 8L, 6L, 7L, 6L, 6L,
8L, 7L, 7L, 7L, 6L, 7L, 8L, 8L, 8L, 10L, 8L, 5L, 7L, 7L, 9L,
8L, 3L, 2L, 3L, 3L, 3L, 3L, 3L, 4L, 3L, 3L, 3L, 4L, 3L, 3L, 3L,
3L, 3L, 3L, 2L, 2L, 2L, 2L, 3L, 3L, 2L, 2L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 4L, 2L, 3L, 3L, 2L, 3L, 4L, 4L, 4L, 4L, 3L,
3L, 4L, 4L, 5L, 4L, 8L, 7L, 8L, 7L, 5L, 7L, 8L, 8L, 7L, 7L, 7L,
9L, 6L, 9L, 8L, 6L, 6L, 8L, 7L, 7L, 8L, 7L, 7L, 7L, 8L, 7L, 7L,
6L, 7L, 7L, 8L, 6L, 7L, 6L, 8L, 6L, 5L, 9L, 6L, 8L, 7L, 6L, 6L,
7L, 6L, 7L, 8L, 8L, 8L, 7L, 10L, 10L, 10L, 11L, 11L, 10L, 9L,
10L, 10L, 9L), v3 = c(84L, 86L, 82L, 100L, 83L, 82L,
76L, 74L, 81L, 72L, 67L, 66L, 67L, 64L, 67L, 61L, 67L, 63L, 59L,
60L, 57L, 54L, 60L, 59L, 53L, 61L, 61L, 57L, 59L, 63L, 60L, 56L,
60L, 64L, 57L, 55L, 58L, 61L, 56L, 63L, 65L, 63L, 59L, 64L, 60L,
62L, 70L, 65L, 65L, 61L, 71L, 69L, 54L, 59L, 54L, 55L, 55L, 56L,
74L, 100L, 86L, 69L, 54L, 55L, 48L, 47L, 48L, 48L, 46L, 44L,
42L, 45L, 43L, 48L, 46L, 43L, 45L, 44L, 52L, 47L, 50L, 49L, 47L,
47L, 50L, 49L, 51L, 47L, 45L, 45L, 49L, 53L, 55L, 56L, 52L, 52L,
51L, 64L, 67L, 73L, 78L, 65L, 76L, 74L, 62L, 57L, 52L, 75L, 54L,
47L, 52L, 52L, 49L, 42L, 45L, 43L, 45L, 42L, 44L, 41L, 40L, 38L,
39L, 41L, 42L, 43L, 39L, 60L, 50L, 49L, 52L, 51L, 46L, 47L, 42L,
44L, 45L, 44L, 47L, 44L, 49L, 43L, 50L, 47L, 48L, 52L, 53L, 51L,
64L, 57L, 60L, 52L, 45L, 48L, 49L, 56L, 81L, 71L, 61L, 68L, 69L,
67L, 69L, 61L, 68L, 69L, 63L, 63L, 61L, 59L, 78L, 60L, 56L, 57L,
57L, 54L, 52L, 48L, 53L, 49L, 50L, 53L, 58L, 55L, 61L, 52L, 57L,
55L, 57L, 51L, 51L, 52L, 54L, 58L, 58L, 80L, 67L, 62L, 60L, 60L,
65L, 64L, 78L, 70L, 63L, 68L, 67L, 75L, 66L, 27L, 26L, 26L, 27L,
24L, 30L, 35L, 33L, 31L, 28L, 28L, 30L, 28L, 26L, 23L, 22L, 21L,
22L, 21L, 20L, 22L, 20L, 20L, 21L, 20L, 24L, 21L, 21L, 22L, 23L,
22L, 24L, 25L, 20L, 22L, 23L, 22L, 20L, 21L, 22L, 22L, 23L, 25L,
25L, 25L, 33L, 28L, 25L, 28L, 27L, 29L, 30L, 58L, 57L, 60L, 58L,
56L, 60L, 59L, 57L, 56L, 60L, 55L, 55L, 54L, 50L, 53L, 55L, 48L,
50L, 53L, 47L, 46L, 51L, 52L, 55L, 61L, 60L, 51L, 51L, 57L, 53L,
71L, 67L, 58L, 56L, 93L, 71L, 66L, 68L, 60L, 62L, 61L, 56L, 57L,
61L, 64L, 64L, 75L, 65L, 64L, 69L, 78L, 84L, 100L, 91L, 94L,
86L, 83L, 89L, 89L, 87L), v4 = c(75L, 77L, 73L, 71L, 70L,
78L, 76L, 72L, 71L, 72L, 75L, 75L, 70L, 74L, 72L, 74L, 74L, 73L,
69L, 74L, 72L, 71L, 74L, 72L, 72L, 82L, 74L, 83L, 78L, 73L, 73L,
80L, 88L, 88L, 74L, 68L, 70L, 76L, 72L, 76L, 75L, 76L, 71L, 77L,
96L, 85L, 100L, 90L, 81L, 80L, 87L, 86L, 81L, 77L, 81L, 74L,
73L, 74L, 76L, 71L, 84L, 79L, 74L, 74L, 72L, 80L, 72L, 73L, 70L,
69L, 69L, 77L, 72L, 77L, 72L, 77L, 77L, 85L, 77L, 74L, 77L, 77L,
76L, 77L, 75L, 77L, 79L, 73L, 71L, 73L, 78L, 78L, 76L, 74L, 74L,
75L, 81L, 86L, 95L, 91L, 85L, 83L, 90L, 92L, 72L, 67L, 72L, 77L,
68L, 64L, 68L, 73L, 75L, 71L, 71L, 70L, 69L, 72L, 68L, 67L, 65L,
65L, 63L, 64L, 64L, 67L, 64L, 80L, 73L, 70L, 100L, 73L, 78L,
62L, 63L, 66L, 60L, 61L, 61L, 62L, 61L, 73L, 71L, 70L, 69L, 67L,
67L, 68L, 64L, 73L, 75L, 70L, 67L, 64L, 68L, 76L, 71L, 73L, 75L,
71L, 74L, 68L, 68L, 72L, 71L, 70L, 69L, 69L, 69L, 71L, 73L, 73L,
68L, 71L, 68L, 64L, 65L, 73L, 66L, 67L, 69L, 72L, 80L, 66L, 69L,
68L, 66L, 72L, 67L, 75L, 75L, 69L, 70L, 68L, 69L, 83L, 70L, 70L,
71L, 73L, 76L, 77L, 82L, 74L, 71L, 70L, 71L, 77L, 71L, 66L, 65L,
74L, 68L, 66L, 79L, 82L, 79L, 71L, 73L, 75L, 79L, 80L, 76L, 71L,
70L, 74L, 70L, 72L, 75L, 71L, 71L, 70L, 74L, 72L, 83L, 68L, 71L,
82L, 79L, 72L, 70L, 67L, 66L, 66L, 65L, 68L, 68L, 65L, 63L, 65L,
68L, 73L, 69L, 74L, 77L, 68L, 67L, 65L, 67L, 72L, 74L, 75L, 74L,
76L, 73L, 72L, 73L, 77L, 75L, 71L, 73L, 73L, 71L, 72L, 74L, 70L,
66L, 72L, 72L, 70L, 67L, 69L, 69L, 75L, 73L, 75L, 83L, 71L, 69L,
66L, 66L, 79L, 74L, 67L, 64L, 68L, 70L, 67L, 68L, 73L, 70L, 73L,
72L, 69L, 77L, 77L, 76L, 82L, 77L, 73L, 71L, 79L, 84L, 84L, 74L,
76L, 72L, 73L, 76L, 75L, 73L), v5 = c(41L, 44L, 40L, 39L,
37L, 40L, 40L, 42L, 39L, 37L, 39L, 37L, 36L, 34L, 34L, 35L, 35L,
32L, 33L, 33L, 32L, 32L, 31L, 30L, 32L, 32L, 30L, 31L, 32L, 34L,
33L, 34L, 35L, 44L, 36L, 39L, 35L, 35L, 35L, 32L, 34L, 36L, 36L,
35L, 36L, 36L, 44L, 39L, 38L, 42L, 44L, 44L, 39L, 39L, 39L, 39L,
37L, 37L, 39L, 38L, 39L, 36L, 35L, 34L, 33L, 32L, 28L, 31L, 29L,
27L, 29L, 30L, 31L, 29L, 29L, 32L, 33L, 34L, 30L, 32L, 35L, 32L,
32L, 34L, 32L, 33L, 33L, 32L, 31L, 30L, 33L, 37L, 32L, 33L, 32L,
32L, 34L, 41L, 45L, 48L, 56L, 47L, 52L, 51L, 44L, 35L, 34L, 34L,
33L, 30L, 32L, 31L, 31L, 30L, 28L, 29L, 29L, 27L, 26L, 26L, 24L,
24L, 24L, 25L, 23L, 25L, 25L, 41L, 35L, 28L, 32L, 31L, 32L, 29L,
29L, 27L, 27L, 27L, 26L, 24L, 24L, 26L, 27L, 27L, 29L, 30L, 30L,
29L, 32L, 31L, 37L, 33L, 31L, 30L, 32L, 32L, 32L, 30L, 30L, 29L,
31L, 31L, 31L, 32L, 30L, 30L, 29L, 28L, 28L, 27L, 27L, 26L, 27L,
25L, 27L, 24L, 23L, 23L, 25L, 25L, 27L, 27L, 28L, 25L, 24L, 25L,
26L, 25L, 26L, 24L, 24L, 24L, 23L, 25L, 25L, 37L, 29L, 28L, 29L,
27L, 33L, 33L, 38L, 33L, 31L, 31L, 32L, 35L, 31L, 28L, 28L, 30L,
29L, 29L, 34L, 43L, 42L, 37L, 34L, 32L, 36L, 31L, 29L, 28L, 27L,
28L, 26L, 24L, 25L, 25L, 24L, 24L, 24L, 25L, 25L, 23L, 25L, 26L,
26L, 24L, 24L, 24L, 24L, 24L, 23L, 23L, 23L, 24L, 22L, 25L, 25L,
26L, 28L, 28L, 34L, 30L, 28L, 29L, 31L, 31L, 31L, 33L, 32L, 32L,
34L, 32L, 33L, 34L, 34L, 33L, 35L, 34L, 32L, 31L, 29L, 30L, 28L,
28L, 28L, 28L, 27L, 28L, 28L, 29L, 28L, 29L, 28L, 27L, 27L, 27L,
27L, 37L, 32L, 31L, 30L, 30L, 30L, 34L, 30L, 30L, 30L, 30L, 30L,
29L, 31L, 32L, 33L, 39L, 33L, 32L, 34L, 37L, 40L, 37L, 36L, 38L,
38L, 36L, 38L, 38L, 39L), v6 = c(6L, 6L, 6L, 6L, 5L,
6L, 7L, 6L, 6L, 5L, 6L, 5L, 4L, 5L, 5L, 5L, 5L, 4L, 4L, 5L, 5L,
5L, 5L, 5L, 5L, 6L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 6L, 5L, 6L,
6L, 5L, 6L, 6L, 6L, 6L, 7L, 6L, 6L, 8L, 7L, 7L, 7L, 7L, 7L, 5L,
5L, 6L, 6L, 5L, 5L, 5L, 5L, 5L, 5L, 4L, 5L, 5L, 5L, 5L, 5L, 4L,
4L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 6L, 5L, 5L, 6L, 5L, 6L, 5L, 5L,
5L, 6L, 6L, 6L, 5L, 6L, 7L, 6L, 7L, 6L, 6L, 6L, 7L, 9L, 7L, 7L,
8L, 8L, 8L, 6L, 5L, 5L, 6L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L,
5L, 5L, 5L, 5L, 5L, 4L, 5L, 5L, 4L, 4L, 4L, 5L, 5L, 5L, 5L, 4L,
5L, 5L, 5L, 5L, 5L, 5L, 6L, 5L, 5L, 5L, 5L, 5L, 6L, 6L, 6L, 5L,
6L, 9L, 7L, 7L, 6L, 6L, 6L, 7L, 6L, 6L, 6L, 5L, 5L, 5L, 5L, 6L,
6L, 5L, 6L, 6L, 6L, 6L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 6L, 6L, 6L,
6L, 7L, 6L, 7L, 6L, 6L, 5L, 6L, 5L, 5L, 5L, 6L, 6L, 6L, 6L, 7L,
6L, 7L, 7L, 6L, 7L, 10L, 7L, 7L, 7L, 7L, 8L, 7L, 6L, 6L, 5L,
5L, 5L, 5L, 6L, 5L, 5L, 5L, 5L, 6L, 5L, 5L, 5L, 5L, 4L, 5L, 5L,
5L, 4L, 4L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L,
4L, 5L, 5L, 5L, 5L, 6L, 6L, 6L, 6L, 6L, 9L, 7L, 7L, 7L, 6L, 7L,
6L, 7L, 6L, 7L, 8L, 7L, 7L, 6L, 6L, 6L, 6L, 6L, 6L, 5L, 6L, 5L,
5L, 5L, 5L, 5L, 5L, 6L, 5L, 5L, 5L, 5L, 6L, 6L, 6L, 6L, 6L, 5L,
6L, 6L, 6L, 6L, 6L, 7L, 6L, 7L, 6L, 8L, 8L, 7L, 7L, 7L, 7L, 10L,
8L, 8L, 7L, 8L, 8L, 7L, 7L, 7L, 7L, 6L, 6L, 7L, 6L), v7 = c(83L,
84L, 81L, 90L, 79L, 78L, 78L, 81L, 78L, 75L, 76L, 77L, 75L, 77L,
79L, 82L, 85L, 81L, 80L, 81L, 81L, 82L, 85L, 80L, 77L, 82L, 83L,
76L, 73L, 74L, 78L, 73L, 77L, 74L, 72L, 70L, 72L, 73L, 70L, 70L,
72L, 75L, 74L, 73L, 73L, 77L, 82L, 81L, 79L, 82L, 86L, 86L, 85L,
79L, 79L, 77L, 76L, 75L, 75L, 78L, 78L, 77L, 74L, 72L, 68L, 69L,
72L, 69L, 72L, 71L, 71L, 72L, 69L, 69L, 72L, 71L, 70L, 72L, 75L,
73L, 74L, 72L, 74L, 75L, 71L, 71L, 73L, 72L, 71L, 70L, 72L, 73L,
72L, 75L, 76L, 76L, 75L, 80L, 83L, 100L, 95L, 84L, 84L, 89L,
76L, 69L, 68L, 67L, 66L, 64L, 67L, 69L, 64L, 63L, 63L, 67L, 66L,
65L, 69L, 64L, 62L, 62L, 63L, 63L, 60L, 63L, 66L, 69L, 64L, 67L,
68L, 63L, 64L, 63L, 61L, 61L, 57L, 64L, 61L, 68L, 65L, 74L, 67L,
66L, 67L, 73L, 69L, 68L, 64L, 68L, 72L, 73L, 69L, 72L, 75L, 80L,
94L, 83L, 81L, 79L, 76L, 72L, 73L, 74L, 74L, 72L, 69L, 70L, 78L,
78L, 81L, 76L, 75L, 76L, 75L, 73L, 74L, 73L, 73L, 72L, 75L, 72L,
76L, 70L, 71L, 70L, 71L, 70L, 69L, 66L, 66L, 63L, 70L, 68L, 68L,
79L, 72L, 75L, 78L, 75L, 75L, 77L, 79L, 82L, 85L, 82L, 83L, 87L,
100L, 89L, 86L, 81L, 84L, 78L, 83L, 92L, 100L, 90L, 87L, 81L,
82L, 79L, 79L, 79L, 81L, 79L, 79L, 76L, 78L, 74L, 73L, 68L, 73L,
71L, 73L, 71L, 72L, 69L, 73L, 70L, 71L, 69L, 73L, 70L, 70L, 73L,
73L, 73L, 69L, 73L, 74L, 76L, 75L, 76L, 77L, 79L, 81L, 78L, 82L,
81L, 94L, 100L, 93L, 91L, 88L, 86L, 90L, 83L, 82L, 82L, 81L,
81L, 82L, 84L, 82L, 81L, 80L, 82L, 81L, 81L, 80L, 78L, 77L, 75L,
72L, 75L, 72L, 73L, 75L, 73L, 75L, 83L, 78L, 77L, 77L, 77L, 75L,
78L, 80L, 77L, 73L, 79L, 79L, 76L, 88L, 91L, 90L, 80L, 82L, 82L,
82L, 85L, 99L, 100L, 97L, 91L, 89L, 82L, 85L, 82L, 83L), v8 = c(610L,
765L, 713L, 685L, 601L, 535L, 582L, 568L, 502L, 608L, 653L, 672L,
694L, 697L, 715L, 751L, 675L, 706L, 777L, 787L, 876L, 823L, 754L,
782L, 834L, 907L, 890L, 913L, 921L, 977L, 890L, 947L, 996L, 830L,
974L, 921L, 912L, 907L, 871L, 805L, 876L, 909L, 861L, 865L, 901L,
742L, 726L, 720L, 803L, 796L, 857L, 902L, 751L, 806L, 859L, 798L,
714L, 728L, 688L, 728L, 785L, 1166L, 1105L, 935L, 1037L, 1016L,
1037L, 932L, 1013L, 996L, 1016L, 1064L, 1104L, 1003L, 1051L,
913L, 944L, 1044L, 1018L, 1073L, 1109L, 1055L, 1076L, 1008L,
1016L, 996L, 1050L, 1030L, 969L, 1011L, 932L, 890L, 978L, 1008L,
928L, 1006L, 927L, 913L, 905L, 952L, 957L, 978L, 978L, 1044L,
1341L, 966L, 881L, 1052L, 981L, 864L, 927L, 887L, 943L, 1055L,
1010L, 1012L, 1059L, 913L, 1028L, 1060L, 1046L, 1061L, 1043L,
1027L, 1094L, 1065L, 1070L, 1000L, 1079L, 1114L, 1156L, 1069L,
1157L, 1234L, 1217L, 1216L, 1190L, 1208L, 1253L, 1182L, 1133L,
1046L, 1122L, 1013L, 1185L, 1208L, 1177L, 1227L, 1080L, 1197L,
1123L, 1260L, 1101L, 1139L, 1054L, 1222L, 1262L, 1158L, 1241L,
1190L, 1087L, 1155L, 1122L, 1159L, 1044L, 999L, 993L, 1193L,
1229L, 1217L, 1301L, 1239L, 1179L, 1092L, 1226L, 1211L, 1236L,
1327L, 1133L, 1149L, 1198L, 1158L, 1312L, 1183L, 1165L, 1163L,
1226L, 1136L, 1130L, 1129L, 1092L, 1039L, 1019L, 1196L, 1155L,
1169L, 1130L, 1185L, 1166L, 1174L, 1048L, 1083L, 1048L, 1161L,
997L, 1041L, 1123L, 895L, 1034L, 1095L, 1080L, 1223L, 1074L,
954L, 948L, 1011L, 982L, 1013L, 1078L, 1080L, 1055L, 1131L, 1145L,
999L, 1213L, 1192L, 1144L, 1082L, 1137L, 1150L, 1104L, 1059L,
1039L, 1099L, 1202L, 1092L, 1072L, 1126L, 1086L, 1098L, 1131L,
1071L, 1122L, 1061L, 988L, 1043L, 760L, 1073L, 950L, 1001L, 960L,
1034L, 919L, 922L, 944L, 996L, 970L, 996L, 996L, 1058L, 1235L,
964L, 1043L, 979L, 865L, 1012L, 906L, 987L, 925L, 847L, 1012L,
1011L, 1065L, 987L, 1078L, 1025L, 1010L, 1045L, 981L, 987L, 1125L,
1184L, 1070L, 995L, 1139L, 1205L, 1286L, 1180L, 1210L, 1147L,
1221L, 1112L, 1151L, 1117L, 1097L, 1066L, 1059L, 1050L, 1040L,
976L, 992L, 979L, 949L, 954L, 932L, 873L, 1015L, 982L, 982L,
1010L, 897L, 1056L, 1217L, 977L, 986L, 1004L, 906L, 890L, 877L,
894L, 672L)), row.names = c(NA, -321L), class = "data.frame")
x <- AllData[2:9]
y <- AllData[2:9]
correlationcoef <- data.frame(cor(x,y,method="kendall"))
I used the above code to run the data but it only gives me the correlation coefficient,
not the p-value that I needed. I also need to store this value into one data frame so
that I will be able to evaluate all correlations in one go.
One could use a loop, but another approach to getting the p-values of the kendall correlation test is to use the rstatix package to create a correlation matrix and a corresponding p-value matrix:
library(rstatix)
# sample data
AllData <- data.frame(
Date = c("2014-01-05", "2014-01-12","2014-01-19", "2014-01-26","2014-02-02", "2014-02-09"),
v1 = c(39,40,39,37,39,44),
v2 = c(4,6,5,5,5,6),
v3 = c(84,86,82,100,83,82),
v4 = c(75,77,73,71,70,78),
v5 = c(41,44,40,39,37,40),
v6 = c(6,6,6,6,5,6),
v7 = c(83,84,81,90,79,78),
v8 = c(610,765,713,685,601,535)
)
# get the correlation matrix
corMatrix <- AllData %>% cor_mat(v1:v8, method = "kendall")
corMatrix
# get the p.values
corMatrix_p <- corMatrix %>% cor_get_pval()
corMatrix_p
And you can specify the variables you want to include in the matrix with the varsargument:
cor_mat(data, ..., vars = NULL, method = "pearson", alternative =
"two.sided", conf.level = 0.95)
Just set vars equal to a character vector of the variable names. In other words, you could also do this:
corMatrix <- AllData %>% cor_mat(c("v1","v2","v3","v4","v5","v6","v7","v8"), method = "kendall")
corMatrix
# get the p.values
corMatrix_p <- corMatrix %>% cor_get_pval()
corMatrix_p

Subtract Values based on Multiple Grouping Factors

I have a dataset with phosphorus concentrations for 17 separate days (concentrations are cumulative, so increase from Day1 to Day102 in all cases). There are 22 different treatments (column = Trmt). Each Trmt has 3 Levels (Level = X, Y, Z). 2 measurements per Level for a total of 6 per Trmt.
My goal is to plot a 3-line graph of Days (x-axis; numeric) by Concentration (y-axis) using ggplot2. Data should be grouped by Trmt, Level and day for a total of 51 measurements (3 lines x 17 days).
My data looks as follows:
structure(list(Trmt = structure(c(2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 4L, 4L, 4L, 4L, 4L, 4L, 3L, 3L, 3L, 3L, 3L, 3L, 6L, 6L, 6L, 6L, 6L, 6L, 5L, 5L, 5L, 5L, 5L, 5L, 8L, 8L, 8L, 8L, 8L, 8L, 7L, 7L, 7L, 7L, 7L, 7L, 10L, 10L, 10L, 10L, 10L, 10L, 9L, 9L, 9L, 9L, 9L, 9L, 12L, 12L, 12L, 12L, 12L, 12L, 11L, 11L, 11L, 11L, 11L, 11L, 14L, 14L, 14L, 14L, 14L, 14L, 13L, 13L, 13L, 13L, 13L, 13L, 16L, 16L, 16L, 16L, 16L, 16L, 15L, 15L, 15L, 15L, 15L, 15L, 18L, 18L, 18L, 18L, 18L, 18L, 17L, 17L, 17L, 17L, 17L, 17L, 20L, 20L, 20L, 20L, 20L, 20L, 19L, 19L, 19L, 19L, 19L, 19L, 22L, 22L, 22L, 22L, 22L, 22L, 21L, 21L, 21L, 21L, 21L, 21L), .Label = c("A01nF", "A01yT", "A02nF", "A02yT", "A03nF", "A03yT", "A04nF", "A04yT", "A05nF", "A05yT", "A06nF", "A06yT", "A07nF", "A07yT", "A08nF", "A08yT", "A10nF", "A10yT", "A11nF", "A11yT", "A13nF", "A13yT"), class = "factor"), Level = structure(c(1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L), .Label = c("X", "Y", "Z"), class = "factor"), Day1 = c(3L, 1L, 4L, 2L, 4L, 2L, 5L, 4L, 1L, 2L, 5L, 1L, 5L, 2L, 5L, 5L, 3L, 5L, 3L, 3L, 1L, 4L, 1L, 1L, 5L, 4L, 1L, 5L, 4L, 5L, 3L, 5L, 3L, 5L, 3L, 4L, 2L, 4L, 2L, 4L, 3L, 1L, 1L, 3L, 1L, 3L, 1L, 5L, 2L, 4L, 4L, 3L, 1L, 4L, 4L, 1L, 4L, 1L, 2L, 5L, 1L, 5L, 1L, 2L, 4L, 4L, 4L, 4L, 2L, 4L, 5L, 5L, 4L, 1L, 3L, 2L, 3L, 5L, 4L, 3L, 2L, 3L, 5L, 4L, 1L, 3L, 4L, 3L, 3L, 5L, 3L, 1L, 1L, 4L, 4L, 5L, 1L, 4L, 4L, 4L, 1L, 4L, 5L, 5L, 1L, 5L, 3L, 1L, 4L, 1L, 4L, 5L, 5L, 3L, 3L, 2L, 4L, 5L, 3L, 2L, 1L, 5L, 5L, 2L, 2L, 3L, 4L, 3L, 4L, 2L, 2L, 4L), Day2 = c(10L, 9L, 7L, 7L, 6L, 7L, 10L, 9L, 10L, 6L, 10L, 7L, 8L, 9L, 8L, 9L, 7L, 10L, 7L, 10L, 6L, 8L, 6L, 8L, 8L, 8L, 10L, 6L, 8L, 8L, 6L, 10L, 7L, 10L, 7L, 10L, 6L, 6L, 7L, 9L, 8L, 10L, 8L, 7L, 9L, 8L, 6L, 9L, 7L, 9L, 8L, 6L, 6L, 8L, 10L, 7L, 8L, 6L, 8L, 8L, 6L, 9L, 10L, 6L, 8L, 7L, 9L, 7L, 8L, 10L, 10L, 6L, 7L, 10L, 9L, 9L, 8L, 9L, 6L, 8L, 6L, 8L, 6L, 9L, 10L, 7L, 7L, 7L, 8L, 7L, 8L, 10L, 7L, 8L, 9L, 6L, 8L, 9L, 8L, 9L, 6L, 7L, 10L, 9L, 10L, 7L, 6L, 9L, 9L, 9L, 6L, 10L, 9L, 8L, 9L, 7L, 10L, 7L, 10L, 9L, 6L, 8L, 9L, 8L, 9L, 6L, 6L, 10L, 9L, 8L, 8L, 7L), Day4 = c(11L, 12L, 14L, 11L, 15L, 15L, 12L, 11L, 15L, 12L, 15L, 12L, 12L, 11L, 15L, 15L, 13L, 11L, 13L, 14L, 12L, 11L, 13L, 12L, 15L, 15L, 14L, 11L, 15L, 11L, 12L, 11L, 13L, 11L, 12L, 13L, 13L, 14L, 13L, 15L, 14L, 15L, 12L, 14L, 11L, 13L, 15L, 11L, 12L, 13L, 11L, 15L, 11L, 13L, 11L, 11L, 14L, 12L, 14L, 15L, 11L, 12L, 15L, 12L, 13L, 12L, 14L, 12L, 11L, 13L, 12L, 12L, 11L, 15L, 13L, 12L, 11L, 12L, 13L, 14L, 14L, 14L, 13L, 12L, 15L, 12L, 15L, 15L, 12L, 13L, 12L, 12L, 12L, 14L, 13L, 13L, 14L, 11L, 12L, 11L, 15L, 11L, 11L, 11L, 14L, 11L, 12L, 15L, 15L, 11L, 12L, 14L, 15L, 14L, 14L, 12L, 14L, 13L, 15L, 15L, 14L, 13L, 12L, 15L, 15L, 11L, 13L, 12L, 11L, 13L, 12L, 14L), Day7 = c(19L, 17L, 17L, 20L, 17L, 19L, 18L, 19L, 17L, 20L, 16L, 20L, 19L, 18L, 20L, 19L, 17L, 16L, 18L, 18L, 17L, 18L, 19L, 18L, 17L, 19L, 17L, 20L, 19L, 20L, 19L, 20L, 17L, 18L, 20L, 19L, 20L, 18L, 18L, 20L, 18L, 20L, 17L, 19L, 17L, 19L, 17L, 17L, 20L, 18L, 18L, 17L, 16L, 18L, 20L, 16L, 17L, 19L, 16L, 19L, 16L, 17L, 16L, 20L, 16L, 19L, 19L, 17L, 17L, 17L, 20L, 19L, 18L, 16L, 20L, 17L, 19L, 16L, 18L, 19L, 16L, 19L, 20L, 20L, 16L, 16L, 18L, 17L, 16L, 18L, 16L, 17L, 16L, 18L, 20L, 16L, 16L, 20L, 20L, 16L, 20L, 18L, 17L, 19L, 18L, 18L, 19L, 19L, 16L, 18L, 19L, 19L, 17L, 17L, 18L, 18L, 20L, 18L, 20L, 20L, 18L, 19L, 19L, 16L, 16L, 17L, 20L, 16L, 17L, 18L, 16L, 20L), Day10 = c(24L, 23L, 23L, 21L, 21L, 23L, 21L, 21L, 22L, 25L, 21L, 23L, 21L, 25L, 25L, 25L, 24L, 22L, 25L, 24L, 21L, 23L, 24L, 23L, 23L, 22L, 23L, 22L, 22L, 25L, 25L, 22L, 21L, 24L, 25L, 23L, 23L, 23L, 24L, 23L, 25L, 23L, 21L, 23L, 22L, 24L, 22L, 23L, 24L, 22L, 25L, 23L, 23L, 21L, 25L, 24L, 24L, 25L, 25L, 25L, 22L, 23L, 21L, 22L, 24L, 22L, 23L, 22L, 24L, 22L, 21L, 22L, 23L, 21L, 25L, 25L, 22L, 21L, 25L, 24L, 22L, 21L, 25L, 24L, 21L, 24L, 25L, 22L, 23L, 22L, 24L, 23L, 25L, 25L, 23L, 25L, 22L, 23L, 23L, 23L, 22L, 25L, 22L, 23L, 24L, 25L, 22L, 21L, 21L, 22L, 23L, 24L, 21L, 24L, 23L, 23L, 25L, 24L, 25L, 23L, 22L, 25L, 25L, 25L, 21L, 22L, 23L, 21L, 24L, 24L, 25L, 21L), Day13 = c(29L, 29L, 26L, 27L, 30L, 30L, 30L, 26L, 30L, 29L, 30L, 27L, 26L, 29L, 28L, 26L, 30L, 28L, 29L, 27L, 28L, 26L, 29L, 28L, 30L, 26L, 27L, 30L, 26L, 29L, 26L, 28L, 29L, 28L, 29L, 28L, 27L, 27L, 28L, 26L, 26L, 27L, 27L, 29L, 27L, 29L, 27L, 30L, 26L, 27L, 30L, 26L, 29L, 29L, 27L, 29L, 26L, 29L, 28L, 28L, 29L, 30L, 28L, 30L, 30L, 30L, 28L, 29L, 28L, 27L, 28L, 27L, 27L, 28L, 27L, 30L, 27L, 30L, 27L, 28L, 29L, 27L, 30L, 29L, 30L, 30L, 26L, 30L, 29L, 30L, 27L, 26L, 27L, 27L, 28L, 26L, 30L, 28L, 30L, 30L, 30L, 30L, 26L, 28L, 27L, 26L, 29L, 26L, 29L, 26L, 30L, 29L, 30L, 26L, 27L, 30L, 29L, 30L, 27L, 30L, 28L, 26L, 30L, 27L, 30L, 26L, 28L, 29L, 26L, 28L, 28L, 26L), Day18 = c(32L, 31L, 32L, 31L, 31L, 34L, 32L, 34L, 32L, 33L, 31L, 34L, 35L, 34L, 34L, 32L, 33L, 35L, 32L, 35L, 31L, 31L, 33L, 33L, 32L, 31L, 32L, 31L, 32L, 34L, 33L, 33L, 34L, 31L, 35L, 35L, 31L, 34L, 32L, 32L, 34L, 33L, 34L, 33L, 33L, 35L, 35L, 31L, 35L, 31L, 33L, 34L, 31L, 33L, 34L, 32L, 32L, 33L, 31L, 32L, 35L, 34L, 31L, 32L, 34L, 35L, 34L, 31L, 34L, 33L, 35L, 35L, 31L, 32L, 35L, 34L, 31L, 32L, 32L, 33L, 32L, 35L, 32L, 32L, 35L, 33L, 34L, 32L, 34L, 35L, 34L, 33L, 33L, 31L, 31L, 31L, 35L, 34L, 33L, 32L, 33L, 33L, 33L, 35L, 34L, 33L, 31L, 34L, 34L, 34L, 34L, 33L, 33L, 31L, 31L, 31L, 33L, 33L, 35L, 32L, 32L, 31L, 31L, 32L, 33L, 32L, 34L, 34L, 31L, 35L, 31L, 35L), Day23 = c(39L, 40L, 38L, 37L, 37L, 38L, 37L, 36L, 37L, 36L, 36L, 38L, 40L, 38L, 37L, 36L, 36L, 40L, 40L, 40L, 40L, 39L, 40L, 36L, 38L, 36L, 36L, 37L, 38L, 37L, 36L, 37L, 39L, 39L, 38L, 38L, 37L, 40L, 36L, 38L, 37L, 40L, 36L, 37L, 39L, 38L, 38L, 38L, 40L, 38L, 37L, 36L, 38L, 36L, 36L, 36L, 39L, 40L, 39L, 37L, 39L, 39L, 37L, 36L, 37L, 39L, 39L, 37L, 36L, 37L, 40L, 36L, 39L, 40L, 39L, 40L, 39L, 38L, 39L, 40L, 37L, 40L, 38L, 38L, 38L, 40L, 40L, 36L, 39L, 39L, 39L, 39L, 38L, 37L, 37L, 36L, 37L, 39L, 37L, 40L, 40L, 40L, 38L, 38L, 39L, 38L, 36L, 37L, 36L, 36L, 40L, 39L, 39L, 39L, 36L, 39L, 38L, 40L, 36L, 37L, 38L, 38L, 36L, 37L, 39L, 36L, 40L, 40L, 39L, 38L, 37L, 38L), Day28 = c(42L, 43L, 43L, 44L, 44L, 44L, 42L, 42L, 43L, 42L, 45L, 43L, 43L, 43L, 42L, 44L, 42L, 44L, 45L, 44L, 44L, 45L, 44L, 41L, 41L, 42L, 44L, 44L, 44L, 45L, 43L, 42L, 43L, 42L, 41L, 44L, 43L, 43L, 42L, 42L, 44L, 42L, 42L, 42L, 45L, 44L, 45L, 42L, 43L, 45L, 45L, 44L, 41L, 42L, 42L, 41L, 44L, 44L, 44L, 44L, 42L, 45L, 41L, 42L, 45L, 43L, 44L, 45L, 44L, 42L, 41L, 43L, 41L, 44L, 43L, 41L, 45L, 42L, 45L, 41L, 45L, 41L, 45L, 42L, 45L, 42L, 45L, 45L, 41L, 41L, 43L, 41L, 41L, 42L, 43L, 41L, 42L, 44L, 43L, 45L, 41L, 41L, 44L, 41L, 44L, 43L, 43L, 45L, 44L, 41L, 44L, 43L, 42L, 45L, 45L, 41L, 45L, 42L, 41L, 44L, 41L, 41L, 41L, 43L, 41L, 41L, 45L, 41L, 42L, 45L, 41L, 44L), Day35 = c(50L, 50L, 50L, 50L, 48L, 46L, 50L, 46L, 48L, 50L, 50L, 50L, 46L, 49L, 46L, 47L, 49L, 49L, 48L, 49L, 46L, 47L, 49L, 46L, 49L, 50L, 49L, 46L, 49L, 50L, 46L, 48L, 50L, 46L, 50L, 48L, 46L, 48L, 50L, 50L, 47L, 47L, 47L, 47L, 47L, 49L, 48L, 46L, 46L, 48L, 50L, 46L, 49L, 48L, 46L, 49L, 50L, 49L, 48L, 48L, 48L, 50L, 49L, 47L, 48L, 50L, 50L, 46L, 47L, 46L, 48L, 48L, 48L, 47L, 49L, 48L, 49L, 46L, 47L, 50L, 47L, 50L, 47L, 47L, 46L, 46L, 47L, 50L, 49L, 49L, 48L, 47L, 46L, 50L, 46L, 50L, 50L, 46L, 47L, 47L, 49L, 50L, 50L, 46L, 47L, 50L, 47L, 48L, 46L, 50L, 49L, 46L, 46L, 50L, 50L, 49L, 46L, 49L, 46L, 46L, 46L, 48L, 47L, 47L, 50L, 47L, 46L, 48L, 50L, 48L, 46L, 46L), Day42 = c(52L, 51L, 53L, 53L, 54L, 55L, 55L, 54L, 52L, 51L, 55L, 51L, 54L, 53L, 53L, 55L, 54L, 55L, 51L, 51L, 55L, 54L, 54L, 53L, 55L, 53L, 52L, 53L, 53L, 51L, 54L, 54L, 55L, 53L, 54L, 55L, 51L, 51L, 54L, 52L, 51L, 51L, 55L, 54L, 54L, 52L, 52L, 55L, 55L, 51L, 55L, 52L, 55L, 51L, 53L, 52L, 53L, 54L, 51L, 54L, 54L, 55L, 52L, 54L, 52L, 52L, 51L, 52L, 55L, 52L, 54L, 51L, 52L, 55L, 51L, 52L, 55L, 54L, 52L, 53L, 53L, 52L, 55L, 51L, 51L, 55L, 52L, 55L, 55L, 55L, 53L, 52L, 53L, 54L, 52L, 52L, 52L, 52L, 53L, 51L, 54L, 54L, 51L, 53L, 55L, 51L, 54L, 54L, 54L, 53L, 53L, 54L, 54L, 55L, 52L, 52L, 54L, 51L, 52L, 51L, 51L, 55L, 52L, 51L, 51L, 53L, 54L, 51L, 51L, 54L, 55L, 52L), Day52 = c(59L, 57L, 56L, 58L, 59L, 59L, 57L, 59L, 57L, 56L, 58L, 58L, 60L, 59L, 56L, 56L, 60L, 57L, 60L, 57L, 59L, 56L, 60L, 59L, 59L, 56L, 60L, 58L, 60L, 57L, 57L, 60L, 56L, 57L, 59L, 60L, 56L, 58L, 57L, 57L, 58L, 58L, 59L, 56L, 58L, 56L, 57L, 60L, 58L, 59L, 58L, 56L, 56L, 57L, 60L, 59L, 60L, 58L, 59L, 60L, 57L, 60L, 59L, 57L, 60L, 56L, 57L, 56L, 58L, 60L, 56L, 58L, 56L, 60L, 57L, 57L, 57L, 60L, 58L, 59L, 58L, 60L, 59L, 58L, 56L, 56L, 58L, 57L, 60L, 56L, 58L, 56L, 57L, 58L, 58L, 60L, 59L, 60L, 59L, 59L, 59L, 57L, 57L, 60L, 59L, 57L, 57L, 58L, 59L, 57L, 59L, 58L, 60L, 59L, 56L, 57L, 57L, 56L, 57L, 60L, 58L, 57L, 56L, 59L, 59L, 59L, 57L, 57L, 58L, 56L, 58L, 60L), Day62 = c(67L, 65L, 68L, 65L, 69L, 70L, 69L, 66L, 65L, 70L, 70L, 65L, 67L, 68L, 65L, 67L, 65L, 66L, 66L, 68L, 68L, 66L, 65L, 67L, 66L, 69L, 69L, 69L, 68L, 67L, 66L, 69L, 65L, 65L, 69L, 66L, 69L, 68L, 69L, 67L, 65L, 69L, 69L, 69L, 70L, 67L, 65L, 65L, 65L, 66L, 66L, 69L, 68L, 66L, 67L, 66L, 70L, 70L, 70L, 69L, 70L, 70L, 67L, 66L, 65L, 69L, 67L, 66L, 70L, 70L, 70L, 65L, 66L, 67L, 66L, 66L, 67L, 68L, 70L, 67L, 69L, 66L, 67L, 65L, 70L, 65L, 70L, 66L, 66L, 69L, 68L, 65L, 65L, 67L, 68L, 67L, 69L, 68L, 69L, 66L, 68L, 70L, 69L, 68L, 70L, 66L, 69L, 66L, 66L, 67L, 65L, 69L, 69L, 67L, 70L, 65L, 70L, 69L, 66L, 68L, 67L, 68L, 66L, 65L, 67L, 70L, 66L, 67L, 66L, 67L, 67L, 70L), Day72 = c(74L, 74L, 71L, 75L, 74L, 71L, 75L, 71L, 75L, 71L, 72L, 72L, 75L, 73L, 75L, 74L, 74L, 74L, 71L, 74L, 72L, 71L, 71L, 74L, 74L, 73L, 72L, 73L, 71L, 71L, 75L, 72L, 73L, 74L, 75L, 73L, 71L, 71L, 74L, 71L, 73L, 75L, 75L, 74L, 71L, 75L, 74L, 72L, 72L, 71L, 72L, 75L, 73L, 74L, 71L, 75L, 75L, 73L, 72L, 73L, 73L, 72L, 75L, 72L, 71L, 72L, 73L, 72L, 72L, 74L, 72L, 72L, 73L, 75L, 74L, 75L, 73L, 74L, 75L, 72L, 75L, 73L, 71L, 71L, 72L, 74L, 72L, 75L, 71L, 71L, 71L, 73L, 72L, 71L, 75L, 75L, 74L, 73L, 71L, 71L, 72L, 71L, 71L, 74L, 72L, 73L, 71L, 75L, 74L, 75L, 74L, 73L, 73L, 73L, 72L, 75L, 73L, 71L, 71L, 72L, 72L, 71L, 71L, 71L, 72L, 73L, 75L, 75L, 72L, 73L, 75L, 75L), Day82 = c(76L, 78L, 78L, 78L, 79L, 77L, 78L, 77L, 80L, 79L, 80L, 76L, 76L, 80L, 80L, 80L, 78L, 78L, 78L, 78L, 80L, 78L, 76L, 79L, 76L, 77L, 76L, 79L, 78L, 76L, 76L, 79L, 79L, 77L, 77L, 77L, 78L, 78L, 80L, 77L, 77L, 76L, 77L, 79L, 78L, 78L, 78L, 80L, 79L, 76L, 79L, 77L, 76L, 80L, 78L, 77L, 79L, 80L, 77L, 80L, 78L, 79L, 78L, 76L, 76L, 79L, 77L, 77L, 78L, 78L, 79L, 78L, 78L, 78L, 80L, 79L, 78L, 77L, 78L, 78L, 78L, 79L, 80L, 77L, 77L, 80L, 77L, 80L, 77L, 76L, 77L, 76L, 77L, 77L, 80L, 79L, 77L, 78L, 80L, 80L, 79L, 80L, 79L, 79L, 78L, 76L, 76L, 79L, 79L, 80L, 79L, 78L, 76L, 79L, 77L, 77L, 76L, 76L, 78L, 78L, 79L, 78L, 76L, 78L, 79L, 76L, 77L, 78L, 76L, 79L, 78L, 77L), Day92 = c(85L, 84L, 85L, 85L, 83L, 82L, 83L, 82L, 85L, 85L, 82L, 85L, 85L, 85L, 81L, 81L, 84L, 81L, 85L, 82L, 85L, 84L, 81L, 82L, 83L, 82L, 84L, 84L, 81L, 85L, 83L, 85L, 82L, 81L, 83L, 83L, 85L, 83L, 81L, 83L, 82L, 84L, 83L, 83L, 82L, 85L, 85L, 82L, 82L, 82L, 85L, 81L, 81L, 82L, 82L, 84L, 81L, 85L, 81L, 82L, 81L, 81L, 85L, 83L, 81L, 83L, 83L, 84L, 83L, 85L, 85L, 83L, 81L, 85L, 81L, 84L, 83L, 83L, 85L, 83L, 82L, 82L, 82L, 83L, 82L, 83L, 81L, 84L, 83L, 84L, 82L, 83L, 81L, 83L, 81L, 82L, 82L, 82L, 85L, 85L, 84L, 81L, 81L, 81L, 84L, 81L, 84L, 81L, 81L, 84L, 84L, 83L, 83L, 82L, 82L, 81L, 85L, 85L, 82L, 83L, 81L, 83L, 82L, 84L, 83L, 82L, 84L, 81L, 83L, 82L, 84L, 85L), Day102 = c(89L, 88L, 88L, 90L, 88L, 90L, 87L, 88L, 89L, 87L, 90L, 86L, 86L, 89L, 86L, 89L, 90L, 88L, 87L, 88L, 88L, 87L, 90L, 86L, 90L, 87L, 88L, 89L, 88L, 90L, 88L, 87L, 89L, 90L, 88L, 87L, 89L, 88L, 87L, 86L, 90L, 86L, 89L, 89L, 90L, 88L, 90L, 86L, 88L, 88L, 90L, 89L, 88L, 88L, 90L, 87L, 88L, 88L, 87L, 90L, 89L, 87L, 90L, 90L, 86L, 87L, 86L, 90L, 88L, 87L, 86L, 88L, 90L, 86L, 89L, 90L, 87L, 87L, 88L, 86L, 86L, 89L, 89L, 86L, 87L, 86L, 86L, 88L, 88L, 88L, 89L, 90L, 88L, 86L, 88L, 88L, 87L, 88L, 90L, 89L, 89L, 86L, 90L, 89L, 89L, 88L, 90L, 88L, 86L, 90L, 90L, 87L, 89L, 90L, 90L, 88L, 88L, 89L, 90L, 88L, 90L, 90L, 87L, 89L, 90L, 90L, 90L, 89L, 86L, 88L, 89L, 88L)), class = "data.frame", row.names = c(NA, -132L))
Required libraries:
tidyr, plyr, ggplot2
The steps that I have taken so far are to:
Convert the data to long format (df = name of dataset):
Fig1 <- gather(df, day, phosphorus, Day1:Day102, factor_key=TRUE)
Change the factor day to numeric
df$day2 <-revalue(df$day, c("Day1"="1", "Day2"="2", "Day4"="4", "Day7"="7", "Day10"="10", "Day13"="13", "Day18"="18", "Day23" = "23","Day28" = "28", "Day35" = "35", "Day42" = "42", "Day52" = "52", "Day62" = "62", "Day72" = "72", "Day82" = "82", Day92" = "92", "Day102" = "102"))
and
df$day3 <- as.numeric(as.character(df$day2))
Group by Trmt, Level and day3
GroupedDF <- df %>% group_by(Trmt, Level, day3)
GroupedCO2M <- GroupedDF %>% summarise(disp = mean(phosphorus))
I would now like to subtract values by accounting for Trmt and Level, thus reducing the number of rows from 102 to 51. I would like to subtract 'yT' Trmt cases from respective 'nF' cases, uniquely for each Level (X, Y and Z). For example, subtract A01yT_X from A01nf_X, A01yT_Y from A01nf_Y, A01yT_Z from A01nf_Z etc. This should give a total of 51 points, 17 for each Level.
Here is a figure of what I have in mind:
Many thanks for any advice.
thanks for sharing the data. The data you have posted is a bit long, hence might not be able to totally copy and paste
Your data is in the wide format, and you need to find the average for each measurement between similar groups (defined by Day, Level, Treatment). So we can work on this in the wide format:
tmp <- Data %>% group_by(Trmt,Level) %>% summarise_all(mean)
> head(tmp)
# A tibble: 6 x 19
# Groups: Trmt [2]
Trmt Level Day1 Day2 Day4 Day7 Day10 Day13 Day18 Day23 Day28 Day35 Day42
<fct> <fct> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
1 A01nF X 3.5 8 12 19 23 29.5 32.5 36.5 42 50 53
2 A01nF Y 4.5 9.5 13 17.5 21 28 32.5 36 43.5 48 54.5
3 A01nF Z 1 8.5 13.5 18.5 22.5 28.5 33 37.5 43 49 51.5
4 A01yT X 2.5 8.5 11 19.5 22.5 28 31.5 38 43 50 52.5
5 A01yT Y 2.5 7.5 13.5 17 22 29.5 31 38.5 43.5 49 52.5
6 A01yT Z 3 7 14.5 18 23 28 33 38 43.5 48 54
This gives you the average for each Trmt,Level, and each column (Day) is average separately. Next step is to define the 2 subgroups under Trmt (nF and yT for A01,A02..), and for this we can introduce a subgroup called "site", which is Trmt without the nF,yT. Once you group your data.frame with this "site" and level, the first row will always be nF, and 2nd row yT, so taking the diff for all your Day columns within this grouping, will give you the difference. So we do it like this:
# need to ungroup Trmt to remove it later
tmp <- tmp%>% ungroup(Trmt) %>%
mutate(site = sub("[yn][TF]","",Trmt)) %>%
select(-Trmt) %>%
group_by(site,Level) %>%
summarize_all(diff)
Now you have the nF - yT values for each treatment, each level and each day
> head(tmp)
# A tibble: 6 x 19
# Groups: site [2]
site Level Day1 Day2 Day4 Day7 Day10 Day13 Day18 Day23 Day28 Day35 Day42
<chr> <fct> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
1 A01 X -1 0.5 -1 0.5 -0.5 -1.5 -1 1.5 1 0 -0.5
2 A01 Y -2 -2 0.5 -0.5 1 1.5 -1.5 2.5 0 1 -2
3 A01 Z 2 -1.5 1 -0.5 0.5 -0.5 0 0.5 0.5 -1 2.5
4 A02 X 1.5 1 1.5 1 -1 -1.5 2 -1.5 -1.5 -1 2
5 A02 Y 0.5 0 -1.5 -1 0.5 1.5 -0.5 -3 -1.5 0 1
6 A02 Z 4 2 1 0.5 1.5 0 2.5 0.5 0.5 1.5 0
Come the last part, which is to plot. We convert it to long and also make "Day", a numeric form of day.
plotdf <- gather(tmp, day, Diff, Day1:Day102, factor_key=TRUE) %>%
mutate(Day=as.numeric(sub("Day","",day)))
# and plot
ggplot(plotdf,aes(x=Day,y=Diff,col=Level,shape=Level)) + geom_line() + geom_point() + facet_wrap(~site) + scale_color_manual(values=c("grey10","grey40","grey80"))
Plot above shows the difference for each site. For diff that is the average across all sites:
meandf <- plotdf %>% group_by(Level,Day) %>% summarize(Diff=mean(Diff))
ggplot(meandf,aes(x=Day,y=Diff,col=Level,shape=Level)) + geom_line() + geom_point() + scale_color_manual(values=c("grey10","grey40","grey80"))
example dataset, subsetted for Day1, Day2 and Day4
Data <- structure(list(Trmt = structure(c(2L, 2L, 2L, 2L, 2L, 2L, 1L,
1L, 1L, 1L, 1L, 1L, 4L, 4L, 4L, 4L, 4L, 4L, 3L, 3L, 3L, 3L, 3L,
3L, 6L, 6L, 6L, 6L, 6L, 6L, 5L, 5L, 5L, 5L, 5L, 5L, 8L, 8L, 8L,
8L, 8L, 8L, 7L, 7L, 7L, 7L, 7L, 7L, 10L, 10L, 10L, 10L, 10L,
10L, 9L, 9L, 9L, 9L, 9L, 9L, 12L, 12L, 12L, 12L, 12L, 12L, 11L,
11L, 11L, 11L, 11L, 11L, 14L, 14L, 14L, 14L, 14L, 14L, 13L, 13L,
13L, 13L, 13L, 13L, 16L, 16L, 16L, 16L, 16L, 16L, 15L, 15L, 15L,
15L, 15L, 15L, 18L, 18L, 18L, 18L, 18L, 18L, 17L, 17L, 17L, 17L,
17L, 17L, 20L, 20L, 20L, 20L, 20L, 20L, 19L, 19L, 19L, 19L, 19L,
19L, 22L, 22L, 22L, 22L, 22L, 22L, 21L, 21L, 21L, 21L, 21L, 21L
), .Label = c("A01nF", "A01yT", "A02nF", "A02yT", "A03nF", "A03yT",
"A04nF", "A04yT", "A05nF", "A05yT", "A06nF", "A06yT", "A07nF",
"A07yT", "A08nF", "A08yT", "A10nF", "A10yT", "A11nF", "A11yT",
"A13nF", "A13yT"), class = "factor"), Level = structure(c(1L,
2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L,
3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L,
1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L,
2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L,
3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L,
1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L,
2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L,
3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L,
1L, 2L, 3L), .Label = c("X", "Y", "Z"), class = "factor"), Day1 = c(3L,
1L, 4L, 2L, 4L, 2L, 5L, 4L, 1L, 2L, 5L, 1L, 5L, 2L, 5L, 5L, 3L,
5L, 3L, 3L, 1L, 4L, 1L, 1L, 5L, 4L, 1L, 5L, 4L, 5L, 3L, 5L, 3L,
5L, 3L, 4L, 2L, 4L, 2L, 4L, 3L, 1L, 1L, 3L, 1L, 3L, 1L, 5L, 2L,
4L, 4L, 3L, 1L, 4L, 4L, 1L, 4L, 1L, 2L, 5L, 1L, 5L, 1L, 2L, 4L,
4L, 4L, 4L, 2L, 4L, 5L, 5L, 4L, 1L, 3L, 2L, 3L, 5L, 4L, 3L, 2L,
3L, 5L, 4L, 1L, 3L, 4L, 3L, 3L, 5L, 3L, 1L, 1L, 4L, 4L, 5L, 1L,
4L, 4L, 4L, 1L, 4L, 5L, 5L, 1L, 5L, 3L, 1L, 4L, 1L, 4L, 5L, 5L,
3L, 3L, 2L, 4L, 5L, 3L, 2L, 1L, 5L, 5L, 2L, 2L, 3L, 4L, 3L, 4L,
2L, 2L, 4L), Day2 = c(10L, 9L, 7L, 7L, 6L, 7L, 10L, 9L, 10L,
6L, 10L, 7L, 8L, 9L, 8L, 9L, 7L, 10L, 7L, 10L, 6L, 8L, 6L, 8L,
8L, 8L, 10L, 6L, 8L, 8L, 6L, 10L, 7L, 10L, 7L, 10L, 6L, 6L, 7L,
9L, 8L, 10L, 8L, 7L, 9L, 8L, 6L, 9L, 7L, 9L, 8L, 6L, 6L, 8L,
10L, 7L, 8L, 6L, 8L, 8L, 6L, 9L, 10L, 6L, 8L, 7L, 9L, 7L, 8L,
10L, 10L, 6L, 7L, 10L, 9L, 9L, 8L, 9L, 6L, 8L, 6L, 8L, 6L, 9L,
10L, 7L, 7L, 7L, 8L, 7L, 8L, 10L, 7L, 8L, 9L, 6L, 8L, 9L, 8L,
9L, 6L, 7L, 10L, 9L, 10L, 7L, 6L, 9L, 9L, 9L, 6L, 10L, 9L, 8L,
9L, 7L, 10L, 7L, 10L, 9L, 6L, 8L, 9L, 8L, 9L, 6L, 6L, 10L, 9L,
8L, 8L, 7L), Day4 = c(11L, 12L, 14L, 11L, 15L, 15L, 12L, 11L,
15L, 12L, 15L, 12L, 12L, 11L, 15L, 15L, 13L, 11L, 13L, 14L, 12L,
11L, 13L, 12L, 15L, 15L, 14L, 11L, 15L, 11L, 12L, 11L, 13L, 11L,
12L, 13L, 13L, 14L, 13L, 15L, 14L, 15L, 12L, 14L, 11L, 13L, 15L,
11L, 12L, 13L, 11L, 15L, 11L, 13L, 11L, 11L, 14L, 12L, 14L, 15L,
11L, 12L, 15L, 12L, 13L, 12L, 14L, 12L, 11L, 13L, 12L, 12L, 11L,
15L, 13L, 12L, 11L, 12L, 13L, 14L, 14L, 14L, 13L, 12L, 15L, 12L,
15L, 15L, 12L, 13L, 12L, 12L, 12L, 14L, 13L, 13L, 14L, 11L, 12L,
11L, 15L, 11L, 11L, 11L, 14L, 11L, 12L, 15L, 15L, 11L, 12L, 14L,
15L, 14L, 14L, 12L, 14L, 13L, 15L, 15L, 14L, 13L, 12L, 15L, 15L,
11L, 13L, 12L, 11L, 13L, 12L, 14L)), class = "data.frame", row.names = c(NA,
-132L))

strange error when creating a model with zelig

dput(t)
structure(list(Volume = c(2625941L, 4685483L, 3160694L, 2627816L,
2430273L, 2498011L, 2632445L, 3224434L, 2531941L, 5043867L, 2788003L,
3278796L, 3273977L, 3192613L, 3456297L, 2668175L, 2805861L, 2689392L,
2733510L, 3285889L, 2957370L, 3420479L, 3868692L, 4353776L, 3134759L,
2914727L, 3160491L, 3803716L, 3427911L, 2646258L, 3616962L, 3071943L,
3013008L, 4024996L, 4357129L, 3110560L, 3063334L, 4537971L, 1902002L,
2618413L, 2473005L, 2844029L, 2398462L, 3406776L, 3071573L, 3714231L,
4276458L, 3825187L, 2652650L, 3040994L, 2695117L, 3038566L, 2695652L,
2919113L, 2840214L, 2768958L, 5246649L, 3023172L, 3565584L, 2928450L,
3503840L, 2948165L, 3512192L, 3409995L, 3511665L, 3155152L, 3020401L,
2758133L, 2548245L, 3033309L, 2740213L, 2851881L, 3134557L, 4445879L,
3173913L, 3720477L, 3753070L, 3609973L, 3826284L, 4864280L, 4159588L,
3095322L, 3138732L, 3591433L, 3063357L, 3215559L, 3258059L, 3559727L,
4886550L, 4025763L, 4108614L, 5720774L, 4075195L, 3322352L, 3048940L,
3249172L, 3148053L, 3321660L, 3159642L, 3976820L, 3848960L, 3466783L,
3811408L, 6033563L, 4114751L, 3181385L, 2926695L, 2866148L, 2692198L,
3400891L, 2922295L, 3912049L, 3079066L, 2833293L, 3560196L, 3317644L,
3151086L, 3776538L, 5479510L, 3954497L, 3594429L, 3088262L, 2778180L,
3532457L), SLA = c(28L, 44L, 12L, 28L, 4L, 28L, 4L, 4L, 8L, 12L,
8L, 4L, 8L, 4L, 8L, 8L, 32L, 4L, 36L, 8L, 4L, 8L, 20L, 8L, 32L,
12L, 32L, 8L, 16L, 40L, 8L, 20L, 4L, 4L, 8L, 20L, 16L, 4L, 12L,
8L, 4L, 8L, 4L, 4L, 8L, 12L, 12L, 16L, 28L, 28L, 12L, 16L, 16L,
8L, 20L, 20L, 24L, 44L, 12L, 24L, 24L, 24L, 20L, 24L, 36L, 16L,
40L, 24L, 4L, 44L, 8L, 16L, 12L, 8L, 32L, 12L, 20L, 16L, 28L,
8L, 24L, 24L, 4L, 4L, 8L, 8L, 4L, 12L, 8L, 44L, 12L, 24L, 40L,
8L, 4L, 8L, 12L, 12L, 8L, 16L, 24L, 8L, 36L, 48L, 36L, 12L, 36L,
28L, 20L, 12L, 20L, 32L, 24L, 4L, 12L, 16L, 8L, 24L, 16L, 36L,
44L, 12L, 8L, 4L), Duration = c(21L, 25L, 15L, 13L, 15L, 20L,
17L, 20L, 12L, 15L, 31L, 12L, 24L, 16L, 25L, 13L, 13L, 20L, 21L,
20L, 26L, 15L, 26L, 21L, 27L, 20L, 34L, 29L, 74L, 62L, 33L, 27L,
26L, 23L, 30L, 26L, 26L, 18L, 19L, 13L, 25L, 18L, 20L, 18L, 37L,
20L, 22L, 25L, 24L, 22L, 42L, 17L, 18L, 18L, 28L, 18L, 28L, 32L,
23L, 31L, 12L, 30L, 40L, 30L, 18L, 18L, 19L, 27L, 21L, 31L, 23L,
26L, 14L, 22L, 21L, 21L, 26L, 30L, 21L, 23L, 12L, 22L, 24L, 29L,
36L, 19L, 21L, 25L, 24L, 29L, 26L, 34L, 33L, 17L, 17L, 24L, 19L,
18L, 12L, 18L, 11L, 19L, 22L, 48L, 49L, 25L, 16L, 43L, 18L, 18L,
19L, 15L, 38L, 19L, 22L, 28L, 28L, 34L, 16L, 53L, 38L, 23L, 27L,
17L)), .Names = c("Volume", "SLA", "Duration"), class = "data.frame", row.names = c(2L,
3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L,
17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L, 27L, 28L, 29L,
30L, 31L, 32L, 33L, 34L, 35L, 36L, 37L, 38L, 39L, 40L, 41L, 42L,
43L, 44L, 45L, 46L, 47L, 48L, 49L, 50L, 51L, 52L, 53L, 54L, 55L,
56L, 57L, 58L, 59L, 60L, 61L, 62L, 63L, 64L, 65L, 66L, 67L, 68L,
69L, 70L, 71L, 72L, 73L, 75L, 76L, 77L, 79L, 80L, 81L, 82L, 84L,
85L, 86L, 87L, 88L, 89L, 90L, 91L, 92L, 93L, 94L, 95L, 96L, 97L,
98L, 99L, 100L, 101L, 102L, 103L, 105L, 106L, 107L, 108L, 110L,
111L, 112L, 113L, 115L, 116L, 117L, 118L, 119L, 120L, 121L, 122L,
123L, 124L, 125L, 126L, 127L, 128L, 129L, 130L, 131L))
when I do this:
z.out1 <- zelig(Duration ~ Volume, model = "logit", data = t)
I get this error:
Error in `rownames<-`(`*tmp*`, value = c(1L, 0L)) :
attempt to set rownames on object with no dimensions
any ideas?

Resources