format - R: "undefined columns selected" error after check.names=FALSE? -


brand new r; trying data read in , reshaped properly. file format has 7 columns of "id"-ish data, sixty columns of annual growth values, columns labelled year. first pass was:

> firstdata <- read.csv("~/thedata.csv")   > nudata <- melt(firstdata, id=1:7) 

that made right arrangement read.csv() had prepended x years ("x1983", e.g.), don't work values. that, so:

> firstdata <- read.csv("~/thedata.csv",check.names = false)   > nudata <- melt(firstdata, id=1:7)   error in `[.data.frame`(data, , x) : undefined columns selected 

the xs kept away (plain "1983", etc.), won't melt(). many retries; lots of reference-consulting; hard figure out right way find answer. seems think structure okay:

> is.data.frame(firstdata) [1] true > ncol(firstdata) [1] 71 

i suspect bare-number column labels 8-71 throwing it. how reassure everything's fine?

edit
didn't want dump data-mess if answer offhand, here's sample. thought i'd figured out when found spaces in column labels... fixed them , still same error. problem rows don't have values in 2016 column?

tree,gap,transx,transy,dbh,nodes,ht,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,2012,2013,2014,2015,2016, 1,1,3,0,4.4,23,366,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,7,3,3,7,3,4,4,13,7,23,17,34,25,30,23,19,25,22,29,28,20,14,6, 2,1,4,0,3.3,24,398,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,12,11,16,10,7,7,16,13,16,12,25,14,24,21,20,22,20,24,15,27,18,17,15,16, 3,1,5,2,2.8,24,325,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,5,7,16,8,6,16,18,10,17,7,21,10,14,12,16,14,23,15,21,20,14,14,12,9, 4,1,5,2.5,3.5,22,388,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,6,6,5,5,15,9,12,13,29,16,20,13,17,19,27,25,13,31,32,26,26,23, 5,1,10.2,0,9.5,43,739,,,,,,,,,,,,,,,,,,,,,16,18,9,14,18,13,14,10,6,8,8,10,12,11,13,11,6,6,7,8,8,9,11,13,20,27,17,23,11,38,21,29,27,31,29,19,23.1,22,33,40,24,22,24, 


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -