Hi,
I have (x, y) data as the follows (saved in the txt file):
x y
1 8
2 5
3 3
4 +
5 -1
6 +
When I read this txt file into R and attach this data, I found the output of y
is as the follows
[1] 8 5 3 + -1 +
Levels: -1 + 3 5 8
Could I get rid of Levels in the output? Because I need
Dear R users,
Does Elasticnet (package "elasticnet") handle the missing value in predictors
? If some one can provide the way to hadle missing value, it will great.
Thanks in advance.
Sincerely,
Ram Kumar Basnet
Wageningen University,
The Netherlands
[[alternative HTML ver
kate uiuc.edu> writes:
[snip]
>
> When I read this txt file into R and attach this data, I found the output of y
is as the follows
> [1] 8 5 3 + -1 +
> Levels: -1 + 3 5 8
>
> Could I get rid of Levels in the output? Because I need to use the observed y
and x run regression first and t
Hello dear R people,
for my MSc thesis I need to program some functions, and some of them
simply do not work. In the following example, I made sure both vectors
have the same length (10), but R gives me the following error:
Error in if (vector1[i] == vector2[j]) { :
missing value where TRUE
Hi all R user,
Suppose I have daily time series value for two assets. However for some days
value of 1 asset is missing whereas for some of the other days values of other
asset are missing. Can anyone tell me what would be effective way by using
statistical analysis to fill up those gaps b
is this what you want?
> vector1
[1] 65 1 34 100 42 20 79 43 89 10
> vector2
[1] 34 65 47 91 48 32 23 74 92 86
>
> for (i in 1:10) {
+ for (j in 1:10) {
+ if (vector1[i] == vector2[j])
+ show(c(i,j))
+ }
+ }
[1] 1 2
[1] 3 1
On Sat, Nov 8, 2008
It would be useful to learn how to use debug/browser. Here is the
state of the machine when the error occurs:
> test()
Error in if (vector1[i] == vector2[j]) { :
missing value where TRUE/FALSE needed
Enter a frame number, or 0 to exit
1: test()
Selection: 1
Called from: eval(expr, envir, enc
They may be the same length; that's not what the error message is
complaining about: it says there is a missing value (i.e., an NA) where
a TRUE/FALSE value is needed, therefore the 'if' doesn't know what to
do, since it is not TRUE or FALSE. So, try
summary(vector1)
summary(vector2)
sum(is.
To answer the actual question, your i and j indices are not what you expect (but are what
you specify).
Consider the following, which follows your algorithm:
> vector1 <- sample(1:100,2)
> vector2 <- sample(1:100,2)
> for (i in vector1) {
+ for (j in vector2) {
+ show(c(i, j))
+ }
+ }
[
9 matches
Mail list logo