Re: [R] replacement has *** rows, data has ***

2017-06-12 Thread William Dunlap via R-help
This can happen if there are rows containing missing values (NA's) in the data used to fit the model. Use na.action=na.exclude when fitting the model instead of the default na.action=na.omit to make the prediction vector line up with the input data instead of lining up with the input data after th

Re: [R] replacement has *** rows, data has ***

2017-06-12 Thread David Winsemius
> On Jun 12, 2017, at 1:32 PM, Manqing Liu wrote: > > Hi all, > > I created a predicted variable based on a model, but somehow not all > observations have a predicted value. When I tired to add the predicated > value to the main data set (data$pr <- pr) , it said: > replacement has 34333 rows,

[R] replacement has *** rows, data has ***

2017-06-12 Thread Manqing Liu
Hi all, I created a predicted variable based on a model, but somehow not all observations have a predicted value. When I tired to add the predicated value to the main data set (data$pr <- pr) , it said: replacement has 34333 rows, data has 34347. Do you know how to solve that? Thanks, Manqing

Re: [R] replacement has 0 rows, data has 2809

2016-06-20 Thread Jim Lemon
Hi Humberto, It may simply be that the file is C(omma)SV format and the default separator for read.delim is a TAB character. Try read.csv. Jim On Tue, Jun 21, 2016 at 2:14 AM, Humberto Munoz Barona wrote: > Hi Jim, > Thanks for your reply. length(lens) gives me 6, which is the size of lens in

Re: [R] replacement has 0 rows, data has 2809

2016-06-18 Thread Jim Lemon
Hi Humberto, The "0 row" error usually arises from a calculation in which a non-existent object is used. I see that you have created a vector with the name "lens" and that may be where this is happening. Have a look at: length(lens) or if it is not too long, just: lens If it is zero length, tha

Re: [R] Replacement Value

2014-04-09 Thread arun
Hi Dila, If 'dat' is the dataset: dat$C[dat$B==0] <- 0  A.K. On Wednesday, April 9, 2014 1:30 AM, dila radi wrote: Dear arun Yes indeed..if the value in B is O..next value in the same row also 0.. other value than 0 remains unchanged. On Apr 9, 2014 12:48 PM, "arun" wrote: Dear Dila, > >What

Re: [R] Replacement Value

2014-04-07 Thread Jim Lemon
On 04/08/2014 01:46 PM, dila radi wrote: Hi all, I have problem on how to replace value. I have this kind of data set: structure(list(A = c(0, 12.6, 10.1, 8.1, 14.4, 0, 0, 0, 0, 0.5, 12.9, 25.9, 49, 0, 0, 0, 0, 0, 7.8), B = c(0, 0, 9.1, 9.3, 1.5, 1, 1, 1, 1.7, 6, 0, 0, 0, 1.7, 3.8, 0, 0, 0, 1),

[R] Replacement Value

2014-04-07 Thread dila radi
Hi all, I have problem on how to replace value. I have this kind of data set: structure(list(A = c(0, 12.6, 10.1, 8.1, 14.4, 0, 0, 0, 0, 0.5, 12.9, 25.9, 49, 0, 0, 0, 0, 0, 7.8), B = c(0, 0, 9.1, 9.3, 1.5, 1, 1, 1, 1.7, 6, 0, 0, 0, 1.7, 3.8, 0, 0, 0, 1), C = c(1, 1, 9.10004, 9.2, 1.5,

Re: [R] Replacement function using grouping variable

2013-09-19 Thread PIKAL Petr
Hi > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- > project.org] On Behalf Of Alecia M Moser > Sent: Thursday, September 19, 2013 7:01 AM > To: r-help@r-project.org > Subject: [R] Replacement function using grouping variable >

[R] Replacement function using grouping variable

2013-09-18 Thread Alecia M Moser
Hello - I am looking for a function that would allow me to replace specific columns in one data frame with columns in another data frame using a grouping variable. df <- read.csv("data.csv", header=T) df1 <- aggregate(df[, c(8,9,10,11,12,27,28)], by=list(df$ID), FUN=function(x) sub("(.*):", "\\1.

Re: [R] replacement functions for subsets

2013-07-10 Thread Harry Mamaysky
; > twoTimes(p[1:2]) <- c(100,102) > Calling twoTimes<-: x= 1:2 > > p > [1] 50 51 3 4 5 > > > Bill Dunlap > Spotfire, TIBCO Software > wdunlap tibco.com > > > > -Original Message- > > From: r-help-boun...@r-project.org [mailto:r-help

Re: [R] replacement functions for subsets

2013-07-10 Thread William Dunlap
ling twoTimes<-: x= 1:2 > p [1] 50 51 3 4 5 Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On > Behalf > Of Harry Mamaysky > Sent: Wednesday, July 10, 2

Re: [R] replacement functions for subsets

2013-07-10 Thread Harry Mamaysky
So how would I get the following to work? > aa<-1 > aa [1] 1 > 'foo<-' <- function(x,value) x<-value > foo(aa)<-1:10 > aa [1] 1 2 3 4 5 6 7 8 9 10 > # This doesn't work: > foo(aa)[4:5] <- c(101,102) Error in foo(aa)[4:5] <- c(101, 102) : could not find function "foo" > # What I would like

Re: [R] replacement functions for subsets

2013-07-10 Thread Bert Gunter
I think the OP may perhaps want to define a method for "[<-" . e.g. try: methods("[<-") If this is not it ... ?? Cheers, Bert On Wed, Jul 10, 2013 at 12:51 PM, David Winsemius wrote: > > On Jul 10, 2013, at 12:17 PM, Harry Mamaysky wrote: > >> As I understand it rownames(aa) returns a copy of

Re: [R] replacement functions for subsets

2013-07-10 Thread David Winsemius
On Jul 10, 2013, at 12:17 PM, Harry Mamaysky wrote: > As I understand it rownames(aa) returns a copy of an attribute of aa. So > changing the value of this vector should make the change to the copy of the > row.names attribute. I would then have to set the original row.names equal to > this co

Re: [R] replacement functions for subsets

2013-07-10 Thread Harry Mamaysky
As I understand it rownames(aa) returns a copy of an attribute of aa. So changing the value of this vector should make the change to the copy of the row.names attribute. I would then have to set the original row.names equal to this copy to effect the change. So my question is why "rownames(aa)[

Re: [R] replacement functions for subsets

2013-07-10 Thread David Winsemius
On Jul 10, 2013, at 11:47 AM, Harry Mamaysky wrote: > I know how to define replacement functions in R (i.e. ‘foo<-‘ <- > function(x,value) x<-value, etc.), but how do you define replacement > functions that operate on subsets of arrays (i.e. how do you pass an index > into foo)? > For example,

[R] replacement functions for subsets

2013-07-10 Thread Harry Mamaysky
I know how to define replacement functions in R (i.e. ‘foo<-‘ <- function(x,value) x<-value, etc.), but how do you define replacement functions that operate on subsets of arrays (i.e. how do you pass an index into foo)? For example, why does the following use of “rownames” work? > aa <-

Re: [R] replacement has length zero. In addition: Warning message: In max(i) : no non-missing arguments to max; returning -Inf

2012-08-03 Thread Sarah Goslee
On Fri, Aug 3, 2012 at 5:14 PM, Yolande Tra wrote: >> i=10 >> thisStamp <- as.POSIXct(strptime(diveCond$timestamp[i], "%Y-%m-%d >> %H:%M:%S")) >> thisStamp > [1] "2008-08-11 14:12:00 EDT" >> ind <- which.min( abs(index(regCond_all) - thisStamp )) >> >> ind > [1] 506 >> diveCond$r_wvht[i] > [1] 0

Re: [R] replacement has length zero. In addition: Warning message: In max(i) : no non-missing arguments to max; returning -Inf

2012-08-03 Thread Yolande Tra
> i=10 > thisStamp <- as.POSIXct(strptime(diveCond$timestamp[i], "%Y-%m-%d %H:%M:%S")) > thisStamp [1] "2008-08-11 14:12:00 EDT" > ind <- which.min( abs(index(regCond_all) - thisStamp )) > > ind [1] 506 > diveCond$r_wvht[i] [1] 0 > regCond_all$WVHT[ind] WVHT 2008-08-11 14:22:0

Re: [R] replacement has length zero. In addition: Warning message: In max(i) : no non-missing arguments to max; returning -Inf

2012-08-03 Thread Sarah Goslee
This runs, so there must be something else going on that you haven't told us about. diveCond <- structure(list(dive_id = c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10), timestamp = c("2008-08-06 08:49:00", "2008-08-06 10:03:00", "2008-08-06 10:25:00", "2008-08-08 09:42:00", "2008-08-08 10:53:00", "2008-08-08 1

Re: [R] replacement has length zero. In addition: Warning message: In max(i) : no non-missing arguments to max; returning -Inf

2012-08-03 Thread arun
; not found   From a glance, I guess you should have posted with "u" in place of regCond_all for the loop.  A.K. - Original Message - From: Yolande Tra To: R help Cc: Sent: Friday, August 3, 2012 3:49 PM Subject: [R] replacement has length zero. In addition: Warning message:

Re: [R] replacement has length zero. In addition: Warning message: In max(i) : no non-missing arguments to max; returning -Inf

2012-08-03 Thread Yolande Tra
> dput(head(diveCond, 10)) structure(list(dive_id = c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10), timestamp = c("2008-08-06 08:49:00", "2008-08-06 10:03:00", "2008-08-06 10:25:00", "2008-08-08 09:42:00", "2008-08-08 10:53:00", "2008-08-08 12:42:00", "2008-08-11 10:10:00", "2008-08-11 11:01:00", "2008-08-11 11:

Re: [R] replacement has length zero. In addition: Warning message: In max(i) : no non-missing arguments to max; returning -Inf

2012-08-03 Thread Sarah Goslee
When i == 10, what is ind? diveCond$r_apt[10] regCond_all$APD[ind] Providing a subset is unhelpful. I gave you explicit dput() code to use; that's how we need data to be provided. I've given you various suggestions; if you don't implement them then there's not much point in me trying to help. Sa

Re: [R] replacement has length zero. In addition: Warning message: In max(i) : no non-missing arguments to max; returning -Inf

2012-08-03 Thread Yolande Tra
I have tried 1 and 2. Then for i=10, the error came back > i=1 > thisStamp <- as.POSIXct(strptime(diveCond$timestamp[1], "%Y-%m-%d %H:%M:%S")) > ind <- which.min( abs(index(regCond_all) - thisStamp )) > diveCond$r_wvht[1]<- regCond_all$WVHT[ind] > diveCond$r_dpd[1]<- regCond_all$DPD[ind] > diveCond

Re: [R] replacement has length zero. In addition: Warning message: In max(i) : no non-missing arguments to max; returning -Inf

2012-08-03 Thread Sarah Goslee
Yolande, Please send your message to the R-help email list too, not just to me. On Fri, Aug 3, 2012 at 4:28 PM, Yolande Tra wrote: > Here is the description > I am trying to build the data diveCond from two datasets diveData_2008, > diveData_2009 and RegCond_all. How would I dput each data for

Re: [R] replacement has length zero. In addition: Warning message: In max(i) : no non-missing arguments to max; returning -Inf

2012-08-03 Thread Sarah Goslee
On Fri, Aug 3, 2012 at 4:04 PM, Yolande Tra wrote: > I am sorry I forgot to mention it in the code. > library(xts) has the function index. That's useful. But here's your first problem: thisStamp <- as.POSIXct(strptime(diveCond$timestamp[i], "%Y-%m-%d %H:%M:%S")) You just created diveCond as a d

Re: [R] replacement has length zero. In addition: Warning message: In max(i) : no non-missing arguments to max; returning -Inf

2012-08-03 Thread Yolande Tra
' not found > > u=regCond_all[1:10,] > Error: object 'regCond_all' not found > > > From a glance, I guess you should have posted with "u" in place of > regCond_all for the loop. > > A.K. > > - Original Message - > From: Yolande

Re: [R] replacement has length zero. In addition: Warning message: In max(i) : no non-missing arguments to max; returning -Inf

2012-08-03 Thread Sarah Goslee
Hi Yolande, What's index() ? I get > ind <- which.min( abs(index(regCond_all) - thisStamp )) Error in which.min(abs(index(regCond_all) - thisStamp)) : could not find function "index" There's probably an easier way to do whatever you're trying to accomplish, but I'm afraid I can't tell what th

[R] replacement has length zero. In addition: Warning message: In max(i) : no non-missing arguments to max; returning -Inf

2012-08-03 Thread Yolande Tra
Hi, Here is my data, the first 10 rows > u=regCond_all[1:10,] > dput(u) structure(c(999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 1.9, 2, 1.97, 1.99, 1.83, 1.78, 1.6, 1.52, 1.52, 1.36, 10.53, 9.88, 9.88, 10.53, 10

Re: [R] replacement has length zero

2012-07-11 Thread fabiano
Thanks Peter. We did manage to solve the problem using the approach bellow. Hab <- cbind(seq(1,21),habitat) hab <- matrix(NA,nrow=3,ncol=7) for (i in 1:3) {hab[i,] <- Hab[habitat==i,1]} The problem was that the hab matrix was not a multiple of habitat. -- View this message in context: ht

Re: [R] replacement has length zero

2012-07-08 Thread Peter Ehlers
On 2012-07-08 06:57, fabiano wrote: Thanks Peter. We had a look at both Hab and habitat. These are integers representing habitat types. habitat <- read.csv("Ungulate_vegetation.csv") habitat <- habitat[,3] habitat [1] 3 3 4 3 3 3 4 4 3 3 3 3 3 4 2 3 2 3 2 3 Hab <- cbind(seq(1,20),habitat) Hab

Re: [R] replacement has length zero

2012-07-08 Thread fabiano
Thanks Peter. We had a look at both Hab and habitat. These are integers representing habitat types. habitat <- read.csv("Ungulate_vegetation.csv") habitat <- habitat[,3] habitat [1] 3 3 4 3 3 3 4 4 3 3 3 3 3 4 2 3 2 3 2 3 Hab <- cbind(seq(1,20),habitat) Hab habitat [1,] 1 3 [2

Re: [R] replacement has length zero

2012-07-07 Thread Peter Ehlers
On 2012-07-07 03:19, fabiano wrote: I have been working on the following code but keep getting an err message. My current thinking is that the problem is on the indexing but do not know how to fix it. Any help please? ungulate <- read.csv("Ungulate.csv",row.names=1) ungulate <- as.matrix(ungulat

Re: [R] replacement has length zero

2012-07-07 Thread Jeff Newmiller
Your request fails the reproducibility requirement from the posting guide, because you have not supplied enough data to run the code and reproduce the error. --- Jeff NewmillerThe . .

[R] replacement has length zero

2012-07-07 Thread fabiano
I have been working on the following code but keep getting an err message. My current thinking is that the problem is on the indexing but do not know how to fix it. Any help please? ungulate <- read.csv("Ungulate.csv",row.names=1) ungulate <- as.matrix(ungulate);colnames(ungulate)<-NULL;rownames(u

Re: [R] replacement has 13665 rows, data has 13664

2011-12-20 Thread Duncan Murdoch
On 11-12-20 12:22 AM, Nicole Marie Ford wrote: Hello, all. I have come across a problem. Previously, when I recoded my DV, added the variable to my dataset and ran the multinom, I was just fine. But I am doing it again and I am getting this error. R> Poland$trust<- trust Error in `$<-.data

[R] replacement has 13665 rows, data has 13664

2011-12-19 Thread Nicole Marie Ford
Hello, all. I have come across a problem. Previously, when I recoded my DV, added the variable to my dataset and ran the multinom, I was just fine. But I am doing it again and I am getting this error. R> Poland$trust <- trust Error in `$<-.data.frame`(`*tmp*`, "trust", value = c(NA, NA, NA, N

[R] replacement bootstrapping

2011-02-03 Thread Mhairi
Hi there I am looking at the functional response (the consumption of single predators of prey over a range of prey densities) and Im having issues with the following script when trying to obtain mutliple replicates of coefficients (a and h) from the following nls model based on Hollings disc equ

[R] optimized R-selection and R-replacement inside a matrix

2010-02-08 Thread Christine SINOQUET
Hello, I need to modify some huge arrays (2000 individuals x 50 000 variables). To format the data, I think I should benefit from optimized R-selection and R-replacement inside a matrix and prohibite a naive use of loops. Thank you in advance for providing information about the following

[R] optimized R-selection and R-replacement inside a matrix need, strings coerced to factors

2010-02-07 Thread Christine SINOQUET
Hello, I need to modify some huge arrays (2000 individuals x 50 000 variables). To format the data, I think I should benefit from optimized R-selection and R-replacement inside a matrix and prohibite a naive use of loops. Thank you in advance for providing information about the following

[R] optimized R-selection and R-replacement inside a matrix need, strings coerced to factors

2010-02-06 Thread Christine SINOQUET
Hello, I encounter two problems : First, I need to modify some huge arrays (2000 individuals x 50 000 variables). To format the data, I think I should benefit from optimized R-selection and R-replacement inside a matrix and prohibite a naive use of loops. Thank you in advance for

Re: [R] replacement

2007-10-19 Thread John Kane
mydata[is.na(mydata)] <- NaN should work --- Samor Gandhi <[EMAIL PROTECTED]> wrote: > Hi, Is it possible to do the following > > > mydata >yx > 1 0.3 1 > 2 0.8 NA > 3 NA 0 > 4 0.2 1 > > I would like to solve > > mydata <- replace(mydata, NA, NaN) > > Thanks!

Re: [R] replacement

2007-10-19 Thread Uwe Ligges
mydata[is.na(mydata)] <- NaN Uwe Ligges Samor Gandhi wrote: > Hi, Is it possible to do the following > >> mydata >yx > 1 0.3 1 > 2 0.8 NA > 3 NA 0 > 4 0.2 1 > > I would like to solve > > mydata <- replace(mydata, NA, NaN) > > Thanks! > ___

[R] replacement

2007-10-19 Thread Samor Gandhi
Hi, Is it possible to do the following > mydata yx 1 0.3 1 2 0.8 NA 3 NA 0 4 0.2 1 I would like to solve mydata <- replace(mydata, NA, NaN) Thanks! __ [[alternative HTML version deleted]] ___