elp [mailto:r-help-boun...@r-project.org] On Behalf Of Curtis
> Burkhalter
> Sent: Friday, March 06, 2015 10:01 PM
> To: Tom Wright
> Cc: r-help@r-project.org
> Subject: Re: [R] problem with function that adds rows to dataframe
> based on conditional statement
>
> Hey Tom,
Hey Tom,
This solution works great, but if I try to then insert it in my function
that I've displayed above and apply it to my split dataframe I get the
error message:
Error in `[.default`(xj, i) : invalid subscript type 'list'
The reason why I need to try and get this to work within the functio
If all you want is to add a row of na's could you just do something
like:
nExpectedRows<-length(unique(animals)) * length(unique(animalYears)) * 2
newDf<-data.frame(animals=rep(NA,nExpectedRows-nrow(comAn)),
animalYears=rep(NA,nExpectedRows-nrow(comAn)),
animal
;
> > -Original Message-
> > From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Curtis
> > Burkhalter
> > Sent: Thursday, March 05, 2015 9:42 PM
> > To: r-help@r-project.org
> > Subject: [R] problem with function that adds rows to dataframe
R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Curtis
> Burkhalter
> Sent: Thursday, March 05, 2015 9:42 PM
> To: r-help@r-project.org
> Subject: [R] problem with function that adds rows to dataframe based on
> conditional statement
>
> Hello everyone,
>
> I
Why should he? seq_len() is part of base R.
On Thursday, March 5, 2015, JS Huang wrote:
> Hi Curtis,
>
> Maybe you forgot to tell us how the function seq_len is defined.
>
>
>
> -
> JS Huang
> --
> View this message in context:
> http://r.789695.n4.nabble.com/problem-with-function-that-add
Hi Curtis,
Maybe you forgot to tell us how the function seq_len is defined.
-
JS Huang
--
View this message in context:
http://r.789695.n4.nabble.com/problem-with-function-that-adds-rows-to-dataframe-based-on-conditional-statement-tp4704228p4704237.html
Sent from the R help mailing list
Hello everyone,
I'm having a problem with a function that I wrote that is supposed to add a
row to dataframe based upon a conditional statement. To explain I've used
an example below:
#create data frame
animals=c("bird","dog","cat")
animals=rep(animals,each=4)
animals=animals[1:11]
animalYears=c(
8 matches
Mail list logo