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
> 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,
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
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
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
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
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),
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,
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
>
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.
; > 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
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
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
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
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
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)[
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,
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 <-
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
> 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
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
; 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:
> 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:
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
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
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
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
' 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
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
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
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
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
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
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
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 . .
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
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
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
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
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
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
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
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!
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!
> ___
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]]
___
45 matches
Mail list logo