Note that there are some explanatory texts on larger screens.

plurals
  1. POChange data.frame format to label all columns
    primarykey
    data
    text
    <p>I have run into this problem before and had a lengthy work around, now I thought to post here. Thanks in advance!</p> <p>I am trying to <code>merge()</code> the following small data.frame (named HelpData) with a much larger data.frame (not included). The code below reads in HelpData, and looks at the <code>head()</code> and the <code>str()</code>.</p> <pre><code>HelpData &lt;- structure(list(`(Intercept)` = c(-0.416714383410771, -0.484420889203111, 0.8852233181836, -0.00573901277840992, 0.819352447999715, -0.0219740206432874, -0.725659038472068, 0.842129479134587, 0.231330671497113, 1.67161285063258, 0.562139877718068, -0.56702368527195, -1.09763116254353, -0.32410756195596, 0.166964590752782, -0.812461815971089, -0.609301958979508, 0.368263149194526, 0.964304770606394, -0.887610418600415, -0.555998527038864, -0.0940912475713328, 0.706094048452952, -0.500888453405431)), .Names = "(Intercept)", row.names = c("CAL_F01", "CAL_F17", "CAL_F19", "CAL_F23", "CAL_F43", "CAL_M33", "CAL_M36", "COL_P01", "COL_P03", "COL_P05", "COL_P06", "COL_P07", "COL_P08", "COL_P09", "COL_P10", "COL_P12", "COL_P13", "PAT_F02", "PAT_F03", "PAT_F04", "PAT_F05", "PAT_M02", "PAT_M03", "PAT_M04"), class = "data.frame") head(HelpData) str(HelpData) </code></pre> <p>As seen in the <code>str()</code> of HelpData, the object is a data frame with 24 obs. of 1 variable. The “Intercept” column is the only one that is recognized. However I want to <code>merge()</code> based on the AnimalID field which is not labeled. The code below results in the error </p> <p>Code:</p> <pre><code> colnames(HelpData)&lt;- c("CougarID", "RandInt") </code></pre> <p>Error:</p> <pre><code> “'names' attribute [2] must be the same length as the vector [1]” This the first coumne is not regonized and thus cannot be named. </code></pre> <p>What is the best what to change the data format so I can have the same two columns, but the ability to name the first?</p> <p>Cheers.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload