Skip to content
Back to formatted view

Raw Message

Message-ID: <BAY135-W49BE0AE37BF4C6B3399432888D0@phx.gbl>
Date: 2009-03-30T10:19:49Z
From: Steve Murray
Subject: Column name assignment problem
In-Reply-To: <644e1f320903271645m37d4e9a4j45f50587f7957f73@mail.gmail.com>

Jim and all,

Thanks - I managed to get it working based on your helpful advice.

I'm now trying to do something very similar which simply involves changing the names of the variables in column 1 to make them more succinct. I'm trying to do this via the 'levels' command as I figured that I might be able to apply the character strings in a similar way to how you recommended when dealing with 'colnames'.


# Refine names of rivers to make more succinct
          riv_names <- get(paste("arunoff_",table_year, sep=''))[,1]
          levels(riv_names) <- c("AMAZON", "AMUR", "CONGO", "LENA", "MISSISSIPPI", "NIGER", "NILE", "OB", "PARANA", "YANGTZE", "YENISEI", "ZAMBEZI")
          assign(get(paste("arunoff_",table_year, sep='')[,1], levels(riv_names)))

Error in paste("arunoff_", table_year, sep = "")[, 1] : 
  incorrect number of dimensions

My thinking was to assign the levels of riv_names to column 1 of the table...

Many thanks again for any advice offered,

Steve