Hello all! I have a problem with R. I try to merge data like this: structure(c(2.1785, 1.868, 2.1855, 2.5175, 2.025, 2.435, 1.809, 1.628, 1.327, 1.3485, 1.4335, 2.052, 2.2465, 2.151, 1.7945, 1.79, 1.6055, 1.616, 1.633, 1.665, 2.002, 2.152, 1.736, 1.7985, 1.9155, 1.7135, 1.548, 1.568, 1.713, 2.079, 1.875, 2.12, 2.072, 1.906, 1.4645, 1.3025, 1.407, 1.5445, 1.437, 1.463, 1.5235, 1.609, 1.738, 1.478, 1.573, 1.0465, 1.429, 1.632, 1.814, 1.933, 1.63, 1.482, 1.466, 1.4025, 1.6055, 1.279, 1.827, 1.201, 1.425, 1.678, 1.5535, 1.599, 1.826, 1.964, 1.68, 1.492, 1.509, 1.666, 1.5665, 1.666, 1.4885, 1.8205, 1.5965, 1.84, 1.551, 1.4835, 1.805, 1.7145, 1.902, 1.2085, 0.9095, 0.9325, 1.34, 1.6135, 1.5825, 1.757, 1.7105, 1.3115, 1.288, 1.567, 1.7795, 1.642, 1.4375, 1.4495, 1.4225, 1.4885, 1.251, 1.179, 1.188, 1.3605, 1.373, 1.2185, 1.405, 1.016, 0.979, 1.018, 1.0335, 1.39, 1.3005, 1.3955, 1.301, 1.6475, 1.1945, 1.3215, 1.0535, 1.1645, 1.0895, 1.041, 1.155, 1.322, 1.1615, 0.933, 1.1215, 1.022, 0.922, 0.8465, 1.103, 1.1375, 1.23, 1.289, 1.222, 1.4865, 1.4025, 1.4295, 1.156, 0.9085, 0.8755, 0.9135, 0.982, 1.145, 1.1295, 1.3475, 1.2415, 1.2505), .Names = c("1868", "1869", "1870", "1871", "1872", "1873", "1874", "1875", "1876", "1877", "1878", "1879", "1880", "1881", "1882", "1883", "1884", "1885", "1886", "1887", "1888", "1889", "1890", "1891", "1892", "1893", "1894", "1895", "1896", "1897", "1898", "1899", "1900", "1901", "1902", "1903", "1904", "1905", "1906", "1907", "1908", "1909", "1910", "1911", "1912", "1913", "1914", "1915", "1916", "1917", "1918", "1919", "1920", "1921", "1922", "1923", "1924", "1925", "1926", "1927", "1928", "1929", "1930", "1931", "1932", "1933", "1934", "1935", "1936", "1937", "1938", "1939", "1940", "1941", "1942", "1943", "1944", "1945", "1946", "1947", "1948", "1949", "1950", "1951", "1952", "1953", "1954", "1955", "1956", "1957", "1958", "1959", "1960", "1961", "1962", "1963", "1964", "1965", "1966", "1967", "1968", "1969", "1970", "1971", "1972", "1973", "1974", "1975", "1976", "1977", "1978", "1979", "1980", "1981", "1982", "1983", "1984", "1985", "1986", "1987", "1988", "1989", "1990", "1991", "1992", "1993", "1994", "1995", "1996", "1997", "1998", "1999", "2000", "2001", "2002", "2003", "2004", "2005", "2006", "2007", "2008", "2009", "2010", "2011")) with a vector like this: extr<-c(1834,1876,1901,1928,2006) The results must be like this: row.names MCG3 extr only for the extr values. is possible to do this with R? Thank you! -- --- Catalin-Constantin ROIBU Forestry engineer, PhD Forestry Faculty of Suceava Str. Universitatii no. 13, Suceava, 720229, Romania office phone +4 0230 52 29 78, ext. 531 mobile phone +4 0745 53 18 01 +4 0766 71 76 58 FAX: +4 0230 52 16 64 silvic.usv.ro [[alternative HTML version deleted]]
Dear Catalun, If I understood your description, please see ?"%in%" and try subset(x, names(x) %in% c(1834,1876,1901,1928,2006) ) where "x" is your data. HTH, Jorge.- On Wed, Mar 13, 2013 at 9:25 PM, catalin roibu <> wrote:> Hello all! > I have a problem with R. I try to merge data like this: > structure(c(2.1785, 1.868, 2.1855, 2.5175, 2.025, 2.435, 1.809, > 1.628, 1.327, 1.3485, 1.4335, 2.052, 2.2465, 2.151, 1.7945, 1.79, > 1.6055, 1.616, 1.633, 1.665, 2.002, 2.152, 1.736, 1.7985, 1.9155, > 1.7135, 1.548, 1.568, 1.713, 2.079, 1.875, 2.12, 2.072, 1.906, > 1.4645, 1.3025, 1.407, 1.5445, 1.437, 1.463, 1.5235, 1.609, 1.738, > 1.478, 1.573, 1.0465, 1.429, 1.632, 1.814, 1.933, 1.63, 1.482, > 1.466, 1.4025, 1.6055, 1.279, 1.827, 1.201, 1.425, 1.678, 1.5535, > 1.599, 1.826, 1.964, 1.68, 1.492, 1.509, 1.666, 1.5665, 1.666, > 1.4885, 1.8205, 1.5965, 1.84, 1.551, 1.4835, 1.805, 1.7145, 1.902, > 1.2085, 0.9095, 0.9325, 1.34, 1.6135, 1.5825, 1.757, 1.7105, > 1.3115, 1.288, 1.567, 1.7795, 1.642, 1.4375, 1.4495, 1.4225, > 1.4885, 1.251, 1.179, 1.188, 1.3605, 1.373, 1.2185, 1.405, 1.016, > 0.979, 1.018, 1.0335, 1.39, 1.3005, 1.3955, 1.301, 1.6475, 1.1945, > 1.3215, 1.0535, 1.1645, 1.0895, 1.041, 1.155, 1.322, 1.1615, > 0.933, 1.1215, 1.022, 0.922, 0.8465, 1.103, 1.1375, 1.23, 1.289, > 1.222, 1.4865, 1.4025, 1.4295, 1.156, 0.9085, 0.8755, 0.9135, > 0.982, 1.145, 1.1295, 1.3475, 1.2415, 1.2505), .Names = c("1868", > "1869", "1870", "1871", "1872", "1873", "1874", "1875", "1876", > "1877", "1878", "1879", "1880", "1881", "1882", "1883", "1884", > "1885", "1886", "1887", "1888", "1889", "1890", "1891", "1892", > "1893", "1894", "1895", "1896", "1897", "1898", "1899", "1900", > "1901", "1902", "1903", "1904", "1905", "1906", "1907", "1908", > "1909", "1910", "1911", "1912", "1913", "1914", "1915", "1916", > "1917", "1918", "1919", "1920", "1921", "1922", "1923", "1924", > "1925", "1926", "1927", "1928", "1929", "1930", "1931", "1932", > "1933", "1934", "1935", "1936", "1937", "1938", "1939", "1940", > "1941", "1942", "1943", "1944", "1945", "1946", "1947", "1948", > "1949", "1950", "1951", "1952", "1953", "1954", "1955", "1956", > "1957", "1958", "1959", "1960", "1961", "1962", "1963", "1964", > "1965", "1966", "1967", "1968", "1969", "1970", "1971", "1972", > "1973", "1974", "1975", "1976", "1977", "1978", "1979", "1980", > "1981", "1982", "1983", "1984", "1985", "1986", "1987", "1988", > "1989", "1990", "1991", "1992", "1993", "1994", "1995", "1996", > "1997", "1998", "1999", "2000", "2001", "2002", "2003", "2004", > "2005", "2006", "2007", "2008", "2009", "2010", "2011")) > > with a vector like this: extr<-c(1834,1876,1901,1928,2006) > The results must be like this: > row.names MCG3 extr > > only for the extr values. > > is possible to do this with R? > > Thank you! > -- > --- > Catalin-Constantin ROIBU > Forestry engineer, PhD > Forestry Faculty of Suceava > Str. Universitatii no. 13, Suceava, 720229, Romania > office phone +4 0230 52 29 78, ext. 531 > mobile phone +4 0745 53 18 01 > +4 0766 71 76 58 > FAX: +4 0230 52 16 64 > silvic.usv.ro > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >[[alternative HTML version deleted]]
On 13-03-2013, at 11:31, Jorge I Velez <jorgeivanvelez at gmail.com> wrote:> Dear Catalun, > > If I understood your description, please see ?"%in%" and try > > subset(x, names(x) %in% c(1834,1876,1901,1928,2006) ) > > where "x" is your data. >Or something like this x[names(x) %in% extr] where extr is the vector you mentioned. Berend> HTH, > Jorge.- > > > On Wed, Mar 13, 2013 at 9:25 PM, catalin roibu <> wrote: > >> Hello all! >> I have a problem with R. I try to merge data like this: >> structure(c(2.1785, 1.868, 2.1855, 2.5175, 2.025, 2.435, 1.809, >> 1.628, 1.327, 1.3485, 1.4335, 2.052, 2.2465, 2.151, 1.7945, 1.79, >> 1.6055, 1.616, 1.633, 1.665, 2.002, 2.152, 1.736, 1.7985, 1.9155, >> 1.7135, 1.548, 1.568, 1.713, 2.079, 1.875, 2.12, 2.072, 1.906, >> 1.4645, 1.3025, 1.407, 1.5445, 1.437, 1.463, 1.5235, 1.609, 1.738, >> 1.478, 1.573, 1.0465, 1.429, 1.632, 1.814, 1.933, 1.63, 1.482, >> 1.466, 1.4025, 1.6055, 1.279, 1.827, 1.201, 1.425, 1.678, 1.5535, >> 1.599, 1.826, 1.964, 1.68, 1.492, 1.509, 1.666, 1.5665, 1.666, >> 1.4885, 1.8205, 1.5965, 1.84, 1.551, 1.4835, 1.805, 1.7145, 1.902, >> 1.2085, 0.9095, 0.9325, 1.34, 1.6135, 1.5825, 1.757, 1.7105, >> 1.3115, 1.288, 1.567, 1.7795, 1.642, 1.4375, 1.4495, 1.4225, >> 1.4885, 1.251, 1.179, 1.188, 1.3605, 1.373, 1.2185, 1.405, 1.016, >> 0.979, 1.018, 1.0335, 1.39, 1.3005, 1.3955, 1.301, 1.6475, 1.1945, >> 1.3215, 1.0535, 1.1645, 1.0895, 1.041, 1.155, 1.322, 1.1615, >> 0.933, 1.1215, 1.022, 0.922, 0.8465, 1.103, 1.1375, 1.23, 1.289, >> 1.222, 1.4865, 1.4025, 1.4295, 1.156, 0.9085, 0.8755, 0.9135, >> 0.982, 1.145, 1.1295, 1.3475, 1.2415, 1.2505), .Names = c("1868", >> "1869", "1870", "1871", "1872", "1873", "1874", "1875", "1876", >> "1877", "1878", "1879", "1880", "1881", "1882", "1883", "1884", >> "1885", "1886", "1887", "1888", "1889", "1890", "1891", "1892", >> "1893", "1894", "1895", "1896", "1897", "1898", "1899", "1900", >> "1901", "1902", "1903", "1904", "1905", "1906", "1907", "1908", >> "1909", "1910", "1911", "1912", "1913", "1914", "1915", "1916", >> "1917", "1918", "1919", "1920", "1921", "1922", "1923", "1924", >> "1925", "1926", "1927", "1928", "1929", "1930", "1931", "1932", >> "1933", "1934", "1935", "1936", "1937", "1938", "1939", "1940", >> "1941", "1942", "1943", "1944", "1945", "1946", "1947", "1948", >> "1949", "1950", "1951", "1952", "1953", "1954", "1955", "1956", >> "1957", "1958", "1959", "1960", "1961", "1962", "1963", "1964", >> "1965", "1966", "1967", "1968", "1969", "1970", "1971", "1972", >> "1973", "1974", "1975", "1976", "1977", "1978", "1979", "1980", >> "1981", "1982", "1983", "1984", "1985", "1986", "1987", "1988", >> "1989", "1990", "1991", "1992", "1993", "1994", "1995", "1996", >> "1997", "1998", "1999", "2000", "2001", "2002", "2003", "2004", >> "2005", "2006", "2007", "2008", "2009", "2010", "2011")) >> >> with a vector like this: extr<-c(1834,1876,1901,1928,2006) >> The results must be like this: >> row.names MCG3 extr >> >> only for the extr values. >> >> is possible to do this with R? >> >> Thank you! >> -- >> --- >> Catalin-Constantin ROIBU >> Forestry engineer, PhD >> Forestry Faculty of Suceava >> Str. Universitatii no. 13, Suceava, 720229, Romania >> office phone +4 0230 52 29 78, ext. 531 >> mobile phone +4 0745 53 18 01 >> +4 0766 71 76 58 >> FAX: +4 0230 52 16 64 >> silvic.usv.ro >> >> [[alternative HTML version deleted]] >> >> ______________________________________________ >> R-help at r-project.org mailing list >> https://stat.ethz.ch/mailman/listinfo/r-help >> PLEASE do read the posting guide >> http://www.R-project.org/posting-guide.html >> and provide commented, minimal, self-contained, reproducible code. >> > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.