[R] Odp: cbind with vectors of different lengths?
petr.pikal at precheza.cz
Thu Jun 10 10:52:24 CEST 2010
you shall use na.action = "na.exclude" option in your lm call?
r-help-bounces at r-project.org napsal dne 10.06.2010 01:12:55:
> Hello R help
> I have a dataframe, with 71 samples (rows) and 30 variables. I got
> models for some of the variables, and I want to join fitted and
> these models to the data frame. Sometimes, these vectors have the same
> of the dependant variable, but in a few cases, NA values can be found on
> data, and therefore, both fitted and residuals have a few rows less than
> original data frame. As I try cbind, R answers with error, because both
> vectors have different lenghts. I have tried with merge but... suddenly
> a lot of rows of repeated values. I think (with my small idea of R and
> manuals and helps I did read) that first, I have to force residuals and
> of my model to be a data frame.
> this gives, for example
>  1.1
>  3.8
>  1.3
>  0.9
> instead of the original fitted(lm)
> 1 3 4 5
> 1.1 3.8 1.3 0.9
> that I want to join to my data frame
>  17.0
>  15.2
>  17.3
>  15.0
>  17.4
> as you can see, row 2 does not exist in fitted... how can I tell R to
> this row as NA, as below?
>  17.0 1.1
>  15.2 NA
>  17.3 3.8
>  15.0 1.3
>  17.4 0.9
> thanks and greets.
> Arantzazu Blanco Bernardeau
> Dpto de Química Agrícola, Geología y Edafología
> Universidad de Murcia-Campus de Espinardo
> ¿Un navegador seguro buscando estás? ¡Protegete ya en
> R-help at r-project.org mailing list
> PLEASE do read the posting guide
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help