R version 4.2.3 (2023-03-15 ucrt) -- "Shortstop Beagle" Copyright (C) 2023 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 (64-bit) R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. [Previously saved workspace restored] > ls() [1] "a" "b" "c" "d" "f" "L" "L2" "s" "v" "w" "x" "y" "z" > rm("a") > ls() [1] "b" "c" "d" "f" "L" "L2" "s" "v" "w" "x" "y" "z" > y [1] 2 3 4 5 6 7 > dim(y) NULL > dim(y) <- c(2,3) > y [,1] [,2] [,3] [1,] 2 4 6 [2,] 3 5 7 > class(y) [1] "matrix" "array" > a <- 1:8 > dim(a) <- c(2,2,2) > a , , 1 [,1] [,2] [1,] 1 3 [2,] 2 4 , , 2 [,1] [,2] [1,] 5 7 [2,] 6 8 > A <- 1:24 > dim(A) <- c(4.3.2) Error: unexpected numeric constant in "dim(A) <- c(4.3.2" > dim(A) <- c(4,3,2) > A , , 1 [,1] [,2] [,3] [1,] 1 5 9 [2,] 2 6 10 [3,] 3 7 11 [4,] 4 8 12 , , 2 [,1] [,2] [,3] [1,] 13 17 21 [2,] 14 18 22 [3,] 15 19 23 [4,] 16 20 24 > B <- matrix(2,3,1:6) > B [,1] [1,] 2 [2,] 2 [3,] 2 > B <- matrix(c(2,3),1:6) > B [,1] [,2] [1,] 2 3 > B <- matrix(1:6,2,3) > B [,1] [,2] [,3] [1,] 1 3 5 [2,] 2 4 6 > ?matrix starting httpd help server ... done > C <- matrix(1:6,2,3,byrow=TRUE) > C [,1] [,2] [,3] [1,] 1 2 3 [2,] 4 5 6 > names(C) NULL > row.names(C) NULL > column.names(C) Error in column.names(C) : could not find function "column.names" > names(C) <- c("a","b","c") > C [,1] [,2] [,3] [1,] 1 2 3 [2,] 4 5 6 attr(,"names") [1] "a" "b" "c" NA NA NA > row.names(C) <- c("d","e") > C [,1] [,2] [,3] d 1 2 3 e 4 5 6 attr(,"names") [1] "a" "b" "c" NA NA NA > dimnames(C)[1] <- c("a","b","c") Error in dimnames(C)[1] <- c("a", "b", "c") : length of 'dimnames' [1] not equal to array extent In addition: Warning message: In dimnames(C)[1] <- c("a", "b", "c") : number of items to replace is not a multiple of replacement length > dimnames(C)[[1]] <- c("a","b","c") Error in dimnames(C)[[1]] <- c("a", "b", "c") : length of 'dimnames' [1] not equal to array extent > dimnames(C) [[1]] [1] "d" "e" [[2]] NULL > dimnames(C)[2] <- c("a","b","c") Error in dimnames(C)[2] <- c("a", "b", "c") : length of 'dimnames' [2] not equal to array extent In addition: Warning message: In dimnames(C)[2] <- c("a", "b", "c") : number of items to replace is not a multiple of replacement length > C [,1] [,2] [,3] d 1 2 3 e 4 5 6 attr(,"names") [1] "a" "b" "c" NA NA NA > dimnames(C)[[2]] <- c("a","b","c") > C a b c d 1 2 3 e 4 5 6 attr(,"names") [1] "a" "b" "c" NA NA NA > names(C) <- NULL > C a b c d 1 2 3 e 4 5 6 > y [,1] [,2] [,3] [1,] 2 4 6 [2,] 3 5 7 > z [1] 1.0 1.5 2.0 2.5 3.0 3.5 > names(z) NULL > names(z)[3] <- "c" > z c 1.0 1.5 2.0 2.5 3.0 3.5 > names(z) [1] NA NA "c" NA NA NA > z[3] c 2 > z["c"] c 2 > z$c Error in z$c : $ operator is invalid for atomic vectors > C a b c d 1 2 3 e 4 5 6 > t(C) d e a 1 4 b 2 5 c 3 6 > g <- c(1,3,-5) > C * g a b c d 1 -10 9 e 12 5 -30 > C %*% g [,1] d -8 e -11 > g %*% C Error in g %*% C : non-conformable arguments > x [1] 2 0 > x %*% C a b c [1,] 2 4 6 > w [1] 3.00 -2.00 4.23 > g [1] 1 3 -5 > g %*% w [,1] [1,] -24.15 > outer(q,w) Error in as.vector(x, mode) : cannot coerce type 'closure' to vector of type 'any' > outer(g,w) [,1] [,2] [,3] [1,] 3 -2 4.23 [2,] 9 -6 12.69 [3,] -15 10 -21.15 > inner(g,w) Error in inner(g, w) : could not find function "inner" > crossprod(g,w) [,1] [1,] -24.15 > C a b c d 1 2 3 e 4 5 6 > C[2] [1] 4 > C[6] [1] 6 > as.vector(C)[6] [1] 6 > C[2,2] [1] 5 > C[2,3] [1] 6 > C[2,] a b c 4 5 6 > C[,3] d e 3 6 > C a b c d 1 2 3 e 4 5 6 > B [,1] [,2] [,3] [1,] 1 3 5 [2,] 2 4 6 > cbind(B,C) a b c d 1 3 5 1 2 3 e 2 4 6 4 5 6 > rbind(B,C) a b c 1 3 5 2 4 6 d 1 2 3 e 4 5 6 > E <- matrix(c(1,2,4,0),2,2) > E [,1] [,2] [1,] 1 4 [2,] 2 0 > diag(E) [1] 1 0 > diag(x) [,1] [,2] [1,] 2 0 [2,] 0 0 > diag(y) [1] 2 5 > diag(z) [,1] [,2] [,3] [,4] [,5] [,6] [1,] 1 0.0 0 0.0 0 0.0 [2,] 0 1.5 0 0.0 0 0.0 [3,] 0 0.0 2 0.0 0 0.0 [4,] 0 0.0 0 2.5 0 0.0 [5,] 0 0.0 0 0.0 3 0.0 [6,] 0 0.0 0 0.0 0 3.5 > diag(3) [,1] [,2] [,3] [1,] 1 0 0 [2,] 0 1 0 [3,] 0 0 1 > det(E) [1] -8 > E [,1] [,2] [1,] 1 4 [2,] 2 0 > eig <- eigen(E) > eig eigen() decomposition $values [1] 3.372281 -2.372281 $vectors [,1] [,2] [1,] 0.8601113 -0.7645475 [2,] 0.5101065 0.6445673 > eig$values [1] 3.372281 -2.372281 > E [,1] [,2] [1,] 1 4 [2,] 2 0 > x [1] 2 0 > solve(E,x) [1] 0.0 0.5 > solve(E) [,1] [,2] [1,] 0.00 0.500 [2,] 0.25 -0.125 > > L [1] TRUE FALSE TRUE TRUE TRUE FALSE > lista <- list("abc",3.14,vekt = c(1,2,4),mx = diag(2)) > lista [[1]] [1] "abc" [[2]] [1] 3.14 $vekt [1] 1 2 4 $mx [,1] [,2] [1,] 1 0 [2,] 0 1 > lista[2] [[1]] [1] 3.14 > lista[[2]] [1] 3.14 > lista[[3]] [1] 1 2 4 > lista[["vekt"]] [1] 1 2 4 > lista$vekt [1] 1 2 4 > lista$vekt[3] [1] 4 > lista[3][2] $ NULL > lista[3] $vekt [1] 1 2 4 > lista[[3]][2] [1] 2 > names(lista) [1] "" "" "vekt" "mx" > names(lista)[2] <- "num" > lista [[1]] [1] "abc" $num [1] 3.14 $vekt [1] 1 2 4 $mx [,1] [,2] [1,] 1 0 [2,] 0 1 > data() > morley Expt Run Speed 001 1 1 850 002 1 2 740 003 1 3 900 004 1 4 1070 005 1 5 930 006 1 6 850 007 1 7 950 008 1 8 980 009 1 9 980 010 1 10 880 011 1 11 1000 012 1 12 980 013 1 13 930 014 1 14 650 015 1 15 760 016 1 16 810 017 1 17 1000 018 1 18 1000 019 1 19 960 020 1 20 960 021 2 1 960 022 2 2 940 023 2 3 960 024 2 4 940 025 2 5 880 026 2 6 800 027 2 7 850 028 2 8 880 029 2 9 900 030 2 10 840 031 2 11 830 032 2 12 790 033 2 13 810 034 2 14 880 035 2 15 880 036 2 16 830 037 2 17 800 038 2 18 790 039 2 19 760 040 2 20 800 041 3 1 880 042 3 2 880 043 3 3 880 044 3 4 860 045 3 5 720 046 3 6 720 047 3 7 620 048 3 8 860 049 3 9 970 050 3 10 950 051 3 11 880 052 3 12 910 053 3 13 850 054 3 14 870 055 3 15 840 056 3 16 840 057 3 17 850 058 3 18 840 059 3 19 840 060 3 20 840 061 4 1 890 062 4 2 810 063 4 3 810 064 4 4 820 065 4 5 800 066 4 6 770 067 4 7 760 068 4 8 740 069 4 9 750 070 4 10 760 071 4 11 910 072 4 12 920 073 4 13 890 074 4 14 860 075 4 15 880 076 4 16 720 077 4 17 840 078 4 18 850 079 4 19 850 080 4 20 780 081 5 1 890 082 5 2 840 083 5 3 780 084 5 4 810 085 5 5 760 086 5 6 810 087 5 7 790 088 5 8 810 089 5 9 820 090 5 10 850 091 5 11 870 092 5 12 870 093 5 13 810 094 5 14 740 095 5 15 810 096 5 16 940 097 5 17 950 098 5 18 800 099 5 19 810 100 5 20 870 > ?morley > head(morley) Expt Run Speed 001 1 1 850 002 1 2 740 003 1 3 900 004 1 4 1070 005 1 5 930 006 1 6 850 > edit(morley) Expt Run Speed 001 1 1 850 002 1 2 740 003 1 3 900 004 1 4 1070 005 1 5 930 006 1 6 850 007 1 7 950 008 1 8 980 009 1 9 980 010 1 10 880 011 1 11 1000 012 1 12 980 013 1 13 930 014 1 14 650 015 1 15 760 016 1 16 810 017 1 17 1000 018 1 18 1000 019 1 19 960 020 1 20 960 021 2 1 960 022 2 2 940 023 2 3 960 024 2 4 940 025 2 5 880 026 2 6 800 027 2 7 850 028 2 8 880 029 2 9 900 030 2 10 840 031 2 11 830 032 2 12 790 033 2 13 810 034 2 14 880 035 2 15 880 036 2 16 830 037 2 17 800 038 2 18 790 039 2 19 760 040 2 20 800 041 3 1 880 042 3 2 880 043 3 3 880 044 3 4 860 045 3 5 720 046 3 6 720 047 3 7 620 048 3 8 860 049 3 9 970 050 3 10 950 051 3 11 880 052 3 12 910 053 3 13 850 054 3 14 870 055 3 15 840 056 3 16 840 057 3 17 850 058 3 18 840 059 3 19 840 060 3 20 840 061 4 1 890 062 4 2 810 063 4 3 810 064 4 4 820 065 4 5 800 066 4 6 770 067 4 7 760 068 4 8 740 069 4 9 750 070 4 10 760 071 4 11 910 072 4 12 920 073 4 13 890 074 4 14 860 075 4 15 880 076 4 16 720 077 4 17 840 078 4 18 850 079 4 19 850 080 4 20 780 081 5 1 890 082 5 2 840 083 5 3 780 084 5 4 810 085 5 5 760 086 5 6 810 087 5 7 790 088 5 8 810 089 5 9 820 090 5 10 850 091 5 11 870 092 5 12 870 093 5 13 810 094 5 14 740 095 5 15 810 096 5 16 940 097 5 17 950 098 5 18 800 099 5 19 810 100 5 20 870 > morley[2] Run 001 1 002 2 003 3 004 4 005 5 006 6 007 7 008 8 009 9 010 10 011 11 012 12 013 13 014 14 015 15 016 16 017 17 018 18 019 19 020 20 021 1 022 2 023 3 024 4 025 5 026 6 027 7 028 8 029 9 030 10 031 11 032 12 033 13 034 14 035 15 036 16 037 17 038 18 039 19 040 20 041 1 042 2 043 3 044 4 045 5 046 6 047 7 048 8 049 9 050 10 051 11 052 12 053 13 054 14 055 15 056 16 057 17 058 18 059 19 060 20 061 1 062 2 063 3 064 4 065 5 066 6 067 7 068 8 069 9 070 10 071 11 072 12 073 13 074 14 075 15 076 16 077 17 078 18 079 19 080 20 081 1 082 2 083 3 084 4 085 5 086 6 087 7 088 8 089 9 090 10 091 11 092 12 093 13 094 14 095 15 096 16 097 17 098 18 099 19 100 20 > morley["Sped"] Error in `[.data.frame`(morley, "Sped") : undefined columns selected > morley["Speed"] Speed 001 850 002 740 003 900 004 1070 005 930 006 850 007 950 008 980 009 980 010 880 011 1000 012 980 013 930 014 650 015 760 016 810 017 1000 018 1000 019 960 020 960 021 960 022 940 023 960 024 940 025 880 026 800 027 850 028 880 029 900 030 840 031 830 032 790 033 810 034 880 035 880 036 830 037 800 038 790 039 760 040 800 041 880 042 880 043 880 044 860 045 720 046 720 047 620 048 860 049 970 050 950 051 880 052 910 053 850 054 870 055 840 056 840 057 850 058 840 059 840 060 840 061 890 062 810 063 810 064 820 065 800 066 770 067 760 068 740 069 750 070 760 071 910 072 920 073 890 074 860 075 880 076 720 077 840 078 850 079 850 080 780 081 890 082 840 083 780 084 810 085 760 086 810 087 790 088 810 089 820 090 850 091 870 092 870 093 810 094 740 095 810 096 940 097 950 098 800 099 810 100 870 > morley$Speed [1] 850 740 900 1070 930 850 950 980 980 880 1000 980 930 650 760 [16] 810 1000 1000 960 960 960 940 960 940 880 800 850 880 900 840 [31] 830 790 810 880 880 830 800 790 760 800 880 880 880 860 720 [46] 720 620 860 970 950 880 910 850 870 840 840 850 840 840 840 [61] 890 810 810 820 800 770 760 740 750 760 910 920 890 860 880 [76] 720 840 850 850 780 890 840 780 810 760 810 790 810 820 850 [91] 870 870 810 740 810 940 950 800 810 870 > morley[2,3] [1] 740 > head(morley) Expt Run Speed 001 1 1 850 002 1 2 740 003 1 3 900 004 1 4 1070 005 1 5 930 006 1 6 850 > morley[2,] Expt Run Speed 002 1 2 740 > morley[2:5,] Expt Run Speed 002 1 2 740 003 1 3 900 004 1 4 1070 005 1 5 930 > class(morley[1]) [1] "data.frame" > class(morley[[1]]) [1] "integer" > is.factor(morley[1]) [1] FALSE > morley$Expt <- factor(morley$Expt) > is.factor(morley[1]) [1] FALSE > is.factor(morley$Expt) [1] TRUE > morley$Expt [1] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 [38] 2 2 2 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4 4 4 [75] 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 Levels: 1 2 3 4 5 > mean(morley$Speed) [1] 852.4 > ?tapply > tapply(morley$Speed,morley$Expt,mean) 1 2 3 4 5 909.0 856.0 845.0 820.5 831.5 > tapply(morley$Speed,morley$Expt,range) $`1` [1] 650 1070 $`2` [1] 760 960 $`3` [1] 620 970 $`4` [1] 720 920 $`5` [1] 740 950 > df <- data.frame(x = rnorm(10), y = rnorm(10)) > df x y 1 -0.15001219 1.8958368 2 -1.13058397 0.2333465 3 -0.40605236 -1.0349728 4 -0.02742272 1.2995876 5 -1.14877369 -0.4036570 6 0.19165095 -0.2708274 7 -0.85703797 -0.8099453 8 1.03689411 0.5646687 9 -1.08485402 -0.1205464 10 0.42056998 -0.2633206 > df$tav <- sqrt(df$x^2 + df$y^2) > df x y tav 1 -0.15001219 1.8958368 1.9017626 2 -1.13058397 0.2333465 1.1544136 3 -0.40605236 -1.0349728 1.1117766 4 -0.02742272 1.2995876 1.2998769 5 -1.14877369 -0.4036570 1.2176288 6 0.19165095 -0.2708274 0.3317794 7 -0.85703797 -0.8099453 1.1792055 8 1.03689411 0.5646687 1.1806778 9 -1.08485402 -0.1205464 1.0915309 10 0.42056998 -0.2633206 0.4962024 > df[4] <- 1:5 > df x y tav V4 1 -0.15001219 1.8958368 1.9017626 1 2 -1.13058397 0.2333465 1.1544136 2 3 -0.40605236 -1.0349728 1.1117766 3 4 -0.02742272 1.2995876 1.2998769 4 5 -1.14877369 -0.4036570 1.2176288 5 6 0.19165095 -0.2708274 0.3317794 1 7 -0.85703797 -0.8099453 1.1792055 2 8 1.03689411 0.5646687 1.1806778 3 9 -1.08485402 -0.1205464 1.0915309 4 10 0.42056998 -0.2633206 0.4962024 5 > df[6] <- 1:3 Error in `[<-.data.frame`(`*tmp*`, 6, value = 1:3) : new columns would leave holes after existing columns > df[11,] x y tav V4 NA NA NA NA NA > df[11,] <- c(rnorm(1), rnorm(1), 0, 6) > df x y tav V4 1 -0.15001219 1.8958368 1.9017626 1 2 -1.13058397 0.2333465 1.1544136 2 3 -0.40605236 -1.0349728 1.1117766 3 4 -0.02742272 1.2995876 1.2998769 4 5 -1.14877369 -0.4036570 1.2176288 5 6 0.19165095 -0.2708274 0.3317794 1 7 -0.85703797 -0.8099453 1.1792055 2 8 1.03689411 0.5646687 1.1806778 3 9 -1.08485402 -0.1205464 1.0915309 4 10 0.42056998 -0.2633206 0.4962024 5 11 0.12638352 0.7872296 0.0000000 6 > df[14,] <- c(rnorm(1), rnorm(1), 0, 6) > df x y tav V4 1 -0.15001219 1.8958368 1.9017626 1 2 -1.13058397 0.2333465 1.1544136 2 3 -0.40605236 -1.0349728 1.1117766 3 4 -0.02742272 1.2995876 1.2998769 4 5 -1.14877369 -0.4036570 1.2176288 5 6 0.19165095 -0.2708274 0.3317794 1 7 -0.85703797 -0.8099453 1.1792055 2 8 1.03689411 0.5646687 1.1806778 3 9 -1.08485402 -0.1205464 1.0915309 4 10 0.42056998 -0.2633206 0.4962024 5 11 0.12638352 0.7872296 0.0000000 6 12 NA NA NA NA 13 NA NA NA NA 14 1.42399930 -0.1811051 0.0000000 6 > names(df) [1] "x" "y" "tav" "V4" > row.names(df) [1] "1" "2" "3" "4" "5" "6" "7" "8" "9" "10" "11" "12" "13" "14" > df2 <- df[3:8,] > df2 x y tav V4 3 -0.40605236 -1.0349728 1.1117766 3 4 -0.02742272 1.2995876 1.2998769 4 5 -1.14877369 -0.4036570 1.2176288 5 6 0.19165095 -0.2708274 0.3317794 1 7 -0.85703797 -0.8099453 1.1792055 2 8 1.03689411 0.5646687 1.1806778 3 > df2[1] x 3 -0.40605236 4 -0.02742272 5 -1.14877369 6 0.19165095 7 -0.85703797 8 1.03689411 > df2[1,] x y tav V4 3 -0.4060524 -1.034973 1.111777 3 > df2["1",] x y tav V4 NA NA NA NA NA > df2[3,] x y tav V4 5 -1.148774 -0.403657 1.217629 5 > df2["3",] x y tav V4 3 -0.4060524 -1.034973 1.111777 3 > x [1] 2 0 > y [,1] [,2] [,3] [1,] 2 4 6 [2,] 3 5 7 > df$x [1] -0.15001219 -1.13058397 -0.40605236 -0.02742272 -1.14877369 0.19165095 [7] -0.85703797 1.03689411 -1.08485402 0.42056998 0.12638352 NA [13] NA 1.42399930 > rm(x,y) > attach(df) > x [1] -0.15001219 -1.13058397 -0.40605236 -0.02742272 -1.14877369 0.19165095 [7] -0.85703797 1.03689411 -1.08485402 0.42056998 0.12638352 NA [13] NA 1.42399930 > df$x [1] -0.15001219 -1.13058397 -0.40605236 -0.02742272 -1.14877369 0.19165095 [7] -0.85703797 1.03689411 -1.08485402 0.42056998 0.12638352 NA [13] NA 1.42399930 > x <- x+2 > x [1] 1.8499878 0.8694160 1.5939476 1.9725773 0.8512263 2.1916509 1.1429620 [8] 3.0368941 0.9151460 2.4205700 2.1263835 NA NA 3.4239993 > df$x [1] -0.15001219 -1.13058397 -0.40605236 -0.02742272 -1.14877369 0.19165095 [7] -0.85703797 1.03689411 -1.08485402 0.42056998 0.12638352 NA [13] NA 1.42399930 > detach(df) > y Error: object 'y' not found > rm(x) > attach(df) > x [1] -0.15001219 -1.13058397 -0.40605236 -0.02742272 -1.14877369 0.19165095 [7] -0.85703797 1.03689411 -1.08485402 0.42056998 0.12638352 NA [13] NA 1.42399930 > y [1] 1.8958368 0.2333465 -1.0349728 1.2995876 -0.4036570 -0.2708274 [7] -0.8099453 0.5646687 -0.1205464 -0.2633206 0.7872296 NA [13] NA -0.1811051 > plot(x,y) > plot(x) > plot(x) > df x y tav V4 1 -0.15001219 1.8958368 1.9017626 1 2 -1.13058397 0.2333465 1.1544136 2 3 -0.40605236 -1.0349728 1.1117766 3 4 -0.02742272 1.2995876 1.2998769 4 5 -1.14877369 -0.4036570 1.2176288 5 6 0.19165095 -0.2708274 0.3317794 1 7 -0.85703797 -0.8099453 1.1792055 2 8 1.03689411 0.5646687 1.1806778 3 9 -1.08485402 -0.1205464 1.0915309 4 10 0.42056998 -0.2633206 0.4962024 5 11 0.12638352 0.7872296 0.0000000 6 12 NA NA NA NA 13 NA NA NA NA 14 1.42399930 -0.1811051 0.0000000 6 > df$V4 <- fcator(V4) Error in fcator(V4) : could not find function "fcator" > df$V4 <- factor(V4) > plot(df$V4) > plot(df$V4,x) > plot(x,y) > plot(x,y,col="red") > plot(x,y,col=4) > plot(1:4,1:4,col=1:4) > plot(1:4,1:4,col=c("red","blue","purple","green")) > plot(x,y,col=V4) > df$V4 <- c(1,2) > df$V4 [1] 1 2 1 2 1 2 1 2 1 2 1 2 1 2 > plot(x,y,col=df$V4) > plot(x,y,pch="x") > plot(x,y,pch="+") > plot(x,y,pch=4) > plot(x,y,pch=df$V4) > plot(x,y,pch=df$V4,col=df$V4) > V4 [1] 1 2 3 4 5 1 2 3 4 5 6 NA NA 6 > table(V4) V4 1 2 3 4 5 6 2 2 2 2 2 2 > x [1] -0.15001219 -1.13058397 -0.40605236 -0.02742272 -1.14877369 0.19165095 [7] -0.85703797 1.03689411 -1.08485402 0.42056998 0.12638352 NA [13] NA 1.42399930 > z <- round(x) > z [1] 0 -1 0 0 -1 0 -1 1 -1 0 0 NA NA 1 > table(z) z -1 0 1 4 6 2 > v <- round(y) > v [1] 2 0 -1 1 0 0 -1 1 0 0 1 NA NA 0 > table(v) v -1 0 1 2 2 6 3 1 > table(z,v) v z -1 0 1 2 -1 1 3 0 0 0 1 2 2 1 1 0 1 1 0 > df$z <- z > df$v <- v > df x y tav V4 z v 1 -0.15001219 1.8958368 1.9017626 1 0 2 2 -1.13058397 0.2333465 1.1544136 2 -1 0 3 -0.40605236 -1.0349728 1.1117766 1 0 -1 4 -0.02742272 1.2995876 1.2998769 2 0 1 5 -1.14877369 -0.4036570 1.2176288 1 -1 0 6 0.19165095 -0.2708274 0.3317794 2 0 0 7 -0.85703797 -0.8099453 1.1792055 1 -1 -1 8 1.03689411 0.5646687 1.1806778 2 1 1 9 -1.08485402 -0.1205464 1.0915309 1 -1 0 10 0.42056998 -0.2633206 0.4962024 2 0 0 11 0.12638352 0.7872296 0.0000000 1 0 1 12 NA NA NA 2 NA NA 13 NA NA NA 1 NA NA 14 1.42399930 -0.1811051 0.0000000 2 1 0 > table(z,v) v z -1 0 1 2 -1 1 3 0 0 0 1 2 2 1 1 0 1 1 0 >