[R] Different varable lengths
Sarah Goslee
sarah.goslee at gmail.com
Mon Apr 30 23:06:19 CEST 2012
Because of the missing comma.
On Mon, Apr 30, 2012 at 4:56 PM, John Kane <jrkrideau at inbox.com> wrote:
>> length(Sweden.GDP.gap.adjust)
> [1] 8
>> Sweden.GDP.gap.adjust
> [1] 0.673792123 1.196706756 1.196131539 0.646944002 -0.312886525
> [6] -1.706584861 -0.369401194 -0.003280389
>
> R is reading Sweden.GDP.gapp.adjust as having 8 elements. Why I don't know.
> John Kane
> Kingston ON Canada
>
>
>> -----Original Message-----
>> From: bahman.zadeh at comhem.se
>> Sent: Mon, 30 Apr 2012 02:43:32 -0700 (PDT)
>> To: r-help at r-project.org
>> Subject: [R] Different varable lengths
>>
>> Hi!
>>
>> I'm trying to do a lm() test on three objects. My problem is that R
>> protests
>> and says that the variable lengths differ for one of the objects
>> (Sweden.GDP.gap). But I have double checked that the number of
>> observations
>> are the same. All three objects should contain 9 observations but R only
>> accepts 9 observations in two of the objects. The third must have 10!
>> Very
>> confusing because there is no 10th observation!
>>
>> # Adjusted Real rate - P
>>> Sweden.p.adjust <- c(4.70243, 1.3776655, 1.117755, 1.6695175, 1.59282,
>>> 1.1017625, -0.04295, 2.2552875, 0.0552875)
>>>
>>> # Adjusted Inflation deviation
>>> Sweden.infl.dev.adjust <- c(0.110382497, -0.261612509, 0.040847515,
>>> -0.195062497, -0.234362485, -0.023408728, 0.206421261, -0.079401261,
>>> 0.071828752)
>>>
>>> # Adjusted GDP-gap
>>> Sweden.GDP.gap.adjust <- c(0.673792123, 1.196706756, 1.196131539,
>>> 0.646944002, -0.312886525, -1.180620213 -0.525964648, -0.369401194,
>>> -0.003280389)
>>>
>>> # OLS regression using ADJUSTED data.#
>>> Sweden.Taylor.real.adjust <- lm(Sweden.p.adjust ~ Sweden.infl.dev.adjust
>>> +
>>> Sweden.GDP.gap.adjust)
>> Error in model.frame.default(formula = Sweden.p.adjust ~
>> Sweden.infl.dev.adjust + :
>> variable lengths differ (found for 'Sweden.GDP.gap.adjust')
>>
>> Why is this happening?
>>
>> / Saint
>>
>>
--
Sarah Goslee
http://www.functionaldiversity.org
More information about the R-help
mailing list