Turn a function that operates on a vector into a function that operates column-wise on a data.frame.
colwise(.fun, .cols = true, ...) catcolwise(.fun, ...) numcolwise(.fun, ...)
.fun | function |
---|---|
.cols | either a function that tests columns for inclusion, or a quoted object giving which columns to process |
... | other arguments passed on to |
catcolwise
and numcolwise
provide version that only operate
on discrete and numeric variables respectively.
# Count number of missing values nmissing <- function(x) sum(is.na(x)) # Apply to every column in a data frame colwise(nmissing)(baseball)#> id year stint team lg g ab r h X2b X3b hr rbi sb cs bb so ibb hbp sh #> 1 0 0 0 0 0 0 0 0 0 0 0 0 12 250 4525 0 1305 7528 377 960 #> sf gidp #> 1 7390 5272# This syntax looks a little different. It is shorthand for the # the following: f <- colwise(nmissing) f(baseball)#> id year stint team lg g ab r h X2b X3b hr rbi sb cs bb so ibb hbp sh #> 1 0 0 0 0 0 0 0 0 0 0 0 0 12 250 4525 0 1305 7528 377 960 #> sf gidp #> 1 7390 5272#> year id stint team lg g ab r h X2b X3b hr rbi sb cs bb so ibb hbp sh sf #> 1 1871 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 7 7 7 7 #> 2 1872 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 13 13 13 13 #> 3 1873 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 13 13 13 13 #> 4 1874 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 15 15 15 15 #> 5 1875 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 17 17 17 17 #> 6 1876 0 0 0 0 0 0 0 0 0 0 0 0 15 15 0 0 15 15 15 15 #> 7 1877 0 0 0 0 0 0 0 0 0 0 0 0 16 16 0 0 16 16 16 16 #> 8 1878 0 0 0 0 0 0 0 0 0 0 0 0 17 17 0 0 17 17 17 17 #> 9 1879 0 0 0 0 0 0 0 0 0 0 0 0 25 25 0 0 25 25 25 25 #> 10 1880 0 0 0 0 0 0 0 0 0 0 0 0 28 28 0 0 28 28 28 28 #> 11 1881 0 0 0 0 0 0 0 0 0 0 0 0 36 36 0 0 36 36 36 36 #> 12 1882 0 0 0 0 0 0 0 0 0 0 0 3 28 35 0 7 35 35 35 35 #> 13 1883 0 0 0 0 0 0 0 0 0 0 0 0 25 38 0 13 38 38 38 38 #> 14 1884 0 0 0 0 0 0 0 0 0 0 0 9 27 53 0 26 53 36 53 53 #> 15 1885 0 0 0 0 0 0 0 0 0 0 0 0 33 50 0 17 50 33 50 50 #> 16 1886 0 0 0 0 0 0 0 0 0 0 0 0 0 51 0 20 51 31 51 51 #> 17 1887 0 0 0 0 0 0 0 0 0 0 0 0 0 56 0 21 56 0 56 56 #> 18 1888 0 0 0 0 0 0 0 0 0 0 0 0 0 60 0 20 60 0 60 60 #> 19 1889 0 0 0 0 0 0 0 0 0 0 0 0 0 57 0 0 57 0 57 57 #> 20 1890 0 0 0 0 0 0 0 0 0 0 0 0 0 72 0 11 72 0 72 72 #> 21 1891 0 0 0 0 0 0 0 0 0 0 0 0 0 77 0 0 77 0 77 77 #> 22 1892 0 0 0 0 0 0 0 0 0 0 0 0 0 75 0 0 75 0 75 75 #> 23 1893 0 0 0 0 0 0 0 0 0 0 0 0 0 68 0 0 68 0 68 68 #> 24 1894 0 0 0 0 0 0 0 0 0 0 0 0 0 66 0 0 66 0 66 66 #> 25 1895 0 0 0 0 0 0 0 0 0 0 0 0 0 70 0 0 70 0 0 70 #> 26 1896 0 0 0 0 0 0 0 0 0 0 0 0 0 74 0 0 74 0 0 74 #> 27 1897 0 0 0 0 0 0 0 0 0 0 0 0 0 75 0 75 75 0 0 75 #> 28 1898 0 0 0 0 0 0 0 0 0 0 0 0 0 78 0 79 78 0 0 78 #> 29 1899 0 0 0 0 0 0 0 0 0 0 0 0 0 75 0 77 75 0 0 75 #> 30 1900 0 0 0 0 0 0 0 0 0 0 0 0 0 69 0 69 69 0 0 69 #> 31 1901 0 0 0 0 0 0 0 0 0 0 0 0 0 83 0 83 83 0 0 83 #> 32 1902 0 0 0 0 0 0 0 0 0 0 0 0 0 87 0 87 87 0 0 87 #> 33 1903 0 0 0 0 0 0 0 0 0 0 0 0 0 79 0 79 79 0 0 79 #> 34 1904 0 0 0 0 0 0 0 0 0 0 0 0 0 81 0 81 81 0 0 81 #> 35 1905 0 0 0 0 0 0 0 0 0 0 0 0 0 82 0 82 82 0 0 82 #> 36 1906 0 0 0 0 0 0 0 0 0 0 0 0 0 81 0 81 81 0 0 81 #> 37 1907 0 0 0 0 0 0 0 0 0 0 0 0 0 82 0 82 82 0 0 82 #> 38 1908 0 0 0 0 0 0 0 0 0 0 0 0 0 81 0 81 81 0 0 81 #> 39 1909 0 0 0 0 0 0 0 0 0 0 0 0 0 82 0 82 82 0 0 82 #> 40 1910 0 0 0 0 0 0 0 0 0 0 0 0 0 75 0 40 75 0 0 75 #> 41 1911 0 0 0 0 0 0 0 0 0 0 0 0 0 85 0 41 85 0 0 85 #> 42 1912 0 0 0 0 0 0 0 0 0 0 0 0 0 97 0 51 97 0 0 97 #> 43 1913 0 0 0 0 0 0 0 0 0 0 0 0 0 101 0 0 101 0 0 101 #> 44 1914 0 0 0 0 0 0 0 0 0 0 0 0 0 72 0 0 107 0 0 107 #> 45 1915 0 0 0 0 0 0 0 0 0 0 0 0 0 62 0 0 133 0 0 133 #> 46 1916 0 0 0 0 0 0 0 0 0 0 0 0 0 102 0 0 121 1 0 121 #> 47 1917 0 0 0 0 0 0 0 0 0 0 0 0 0 112 0 0 112 0 0 112 #> 48 1918 0 0 0 0 0 0 0 0 0 0 0 0 0 109 0 0 109 0 0 109 #> 49 1919 0 0 0 0 0 0 0 0 0 0 0 0 0 122 0 0 122 0 0 122 #> 50 1920 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 117 0 0 117 #> 51 1921 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 117 0 0 117 #> 52 1922 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 115 0 0 115 #> 53 1923 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 132 0 0 132 #> 54 1924 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 132 0 0 132 #> 55 1925 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 135 0 0 135 #> 56 1926 0 0 0 0 0 0 0 0 0 0 0 0 0 68 0 0 135 0 0 135 #> 57 1927 0 0 0 0 0 0 0 0 0 0 0 0 0 67 0 0 132 0 0 132 #> 58 1928 0 0 0 0 0 0 0 0 0 0 0 0 0 68 0 0 133 0 0 133 #> 59 1929 0 0 0 0 0 0 0 0 0 0 0 0 0 66 0 0 131 0 0 131 #> 60 1930 0 0 0 0 0 0 0 0 0 0 0 0 0 65 0 0 131 0 0 131 #> 61 1931 0 0 0 0 0 0 0 0 0 0 0 0 0 59 0 0 125 0 0 125 #> 62 1932 0 0 0 0 0 0 0 0 0 0 0 0 0 65 0 0 129 0 0 129 #> 63 1933 0 0 0 0 0 0 0 0 0 0 0 0 0 62 0 0 131 0 0 131 #> 64 1934 0 0 0 0 0 0 0 0 0 0 0 0 0 59 0 0 132 0 0 132 #> 65 1935 0 0 0 0 0 0 0 0 0 0 0 0 0 64 0 0 126 0 0 126 #> 66 1936 0 0 0 0 0 0 0 0 0 0 0 0 0 58 0 0 128 0 0 128 #> 67 1937 0 0 0 0 0 0 0 0 0 0 0 0 0 54 0 0 121 0 0 121 #> 68 1938 0 0 0 0 0 0 0 0 0 0 0 0 0 56 0 0 117 0 0 117 #> 69 1939 0 0 0 0 0 0 0 0 0 0 0 0 0 64 0 0 129 0 0 129 #> 70 1940 0 0 0 0 0 0 0 0 0 0 0 0 0 61 0 0 121 0 0 121 #> 71 1941 0 0 0 0 0 0 0 0 0 0 0 0 0 64 0 0 130 0 0 130 #> 72 1942 0 0 0 0 0 0 0 0 0 0 0 0 0 60 0 0 118 0 0 118 #> 73 1943 0 0 0 0 0 0 0 0 0 0 0 0 0 58 0 0 101 0 0 101 #> 74 1944 0 0 0 0 0 0 0 0 0 0 0 0 0 48 0 0 88 0 0 88 #> 75 1945 0 0 0 0 0 0 0 0 0 0 0 0 0 48 0 0 87 0 0 87 #> 76 1946 0 0 0 0 0 0 0 0 0 0 0 0 0 56 0 0 120 0 0 120 #> 77 1947 0 0 0 0 0 0 0 0 0 0 0 0 0 62 0 0 121 0 0 121 #> 78 1948 0 0 0 0 0 0 0 0 0 0 0 0 0 60 0 0 112 0 0 112 #> 79 1949 0 0 0 0 0 0 0 0 0 0 0 0 0 65 0 0 117 0 0 117 #> 80 1950 0 0 0 0 0 0 0 0 0 0 0 0 0 57 0 0 118 0 0 118 #> 81 1951 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 125 0 0 125 #> 82 1952 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 142 0 0 142 #> 83 1953 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 141 0 0 141 #> 84 1954 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 138 0 0 0 #> 85 1955 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 #> 86 1956 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 #> 87 1957 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 #> 88 1958 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 #> 89 1959 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 #> 90 1960 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 #> 91 1961 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 #> 92 1962 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 #> 93 1963 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 #> 94 1964 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 #> 95 1965 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 #> 96 1966 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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11 36 #> 12 35 #> 13 38 #> 14 53 #> 15 50 #> 16 51 #> 17 56 #> 18 60 #> 19 57 #> 20 72 #> 21 77 #> 22 75 #> 23 68 #> 24 66 #> 25 70 #> 26 74 #> 27 75 #> 28 79 #> 29 77 #> 30 69 #> 31 83 #> 32 87 #> 33 79 #> 34 81 #> 35 82 #> 36 81 #> 37 82 #> 38 81 #> 39 82 #> 40 75 #> 41 85 #> 42 97 #> 43 101 #> 44 107 #> 45 133 #> 46 121 #> 47 112 #> 48 109 #> 49 122 #> 50 117 #> 51 117 #> 52 115 #> 53 132 #> 54 132 #> 55 136 #> 56 135 #> 57 132 #> 58 133 #> 59 131 #> 60 131 #> 61 125 #> 62 129 #> 63 69 #> 64 73 #> 65 62 #> 66 70 #> 67 67 #> 68 61 #> 69 0 #> 70 0 #> 71 0 #> 72 0 #> 73 0 #> 74 0 #> 75 0 #> 76 0 #> 77 0 #> 78 0 #> 79 0 #> 80 0 #> 81 0 #> 82 0 #> 83 0 #> 84 0 #> 85 0 #> 86 0 #> 87 0 #> 88 0 #> 89 0 #> 90 0 #> 91 0 #> 92 0 #> 93 0 #> 94 0 #> 95 0 #> 96 0 #> 97 0 #> 98 0 #> 99 0 #> 100 0 #> 101 0 #> 102 0 #> 103 0 #> 104 0 #> 105 0 #> 106 0 #> 107 0 #> 108 0 #> 109 0 #> 110 0 #> 111 0 #> 112 0 #> 113 0 #> 114 0 #> 115 0 #> 116 0 #> 117 0 #> 118 0 #> 119 0 #> 120 0 #> 121 0 #> 122 0 #> 123 0 #> 124 0 #> 125 0 #> 126 0 #> 127 0 #> 128 0 #> 129 0 #> 130 0 #> 131 0 #> 132 0 #> 133 0 #> 134 0 #> 135 0 #> 136 0 #> 137 0# To operate only on specified columns, supply them as the second # argument. Many different forms are accepted. ddply(baseball, .(year), colwise(nmissing, .(sb, cs, so)))#> year sb cs so #> 1 1871 0 0 0 #> 2 1872 0 0 0 #> 3 1873 0 0 0 #> 4 1874 0 0 0 #> 5 1875 0 0 0 #> 6 1876 15 15 0 #> 7 1877 16 16 0 #> 8 1878 17 17 0 #> 9 1879 25 25 0 #> 10 1880 28 28 0 #> 11 1881 36 36 0 #> 12 1882 28 35 7 #> 13 1883 25 38 13 #> 14 1884 27 53 26 #> 15 1885 33 50 17 #> 16 1886 0 51 20 #> 17 1887 0 56 21 #> 18 1888 0 60 20 #> 19 1889 0 57 0 #> 20 1890 0 72 11 #> 21 1891 0 77 0 #> 22 1892 0 75 0 #> 23 1893 0 68 0 #> 24 1894 0 66 0 #> 25 1895 0 70 0 #> 26 1896 0 74 0 #> 27 1897 0 75 75 #> 28 1898 0 78 79 #> 29 1899 0 75 77 #> 30 1900 0 69 69 #> 31 1901 0 83 83 #> 32 1902 0 87 87 #> 33 1903 0 79 79 #> 34 1904 0 81 81 #> 35 1905 0 82 82 #> 36 1906 0 81 81 #> 37 1907 0 82 82 #> 38 1908 0 81 81 #> 39 1909 0 82 82 #> 40 1910 0 75 40 #> 41 1911 0 85 41 #> 42 1912 0 97 51 #> 43 1913 0 101 0 #> 44 1914 0 72 0 #> 45 1915 0 62 0 #> 46 1916 0 102 0 #> 47 1917 0 112 0 #> 48 1918 0 109 0 #> 49 1919 0 122 0 #> 50 1920 0 0 0 #> 51 1921 0 0 0 #> 52 1922 0 0 0 #> 53 1923 0 0 0 #> 54 1924 0 0 0 #> 55 1925 0 0 0 #> 56 1926 0 68 0 #> 57 1927 0 67 0 #> 58 1928 0 68 0 #> 59 1929 0 66 0 #> 60 1930 0 65 0 #> 61 1931 0 59 0 #> 62 1932 0 65 0 #> 63 1933 0 62 0 #> 64 1934 0 59 0 #> 65 1935 0 64 0 #> 66 1936 0 58 0 #> 67 1937 0 54 0 #> 68 1938 0 56 0 #> 69 1939 0 64 0 #> 70 1940 0 61 0 #> 71 1941 0 64 0 #> 72 1942 0 60 0 #> 73 1943 0 58 0 #> 74 1944 0 48 0 #> 75 1945 0 48 0 #> 76 1946 0 56 0 #> 77 1947 0 62 0 #> 78 1948 0 60 0 #> 79 1949 0 65 0 #> 80 1950 0 57 0 #> 81 1951 0 0 0 #> 82 1952 0 0 0 #> 83 1953 0 0 0 #> 84 1954 0 0 0 #> 85 1955 0 0 0 #> 86 1956 0 0 0 #> 87 1957 0 0 0 #> 88 1958 0 0 0 #> 89 1959 0 0 0 #> 90 1960 0 0 0 #> 91 1961 0 0 0 #> 92 1962 0 0 0 #> 93 1963 0 0 0 #> 94 1964 0 0 0 #> 95 1965 0 0 0 #> 96 1966 0 0 0 #> 97 1967 0 0 0 #> 98 1968 0 0 0 #> 99 1969 0 0 0 #> 100 1970 0 0 0 #> 101 1971 0 0 0 #> 102 1972 0 0 0 #> 103 1973 0 0 0 #> 104 1974 0 0 0 #> 105 1975 0 0 0 #> 106 1976 0 0 0 #> 107 1977 0 0 0 #> 108 1978 0 0 0 #> 109 1979 0 0 0 #> 110 1980 0 0 0 #> 111 1981 0 0 0 #> 112 1982 0 0 0 #> 113 1983 0 0 0 #> 114 1984 0 0 0 #> 115 1985 0 0 0 #> 116 1986 0 0 0 #> 117 1987 0 0 0 #> 118 1988 0 0 0 #> 119 1989 0 0 0 #> 120 1990 0 0 0 #> 121 1991 0 0 0 #> 122 1992 0 0 0 #> 123 1993 0 0 0 #> 124 1994 0 0 0 #> 125 1995 0 0 0 #> 126 1996 0 0 0 #> 127 1997 0 0 0 #> 128 1998 0 0 0 #> 129 1999 0 0 0 #> 130 2000 0 0 0 #> 131 2001 0 0 0 #> 132 2002 0 0 0 #> 133 2003 0 0 0 #> 134 2004 0 0 0 #> 135 2005 0 0 0 #> 136 2006 0 0 0 #> 137 2007 0 0 0#> year sb cs so #> 1 1871 0 0 0 #> 2 1872 0 0 0 #> 3 1873 0 0 0 #> 4 1874 0 0 0 #> 5 1875 0 0 0 #> 6 1876 15 15 0 #> 7 1877 16 16 0 #> 8 1878 17 17 0 #> 9 1879 25 25 0 #> 10 1880 28 28 0 #> 11 1881 36 36 0 #> 12 1882 28 35 7 #> 13 1883 25 38 13 #> 14 1884 27 53 26 #> 15 1885 33 50 17 #> 16 1886 0 51 20 #> 17 1887 0 56 21 #> 18 1888 0 60 20 #> 19 1889 0 57 0 #> 20 1890 0 72 11 #> 21 1891 0 77 0 #> 22 1892 0 75 0 #> 23 1893 0 68 0 #> 24 1894 0 66 0 #> 25 1895 0 70 0 #> 26 1896 0 74 0 #> 27 1897 0 75 75 #> 28 1898 0 78 79 #> 29 1899 0 75 77 #> 30 1900 0 69 69 #> 31 1901 0 83 83 #> 32 1902 0 87 87 #> 33 1903 0 79 79 #> 34 1904 0 81 81 #> 35 1905 0 82 82 #> 36 1906 0 81 81 #> 37 1907 0 82 82 #> 38 1908 0 81 81 #> 39 1909 0 82 82 #> 40 1910 0 75 40 #> 41 1911 0 85 41 #> 42 1912 0 97 51 #> 43 1913 0 101 0 #> 44 1914 0 72 0 #> 45 1915 0 62 0 #> 46 1916 0 102 0 #> 47 1917 0 112 0 #> 48 1918 0 109 0 #> 49 1919 0 122 0 #> 50 1920 0 0 0 #> 51 1921 0 0 0 #> 52 1922 0 0 0 #> 53 1923 0 0 0 #> 54 1924 0 0 0 #> 55 1925 0 0 0 #> 56 1926 0 68 0 #> 57 1927 0 67 0 #> 58 1928 0 68 0 #> 59 1929 0 66 0 #> 60 1930 0 65 0 #> 61 1931 0 59 0 #> 62 1932 0 65 0 #> 63 1933 0 62 0 #> 64 1934 0 59 0 #> 65 1935 0 64 0 #> 66 1936 0 58 0 #> 67 1937 0 54 0 #> 68 1938 0 56 0 #> 69 1939 0 64 0 #> 70 1940 0 61 0 #> 71 1941 0 64 0 #> 72 1942 0 60 0 #> 73 1943 0 58 0 #> 74 1944 0 48 0 #> 75 1945 0 48 0 #> 76 1946 0 56 0 #> 77 1947 0 62 0 #> 78 1948 0 60 0 #> 79 1949 0 65 0 #> 80 1950 0 57 0 #> 81 1951 0 0 0 #> 82 1952 0 0 0 #> 83 1953 0 0 0 #> 84 1954 0 0 0 #> 85 1955 0 0 0 #> 86 1956 0 0 0 #> 87 1957 0 0 0 #> 88 1958 0 0 0 #> 89 1959 0 0 0 #> 90 1960 0 0 0 #> 91 1961 0 0 0 #> 92 1962 0 0 0 #> 93 1963 0 0 0 #> 94 1964 0 0 0 #> 95 1965 0 0 0 #> 96 1966 0 0 0 #> 97 1967 0 0 0 #> 98 1968 0 0 0 #> 99 1969 0 0 0 #> 100 1970 0 0 0 #> 101 1971 0 0 0 #> 102 1972 0 0 0 #> 103 1973 0 0 0 #> 104 1974 0 0 0 #> 105 1975 0 0 0 #> 106 1976 0 0 0 #> 107 1977 0 0 0 #> 108 1978 0 0 0 #> 109 1979 0 0 0 #> 110 1980 0 0 0 #> 111 1981 0 0 0 #> 112 1982 0 0 0 #> 113 1983 0 0 0 #> 114 1984 0 0 0 #> 115 1985 0 0 0 #> 116 1986 0 0 0 #> 117 1987 0 0 0 #> 118 1988 0 0 0 #> 119 1989 0 0 0 #> 120 1990 0 0 0 #> 121 1991 0 0 0 #> 122 1992 0 0 0 #> 123 1993 0 0 0 #> 124 1994 0 0 0 #> 125 1995 0 0 0 #> 126 1996 0 0 0 #> 127 1997 0 0 0 #> 128 1998 0 0 0 #> 129 1999 0 0 0 #> 130 2000 0 0 0 #> 131 2001 0 0 0 #> 132 2002 0 0 0 #> 133 2003 0 0 0 #> 134 2004 0 0 0 #> 135 2005 0 0 0 #> 136 2006 0 0 0 #> 137 2007 0 0 0#> year sb cs so #> 1 1871 0 0 0 #> 2 1872 0 0 0 #> 3 1873 0 0 0 #> 4 1874 0 0 0 #> 5 1875 0 0 0 #> 6 1876 15 15 0 #> 7 1877 16 16 0 #> 8 1878 17 17 0 #> 9 1879 25 25 0 #> 10 1880 28 28 0 #> 11 1881 36 36 0 #> 12 1882 28 35 7 #> 13 1883 25 38 13 #> 14 1884 27 53 26 #> 15 1885 33 50 17 #> 16 1886 0 51 20 #> 17 1887 0 56 21 #> 18 1888 0 60 20 #> 19 1889 0 57 0 #> 20 1890 0 72 11 #> 21 1891 0 77 0 #> 22 1892 0 75 0 #> 23 1893 0 68 0 #> 24 1894 0 66 0 #> 25 1895 0 70 0 #> 26 1896 0 74 0 #> 27 1897 0 75 75 #> 28 1898 0 78 79 #> 29 1899 0 75 77 #> 30 1900 0 69 69 #> 31 1901 0 83 83 #> 32 1902 0 87 87 #> 33 1903 0 79 79 #> 34 1904 0 81 81 #> 35 1905 0 82 82 #> 36 1906 0 81 81 #> 37 1907 0 82 82 #> 38 1908 0 81 81 #> 39 1909 0 82 82 #> 40 1910 0 75 40 #> 41 1911 0 85 41 #> 42 1912 0 97 51 #> 43 1913 0 101 0 #> 44 1914 0 72 0 #> 45 1915 0 62 0 #> 46 1916 0 102 0 #> 47 1917 0 112 0 #> 48 1918 0 109 0 #> 49 1919 0 122 0 #> 50 1920 0 0 0 #> 51 1921 0 0 0 #> 52 1922 0 0 0 #> 53 1923 0 0 0 #> 54 1924 0 0 0 #> 55 1925 0 0 0 #> 56 1926 0 68 0 #> 57 1927 0 67 0 #> 58 1928 0 68 0 #> 59 1929 0 66 0 #> 60 1930 0 65 0 #> 61 1931 0 59 0 #> 62 1932 0 65 0 #> 63 1933 0 62 0 #> 64 1934 0 59 0 #> 65 1935 0 64 0 #> 66 1936 0 58 0 #> 67 1937 0 54 0 #> 68 1938 0 56 0 #> 69 1939 0 64 0 #> 70 1940 0 61 0 #> 71 1941 0 64 0 #> 72 1942 0 60 0 #> 73 1943 0 58 0 #> 74 1944 0 48 0 #> 75 1945 0 48 0 #> 76 1946 0 56 0 #> 77 1947 0 62 0 #> 78 1948 0 60 0 #> 79 1949 0 65 0 #> 80 1950 0 57 0 #> 81 1951 0 0 0 #> 82 1952 0 0 0 #> 83 1953 0 0 0 #> 84 1954 0 0 0 #> 85 1955 0 0 0 #> 86 1956 0 0 0 #> 87 1957 0 0 0 #> 88 1958 0 0 0 #> 89 1959 0 0 0 #> 90 1960 0 0 0 #> 91 1961 0 0 0 #> 92 1962 0 0 0 #> 93 1963 0 0 0 #> 94 1964 0 0 0 #> 95 1965 0 0 0 #> 96 1966 0 0 0 #> 97 1967 0 0 0 #> 98 1968 0 0 0 #> 99 1969 0 0 0 #> 100 1970 0 0 0 #> 101 1971 0 0 0 #> 102 1972 0 0 0 #> 103 1973 0 0 0 #> 104 1974 0 0 0 #> 105 1975 0 0 0 #> 106 1976 0 0 0 #> 107 1977 0 0 0 #> 108 1978 0 0 0 #> 109 1979 0 0 0 #> 110 1980 0 0 0 #> 111 1981 0 0 0 #> 112 1982 0 0 0 #> 113 1983 0 0 0 #> 114 1984 0 0 0 #> 115 1985 0 0 0 #> 116 1986 0 0 0 #> 117 1987 0 0 0 #> 118 1988 0 0 0 #> 119 1989 0 0 0 #> 120 1990 0 0 0 #> 121 1991 0 0 0 #> 122 1992 0 0 0 #> 123 1993 0 0 0 #> 124 1994 0 0 0 #> 125 1995 0 0 0 #> 126 1996 0 0 0 #> 127 1997 0 0 0 #> 128 1998 0 0 0 #> 129 1999 0 0 0 #> 130 2000 0 0 0 #> 131 2001 0 0 0 #> 132 2002 0 0 0 #> 133 2003 0 0 0 #> 134 2004 0 0 0 #> 135 2005 0 0 0 #> 136 2006 0 0 0 #> 137 2007 0 0 0# Alternatively, you can specify a boolean function that determines # whether or not a column should be included ddply(baseball, .(year), colwise(nmissing, is.character))#> year id team lg #> 1 1871 0 0 0 #> 2 1872 0 0 0 #> 3 1873 0 0 0 #> 4 1874 0 0 0 #> 5 1875 0 0 0 #> 6 1876 0 0 0 #> 7 1877 0 0 0 #> 8 1878 0 0 0 #> 9 1879 0 0 0 #> 10 1880 0 0 0 #> 11 1881 0 0 0 #> 12 1882 0 0 0 #> 13 1883 0 0 0 #> 14 1884 0 0 0 #> 15 1885 0 0 0 #> 16 1886 0 0 0 #> 17 1887 0 0 0 #> 18 1888 0 0 0 #> 19 1889 0 0 0 #> 20 1890 0 0 0 #> 21 1891 0 0 0 #> 22 1892 0 0 0 #> 23 1893 0 0 0 #> 24 1894 0 0 0 #> 25 1895 0 0 0 #> 26 1896 0 0 0 #> 27 1897 0 0 0 #> 28 1898 0 0 0 #> 29 1899 0 0 0 #> 30 1900 0 0 0 #> 31 1901 0 0 0 #> 32 1902 0 0 0 #> 33 1903 0 0 0 #> 34 1904 0 0 0 #> 35 1905 0 0 0 #> 36 1906 0 0 0 #> 37 1907 0 0 0 #> 38 1908 0 0 0 #> 39 1909 0 0 0 #> 40 1910 0 0 0 #> 41 1911 0 0 0 #> 42 1912 0 0 0 #> 43 1913 0 0 0 #> 44 1914 0 0 0 #> 45 1915 0 0 0 #> 46 1916 0 0 0 #> 47 1917 0 0 0 #> 48 1918 0 0 0 #> 49 1919 0 0 0 #> 50 1920 0 0 0 #> 51 1921 0 0 0 #> 52 1922 0 0 0 #> 53 1923 0 0 0 #> 54 1924 0 0 0 #> 55 1925 0 0 0 #> 56 1926 0 0 0 #> 57 1927 0 0 0 #> 58 1928 0 0 0 #> 59 1929 0 0 0 #> 60 1930 0 0 0 #> 61 1931 0 0 0 #> 62 1932 0 0 0 #> 63 1933 0 0 0 #> 64 1934 0 0 0 #> 65 1935 0 0 0 #> 66 1936 0 0 0 #> 67 1937 0 0 0 #> 68 1938 0 0 0 #> 69 1939 0 0 0 #> 70 1940 0 0 0 #> 71 1941 0 0 0 #> 72 1942 0 0 0 #> 73 1943 0 0 0 #> 74 1944 0 0 0 #> 75 1945 0 0 0 #> 76 1946 0 0 0 #> 77 1947 0 0 0 #> 78 1948 0 0 0 #> 79 1949 0 0 0 #> 80 1950 0 0 0 #> 81 1951 0 0 0 #> 82 1952 0 0 0 #> 83 1953 0 0 0 #> 84 1954 0 0 0 #> 85 1955 0 0 0 #> 86 1956 0 0 0 #> 87 1957 0 0 0 #> 88 1958 0 0 0 #> 89 1959 0 0 0 #> 90 1960 0 0 0 #> 91 1961 0 0 0 #> 92 1962 0 0 0 #> 93 1963 0 0 0 #> 94 1964 0 0 0 #> 95 1965 0 0 0 #> 96 1966 0 0 0 #> 97 1967 0 0 0 #> 98 1968 0 0 0 #> 99 1969 0 0 0 #> 100 1970 0 0 0 #> 101 1971 0 0 0 #> 102 1972 0 0 0 #> 103 1973 0 0 0 #> 104 1974 0 0 0 #> 105 1975 0 0 0 #> 106 1976 0 0 0 #> 107 1977 0 0 0 #> 108 1978 0 0 0 #> 109 1979 0 0 0 #> 110 1980 0 0 0 #> 111 1981 0 0 0 #> 112 1982 0 0 0 #> 113 1983 0 0 0 #> 114 1984 0 0 0 #> 115 1985 0 0 0 #> 116 1986 0 0 0 #> 117 1987 0 0 0 #> 118 1988 0 0 0 #> 119 1989 0 0 0 #> 120 1990 0 0 0 #> 121 1991 0 0 0 #> 122 1992 0 0 0 #> 123 1993 0 0 0 #> 124 1994 0 0 0 #> 125 1995 0 0 0 #> 126 1996 0 0 0 #> 127 1997 0 0 0 #> 128 1998 0 0 0 #> 129 1999 0 0 0 #> 130 2000 0 0 0 #> 131 2001 0 0 0 #> 132 2002 0 0 0 #> 133 2003 0 0 0 #> 134 2004 0 0 0 #> 135 2005 0 0 0 #> 136 2006 0 0 0 #> 137 2007 0 0 0#> year stint g ab r h X2b X3b hr rbi sb cs bb so ibb hbp sh sf gidp #> 1 1871 0 0 0 0 0 0 0 0 0 0 0 0 0 7 7 7 7 7 #> 2 1872 0 0 0 0 0 0 0 0 0 0 0 0 0 13 13 13 13 13 #> 3 1873 0 0 0 0 0 0 0 0 0 0 0 0 0 13 13 13 13 13 #> 4 1874 0 0 0 0 0 0 0 0 0 0 0 0 0 15 15 15 15 15 #> 5 1875 0 0 0 0 0 0 0 0 0 0 0 0 0 17 17 17 17 17 #> 6 1876 0 0 0 0 0 0 0 0 0 15 15 0 0 15 15 15 15 15 #> 7 1877 0 0 0 0 0 0 0 0 0 16 16 0 0 16 16 16 16 17 #> 8 1878 0 0 0 0 0 0 0 0 0 17 17 0 0 17 17 17 17 17 #> 9 1879 0 0 0 0 0 0 0 0 0 25 25 0 0 25 25 25 25 25 #> 10 1880 0 0 0 0 0 0 0 0 0 28 28 0 0 28 28 28 28 28 #> 11 1881 0 0 0 0 0 0 0 0 0 36 36 0 0 36 36 36 36 36 #> 12 1882 0 0 0 0 0 0 0 0 3 28 35 0 7 35 35 35 35 35 #> 13 1883 0 0 0 0 0 0 0 0 0 25 38 0 13 38 38 38 38 38 #> 14 1884 0 0 0 0 0 0 0 0 9 27 53 0 26 53 36 53 53 53 #> 15 1885 0 0 0 0 0 0 0 0 0 33 50 0 17 50 33 50 50 50 #> 16 1886 0 0 0 0 0 0 0 0 0 0 51 0 20 51 31 51 51 51 #> 17 1887 0 0 0 0 0 0 0 0 0 0 56 0 21 56 0 56 56 56 #> 18 1888 0 0 0 0 0 0 0 0 0 0 60 0 20 60 0 60 60 60 #> 19 1889 0 0 0 0 0 0 0 0 0 0 57 0 0 57 0 57 57 57 #> 20 1890 0 0 0 0 0 0 0 0 0 0 72 0 11 72 0 72 72 72 #> 21 1891 0 0 0 0 0 0 0 0 0 0 77 0 0 77 0 77 77 77 #> 22 1892 0 0 0 0 0 0 0 0 0 0 75 0 0 75 0 75 75 75 #> 23 1893 0 0 0 0 0 0 0 0 0 0 68 0 0 68 0 68 68 68 #> 24 1894 0 0 0 0 0 0 0 0 0 0 66 0 0 66 0 66 66 66 #> 25 1895 0 0 0 0 0 0 0 0 0 0 70 0 0 70 0 0 70 70 #> 26 1896 0 0 0 0 0 0 0 0 0 0 74 0 0 74 0 0 74 74 #> 27 1897 0 0 0 0 0 0 0 0 0 0 75 0 75 75 0 0 75 75 #> 28 1898 0 0 0 0 0 0 0 0 0 0 78 0 79 78 0 0 78 79 #> 29 1899 0 0 0 0 0 0 0 0 0 0 75 0 77 75 0 0 75 77 #> 30 1900 0 0 0 0 0 0 0 0 0 0 69 0 69 69 0 0 69 69 #> 31 1901 0 0 0 0 0 0 0 0 0 0 83 0 83 83 0 0 83 83 #> 32 1902 0 0 0 0 0 0 0 0 0 0 87 0 87 87 0 0 87 87 #> 33 1903 0 0 0 0 0 0 0 0 0 0 79 0 79 79 0 0 79 79 #> 34 1904 0 0 0 0 0 0 0 0 0 0 81 0 81 81 0 0 81 81 #> 35 1905 0 0 0 0 0 0 0 0 0 0 82 0 82 82 0 0 82 82 #> 36 1906 0 0 0 0 0 0 0 0 0 0 81 0 81 81 0 0 81 81 #> 37 1907 0 0 0 0 0 0 0 0 0 0 82 0 82 82 0 0 82 82 #> 38 1908 0 0 0 0 0 0 0 0 0 0 81 0 81 81 0 0 81 81 #> 39 1909 0 0 0 0 0 0 0 0 0 0 82 0 82 82 0 0 82 82 #> 40 1910 0 0 0 0 0 0 0 0 0 0 75 0 40 75 0 0 75 75 #> 41 1911 0 0 0 0 0 0 0 0 0 0 85 0 41 85 0 0 85 85 #> 42 1912 0 0 0 0 0 0 0 0 0 0 97 0 51 97 0 0 97 97 #> 43 1913 0 0 0 0 0 0 0 0 0 0 101 0 0 101 0 0 101 101 #> 44 1914 0 0 0 0 0 0 0 0 0 0 72 0 0 107 0 0 107 107 #> 45 1915 0 0 0 0 0 0 0 0 0 0 62 0 0 133 0 0 133 133 #> 46 1916 0 0 0 0 0 0 0 0 0 0 102 0 0 121 1 0 121 121 #> 47 1917 0 0 0 0 0 0 0 0 0 0 112 0 0 112 0 0 112 112 #> 48 1918 0 0 0 0 0 0 0 0 0 0 109 0 0 109 0 0 109 109 #> 49 1919 0 0 0 0 0 0 0 0 0 0 122 0 0 122 0 0 122 122 #> 50 1920 0 0 0 0 0 0 0 0 0 0 0 0 0 117 0 0 117 117 #> 51 1921 0 0 0 0 0 0 0 0 0 0 0 0 0 117 0 0 117 117 #> 52 1922 0 0 0 0 0 0 0 0 0 0 0 0 0 115 0 0 115 115 #> 53 1923 0 0 0 0 0 0 0 0 0 0 0 0 0 132 0 0 132 132 #> 54 1924 0 0 0 0 0 0 0 0 0 0 0 0 0 132 0 0 132 132 #> 55 1925 0 0 0 0 0 0 0 0 0 0 0 0 0 135 0 0 135 136 #> 56 1926 0 0 0 0 0 0 0 0 0 0 68 0 0 135 0 0 135 135 #> 57 1927 0 0 0 0 0 0 0 0 0 0 67 0 0 132 0 0 132 132 #> 58 1928 0 0 0 0 0 0 0 0 0 0 68 0 0 133 0 0 133 133 #> 59 1929 0 0 0 0 0 0 0 0 0 0 66 0 0 131 0 0 131 131 #> 60 1930 0 0 0 0 0 0 0 0 0 0 65 0 0 131 0 0 131 131 #> 61 1931 0 0 0 0 0 0 0 0 0 0 59 0 0 125 0 0 125 125 #> 62 1932 0 0 0 0 0 0 0 0 0 0 65 0 0 129 0 0 129 129 #> 63 1933 0 0 0 0 0 0 0 0 0 0 62 0 0 131 0 0 131 69 #> 64 1934 0 0 0 0 0 0 0 0 0 0 59 0 0 132 0 0 132 73 #> 65 1935 0 0 0 0 0 0 0 0 0 0 64 0 0 126 0 0 126 62 #> 66 1936 0 0 0 0 0 0 0 0 0 0 58 0 0 128 0 0 128 70 #> 67 1937 0 0 0 0 0 0 0 0 0 0 54 0 0 121 0 0 121 67 #> 68 1938 0 0 0 0 0 0 0 0 0 0 56 0 0 117 0 0 117 61 #> 69 1939 0 0 0 0 0 0 0 0 0 0 64 0 0 129 0 0 129 0 #> 70 1940 0 0 0 0 0 0 0 0 0 0 61 0 0 121 0 0 121 0 #> 71 1941 0 0 0 0 0 0 0 0 0 0 64 0 0 130 0 0 130 0 #> 72 1942 0 0 0 0 0 0 0 0 0 0 60 0 0 118 0 0 118 0 #> 73 1943 0 0 0 0 0 0 0 0 0 0 58 0 0 101 0 0 101 0 #> 74 1944 0 0 0 0 0 0 0 0 0 0 48 0 0 88 0 0 88 0 #> 75 1945 0 0 0 0 0 0 0 0 0 0 48 0 0 87 0 0 87 0 #> 76 1946 0 0 0 0 0 0 0 0 0 0 56 0 0 120 0 0 120 0 #> 77 1947 0 0 0 0 0 0 0 0 0 0 62 0 0 121 0 0 121 0 #> 78 1948 0 0 0 0 0 0 0 0 0 0 60 0 0 112 0 0 112 0 #> 79 1949 0 0 0 0 0 0 0 0 0 0 65 0 0 117 0 0 117 0 #> 80 1950 0 0 0 0 0 0 0 0 0 0 57 0 0 118 0 0 118 0 #> 81 1951 0 0 0 0 0 0 0 0 0 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998 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 #> 129 1999 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 #> 130 2000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 #> 131 2001 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 #> 132 2002 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 #> 133 2003 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 #> 134 2004 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 #> 135 2005 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 #> 136 2006 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 #> 137 2007 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0#> year id team lg #> 1 1871 0 0 0 #> 2 1872 0 0 0 #> 3 1873 0 0 0 #> 4 1874 0 0 0 #> 5 1875 0 0 0 #> 6 1876 0 0 0 #> 7 1877 0 0 0 #> 8 1878 0 0 0 #> 9 1879 0 0 0 #> 10 1880 0 0 0 #> 11 1881 0 0 0 #> 12 1882 0 0 0 #> 13 1883 0 0 0 #> 14 1884 0 0 0 #> 15 1885 0 0 0 #> 16 1886 0 0 0 #> 17 1887 0 0 0 #> 18 1888 0 0 0 #> 19 1889 0 0 0 #> 20 1890 0 0 0 #> 21 1891 0 0 0 #> 22 1892 0 0 0 #> 23 1893 0 0 0 #> 24 1894 0 0 0 #> 25 1895 0 0 0 #> 26 1896 0 0 0 #> 27 1897 0 0 0 #> 28 1898 0 0 0 #> 29 1899 0 0 0 #> 30 1900 0 0 0 #> 31 1901 0 0 0 #> 32 1902 0 0 0 #> 33 1903 0 0 0 #> 34 1904 0 0 0 #> 35 1905 0 0 0 #> 36 1906 0 0 0 #> 37 1907 0 0 0 #> 38 1908 0 0 0 #> 39 1909 0 0 0 #> 40 1910 0 0 0 #> 41 1911 0 0 0 #> 42 1912 0 0 0 #> 43 1913 0 0 0 #> 44 1914 0 0 0 #> 45 1915 0 0 0 #> 46 1916 0 0 0 #> 47 1917 0 0 0 #> 48 1918 0 0 0 #> 49 1919 0 0 0 #> 50 1920 0 0 0 #> 51 1921 0 0 0 #> 52 1922 0 0 0 #> 53 1923 0 0 0 #> 54 1924 0 0 0 #> 55 1925 0 0 0 #> 56 1926 0 0 0 #> 57 1927 0 0 0 #> 58 1928 0 0 0 #> 59 1929 0 0 0 #> 60 1930 0 0 0 #> 61 1931 0 0 0 #> 62 1932 0 0 0 #> 63 1933 0 0 0 #> 64 1934 0 0 0 #> 65 1935 0 0 0 #> 66 1936 0 0 0 #> 67 1937 0 0 0 #> 68 1938 0 0 0 #> 69 1939 0 0 0 #> 70 1940 0 0 0 #> 71 1941 0 0 0 #> 72 1942 0 0 0 #> 73 1943 0 0 0 #> 74 1944 0 0 0 #> 75 1945 0 0 0 #> 76 1946 0 0 0 #> 77 1947 0 0 0 #> 78 1948 0 0 0 #> 79 1949 0 0 0 #> 80 1950 0 0 0 #> 81 1951 0 0 0 #> 82 1952 0 0 0 #> 83 1953 0 0 0 #> 84 1954 0 0 0 #> 85 1955 0 0 0 #> 86 1956 0 0 0 #> 87 1957 0 0 0 #> 88 1958 0 0 0 #> 89 1959 0 0 0 #> 90 1960 0 0 0 #> 91 1961 0 0 0 #> 92 1962 0 0 0 #> 93 1963 0 0 0 #> 94 1964 0 0 0 #> 95 1965 0 0 0 #> 96 1966 0 0 0 #> 97 1967 0 0 0 #> 98 1968 0 0 0 #> 99 1969 0 0 0 #> 100 1970 0 0 0 #> 101 1971 0 0 0 #> 102 1972 0 0 0 #> 103 1973 0 0 0 #> 104 1974 0 0 0 #> 105 1975 0 0 0 #> 106 1976 0 0 0 #> 107 1977 0 0 0 #> 108 1978 0 0 0 #> 109 1979 0 0 0 #> 110 1980 0 0 0 #> 111 1981 0 0 0 #> 112 1982 0 0 0 #> 113 1983 0 0 0 #> 114 1984 0 0 0 #> 115 1985 0 0 0 #> 116 1986 0 0 0 #> 117 1987 0 0 0 #> 118 1988 0 0 0 #> 119 1989 0 0 0 #> 120 1990 0 0 0 #> 121 1991 0 0 0 #> 122 1992 0 0 0 #> 123 1993 0 0 0 #> 124 1994 0 0 0 #> 125 1995 0 0 0 #> 126 1996 0 0 0 #> 127 1997 0 0 0 #> 128 1998 0 0 0 #> 129 1999 0 0 0 #> 130 2000 0 0 0 #> 131 2001 0 0 0 #> 132 2002 0 0 0 #> 133 2003 0 0 0 #> 134 2004 0 0 0 #> 135 2005 0 0 0 #> 136 2006 0 0 0 #> 137 2007 0 0 0# These last two cases are particularly common, so some shortcuts are # provided: ddply(baseball, .(year), numcolwise(nmissing))#> year stint g ab r h X2b X3b hr rbi sb cs bb so ibb hbp sh sf gidp #> 1 1871 0 0 0 0 0 0 0 0 0 0 0 0 0 7 7 7 7 7 #> 2 1872 0 0 0 0 0 0 0 0 0 0 0 0 0 13 13 13 13 13 #> 3 1873 0 0 0 0 0 0 0 0 0 0 0 0 0 13 13 13 13 13 #> 4 1874 0 0 0 0 0 0 0 0 0 0 0 0 0 15 15 15 15 15 #> 5 1875 0 0 0 0 0 0 0 0 0 0 0 0 0 17 17 17 17 17 #> 6 1876 0 0 0 0 0 0 0 0 0 15 15 0 0 15 15 15 15 15 #> 7 1877 0 0 0 0 0 0 0 0 0 16 16 0 0 16 16 16 16 17 #> 8 1878 0 0 0 0 0 0 0 0 0 17 17 0 0 17 17 17 17 17 #> 9 1879 0 0 0 0 0 0 0 0 0 25 25 0 0 25 25 25 25 25 #> 10 1880 0 0 0 0 0 0 0 0 0 28 28 0 0 28 28 28 28 28 #> 11 1881 0 0 0 0 0 0 0 0 0 36 36 0 0 36 36 36 36 36 #> 12 1882 0 0 0 0 0 0 0 0 3 28 35 0 7 35 35 35 35 35 #> 13 1883 0 0 0 0 0 0 0 0 0 25 38 0 13 38 38 38 38 38 #> 14 1884 0 0 0 0 0 0 0 0 9 27 53 0 26 53 36 53 53 53 #> 15 1885 0 0 0 0 0 0 0 0 0 33 50 0 17 50 33 50 50 50 #> 16 1886 0 0 0 0 0 0 0 0 0 0 51 0 20 51 31 51 51 51 #> 17 1887 0 0 0 0 0 0 0 0 0 0 56 0 21 56 0 56 56 56 #> 18 1888 0 0 0 0 0 0 0 0 0 0 60 0 20 60 0 60 60 60 #> 19 1889 0 0 0 0 0 0 0 0 0 0 57 0 0 57 0 57 57 57 #> 20 1890 0 0 0 0 0 0 0 0 0 0 72 0 11 72 0 72 72 72 #> 21 1891 0 0 0 0 0 0 0 0 0 0 77 0 0 77 0 77 77 77 #> 22 1892 0 0 0 0 0 0 0 0 0 0 75 0 0 75 0 75 75 75 #> 23 1893 0 0 0 0 0 0 0 0 0 0 68 0 0 68 0 68 68 68 #> 24 1894 0 0 0 0 0 0 0 0 0 0 66 0 0 66 0 66 66 66 #> 25 1895 0 0 0 0 0 0 0 0 0 0 70 0 0 70 0 0 70 70 #> 26 1896 0 0 0 0 0 0 0 0 0 0 74 0 0 74 0 0 74 74 #> 27 1897 0 0 0 0 0 0 0 0 0 0 75 0 75 75 0 0 75 75 #> 28 1898 0 0 0 0 0 0 0 0 0 0 78 0 79 78 0 0 78 79 #> 29 1899 0 0 0 0 0 0 0 0 0 0 75 0 77 75 0 0 75 77 #> 30 1900 0 0 0 0 0 0 0 0 0 0 69 0 69 69 0 0 69 69 #> 31 1901 0 0 0 0 0 0 0 0 0 0 83 0 83 83 0 0 83 83 #> 32 1902 0 0 0 0 0 0 0 0 0 0 87 0 87 87 0 0 87 87 #> 33 1903 0 0 0 0 0 0 0 0 0 0 79 0 79 79 0 0 79 79 #> 34 1904 0 0 0 0 0 0 0 0 0 0 81 0 81 81 0 0 81 81 #> 35 1905 0 0 0 0 0 0 0 0 0 0 82 0 82 82 0 0 82 82 #> 36 1906 0 0 0 0 0 0 0 0 0 0 81 0 81 81 0 0 81 81 #> 37 1907 0 0 0 0 0 0 0 0 0 0 82 0 82 82 0 0 82 82 #> 38 1908 0 0 0 0 0 0 0 0 0 0 81 0 81 81 0 0 81 81 #> 39 1909 0 0 0 0 0 0 0 0 0 0 82 0 82 82 0 0 82 82 #> 40 1910 0 0 0 0 0 0 0 0 0 0 75 0 40 75 0 0 75 75 #> 41 1911 0 0 0 0 0 0 0 0 0 0 85 0 41 85 0 0 85 85 #> 42 1912 0 0 0 0 0 0 0 0 0 0 97 0 51 97 0 0 97 97 #> 43 1913 0 0 0 0 0 0 0 0 0 0 101 0 0 101 0 0 101 101 #> 44 1914 0 0 0 0 0 0 0 0 0 0 72 0 0 107 0 0 107 107 #> 45 1915 0 0 0 0 0 0 0 0 0 0 62 0 0 133 0 0 133 133 #> 46 1916 0 0 0 0 0 0 0 0 0 0 102 0 0 121 1 0 121 121 #> 47 1917 0 0 0 0 0 0 0 0 0 0 112 0 0 112 0 0 112 112 #> 48 1918 0 0 0 0 0 0 0 0 0 0 109 0 0 109 0 0 109 109 #> 49 1919 0 0 0 0 0 0 0 0 0 0 122 0 0 122 0 0 122 122 #> 50 1920 0 0 0 0 0 0 0 0 0 0 0 0 0 117 0 0 117 117 #> 51 1921 0 0 0 0 0 0 0 0 0 0 0 0 0 117 0 0 117 117 #> 52 1922 0 0 0 0 0 0 0 0 0 0 0 0 0 115 0 0 115 115 #> 53 1923 0 0 0 0 0 0 0 0 0 0 0 0 0 132 0 0 132 132 #> 54 1924 0 0 0 0 0 0 0 0 0 0 0 0 0 132 0 0 132 132 #> 55 1925 0 0 0 0 0 0 0 0 0 0 0 0 0 135 0 0 135 136 #> 56 1926 0 0 0 0 0 0 0 0 0 0 68 0 0 135 0 0 135 135 #> 57 1927 0 0 0 0 0 0 0 0 0 0 67 0 0 132 0 0 132 132 #> 58 1928 0 0 0 0 0 0 0 0 0 0 68 0 0 133 0 0 133 133 #> 59 1929 0 0 0 0 0 0 0 0 0 0 66 0 0 131 0 0 131 131 #> 60 1930 0 0 0 0 0 0 0 0 0 0 65 0 0 131 0 0 131 131 #> 61 1931 0 0 0 0 0 0 0 0 0 0 59 0 0 125 0 0 125 125 #> 62 1932 0 0 0 0 0 0 0 0 0 0 65 0 0 129 0 0 129 129 #> 63 1933 0 0 0 0 0 0 0 0 0 0 62 0 0 131 0 0 131 69 #> 64 1934 0 0 0 0 0 0 0 0 0 0 59 0 0 132 0 0 132 73 #> 65 1935 0 0 0 0 0 0 0 0 0 0 64 0 0 126 0 0 126 62 #> 66 1936 0 0 0 0 0 0 0 0 0 0 58 0 0 128 0 0 128 70 #> 67 1937 0 0 0 0 0 0 0 0 0 0 54 0 0 121 0 0 121 67 #> 68 1938 0 0 0 0 0 0 0 0 0 0 56 0 0 117 0 0 117 61 #> 69 1939 0 0 0 0 0 0 0 0 0 0 64 0 0 129 0 0 129 0 #> 70 1940 0 0 0 0 0 0 0 0 0 0 61 0 0 121 0 0 121 0 #> 71 1941 0 0 0 0 0 0 0 0 0 0 64 0 0 130 0 0 130 0 #> 72 1942 0 0 0 0 0 0 0 0 0 0 60 0 0 118 0 0 118 0 #> 73 1943 0 0 0 0 0 0 0 0 0 0 58 0 0 101 0 0 101 0 #> 74 1944 0 0 0 0 0 0 0 0 0 0 48 0 0 88 0 0 88 0 #> 75 1945 0 0 0 0 0 0 0 0 0 0 48 0 0 87 0 0 87 0 #> 76 1946 0 0 0 0 0 0 0 0 0 0 56 0 0 120 0 0 120 0 #> 77 1947 0 0 0 0 0 0 0 0 0 0 62 0 0 121 0 0 121 0 #> 78 1948 0 0 0 0 0 0 0 0 0 0 60 0 0 112 0 0 112 0 #> 79 1949 0 0 0 0 0 0 0 0 0 0 65 0 0 117 0 0 117 0 #> 80 1950 0 0 0 0 0 0 0 0 0 0 57 0 0 118 0 0 118 0 #> 81 1951 0 0 0 0 0 0 0 0 0 0 0 0 0 125 0 0 125 0 #> 82 1952 0 0 0 0 0 0 0 0 0 0 0 0 0 142 0 0 142 0 #> 83 1953 0 0 0 0 0 0 0 0 0 0 0 0 0 141 0 0 141 0 #> 84 1954 0 0 0 0 0 0 0 0 0 0 0 0 0 138 0 0 0 0 #> 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 0 0 0 0 0 0 0 0 #> 132 2002 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 #> 133 2003 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 #> 134 2004 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 #> 135 2005 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 #> 136 2006 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 #> 137 2007 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0#> year id team lg #> 1 1871 0 0 0 #> 2 1872 0 0 0 #> 3 1873 0 0 0 #> 4 1874 0 0 0 #> 5 1875 0 0 0 #> 6 1876 0 0 0 #> 7 1877 0 0 0 #> 8 1878 0 0 0 #> 9 1879 0 0 0 #> 10 1880 0 0 0 #> 11 1881 0 0 0 #> 12 1882 0 0 0 #> 13 1883 0 0 0 #> 14 1884 0 0 0 #> 15 1885 0 0 0 #> 16 1886 0 0 0 #> 17 1887 0 0 0 #> 18 1888 0 0 0 #> 19 1889 0 0 0 #> 20 1890 0 0 0 #> 21 1891 0 0 0 #> 22 1892 0 0 0 #> 23 1893 0 0 0 #> 24 1894 0 0 0 #> 25 1895 0 0 0 #> 26 1896 0 0 0 #> 27 1897 0 0 0 #> 28 1898 0 0 0 #> 29 1899 0 0 0 #> 30 1900 0 0 0 #> 31 1901 0 0 0 #> 32 1902 0 0 0 #> 33 1903 0 0 0 #> 34 1904 0 0 0 #> 35 1905 0 0 0 #> 36 1906 0 0 0 #> 37 1907 0 0 0 #> 38 1908 0 0 0 #> 39 1909 0 0 0 #> 40 1910 0 0 0 #> 41 1911 0 0 0 #> 42 1912 0 0 0 #> 43 1913 0 0 0 #> 44 1914 0 0 0 #> 45 1915 0 0 0 #> 46 1916 0 0 0 #> 47 1917 0 0 0 #> 48 1918 0 0 0 #> 49 1919 0 0 0 #> 50 1920 0 0 0 #> 51 1921 0 0 0 #> 52 1922 0 0 0 #> 53 1923 0 0 0 #> 54 1924 0 0 0 #> 55 1925 0 0 0 #> 56 1926 0 0 0 #> 57 1927 0 0 0 #> 58 1928 0 0 0 #> 59 1929 0 0 0 #> 60 1930 0 0 0 #> 61 1931 0 0 0 #> 62 1932 0 0 0 #> 63 1933 0 0 0 #> 64 1934 0 0 0 #> 65 1935 0 0 0 #> 66 1936 0 0 0 #> 67 1937 0 0 0 #> 68 1938 0 0 0 #> 69 1939 0 0 0 #> 70 1940 0 0 0 #> 71 1941 0 0 0 #> 72 1942 0 0 0 #> 73 1943 0 0 0 #> 74 1944 0 0 0 #> 75 1945 0 0 0 #> 76 1946 0 0 0 #> 77 1947 0 0 0 #> 78 1948 0 0 0 #> 79 1949 0 0 0 #> 80 1950 0 0 0 #> 81 1951 0 0 0 #> 82 1952 0 0 0 #> 83 1953 0 0 0 #> 84 1954 0 0 0 #> 85 1955 0 0 0 #> 86 1956 0 0 0 #> 87 1957 0 0 0 #> 88 1958 0 0 0 #> 89 1959 0 0 0 #> 90 1960 0 0 0 #> 91 1961 0 0 0 #> 92 1962 0 0 0 #> 93 1963 0 0 0 #> 94 1964 0 0 0 #> 95 1965 0 0 0 #> 96 1966 0 0 0 #> 97 1967 0 0 0 #> 98 1968 0 0 0 #> 99 1969 0 0 0 #> 100 1970 0 0 0 #> 101 1971 0 0 0 #> 102 1972 0 0 0 #> 103 1973 0 0 0 #> 104 1974 0 0 0 #> 105 1975 0 0 0 #> 106 1976 0 0 0 #> 107 1977 0 0 0 #> 108 1978 0 0 0 #> 109 1979 0 0 0 #> 110 1980 0 0 0 #> 111 1981 0 0 0 #> 112 1982 0 0 0 #> 113 1983 0 0 0 #> 114 1984 0 0 0 #> 115 1985 0 0 0 #> 116 1986 0 0 0 #> 117 1987 0 0 0 #> 118 1988 0 0 0 #> 119 1989 0 0 0 #> 120 1990 0 0 0 #> 121 1991 0 0 0 #> 122 1992 0 0 0 #> 123 1993 0 0 0 #> 124 1994 0 0 0 #> 125 1995 0 0 0 #> 126 1996 0 0 0 #> 127 1997 0 0 0 #> 128 1998 0 0 0 #> 129 1999 0 0 0 #> 130 2000 0 0 0 #> 131 2001 0 0 0 #> 132 2002 0 0 0 #> 133 2003 0 0 0 #> 134 2004 0 0 0 #> 135 2005 0 0 0 #> 136 2006 0 0 0 #> 137 2007 0 0 0# You can supply additional arguments to either colwise, or the function # it generates: numcolwise(mean)(baseball, na.rm = TRUE)#> year stint g ab r h X2b X3b #> 1 1961.068 1.092723 72.81764 225.4049 31.7805 61.7569 10.45242 2.194064 #> hr rbi sb cs bb so ibb hbp #> 1 5.234204 29.58657 5.168353 2.099744 22.49472 29.26223 2.291793 1.543195 #> sh sf gidp #> 1 3.388013 1.842477 4.773726numcolwise(mean, na.rm = TRUE)(baseball)#> year stint g ab r h X2b X3b #> 1 1961.068 1.092723 72.81764 225.4049 31.7805 61.7569 10.45242 2.194064 #> hr rbi sb cs bb so ibb hbp #> 1 5.234204 29.58657 5.168353 2.099744 22.49472 29.26223 2.291793 1.543195 #> sh sf gidp #> 1 3.388013 1.842477 4.773726