m_fac1 | ds_temp$closed_sls_fac1 #
>> > WRONG
>> >
>> > # 3rd try
>> > closed_mdm_num1 <- as.numeric(closed_mdm) # OK
>> > closed_sls_num1 <- as.numeric(closed_sls) # OK
>> >
>> > ds_temp3 <- data.frame(cust_id, closed_md
due to not allowed NA in subscripts
> > ds_temp4[is.na(ds_temp4$closed_mdm_num1), ds_temp4$closed_mdm_num1] <- 0
> > ds_temp4[is.na(ds_temp4$closed_sls_num1), ds_temp4$closed_sls_num1] <- 0
> >
> > # 5th try
> > ds_temp4$closed_mdm_num1 <- ifelse(is.na(ds_temp4
s_temp4[is.na(ds_temp4$closed_sls_num1), ds_temp4$closed_sls_num1] <- 0
>
> # 5th try
> ds_temp4$closed_mdm_num1 <- ifelse(is.na(ds_temp4$closed_mdm_num1), 1, 0)
> ds_temp4$closed_sls_num1 <- ifelse(is.na(ds_temp4$closed_sls_num1), 1, 0)
> ds_temp4
>
> ds_temp4$clos
_temp$closed_mdm_num1 | ds_temp$closed_sls_num1 #
>WRONG
>
># 4th try
>ds_temp4 <- ds_temp3
>ds_temp4
>
># Does not run due to not allowed NA in subscripts
>ds_temp4[is.na(ds_temp4$closed_mdm_num1), ds_temp4$closed_mdm_num1] <- 0
>ds_temp4[is.na(ds_temp4$closed_s
> 1 1A NA
> 2 0b NA
> 3 2 NA
>
> David C
>
> -Original Message-
> From: Bert Gunter [mailto:bgunter.4...@gmail.com]
> Sent: Thursday, June 23, 2016 1:48 PM
> To: David L Carlson
> Cc: Ivan Calandra; R Help
> Subject: Re: [R] Subscripting problem with i
Behalf Of
> g.maub...@gmx.de
> Sent: Friday, June 24, 2016 9:15 AM
> To: Bert Gunter
> Cc: R Help
> Subject: Re: [R] Subscripting problem with is.na()
>
> Hi Bert,
>
> many thanks for all your help and your comments. I learn at lot this way.
>
> My question was about is.n
mp4$closed_mdm_num1 <- ifelse(is.na(ds_temp4$closed_mdm_num1), 1, 0)
ds_temp4$closed_sls_num1 <- ifelse(is.na(ds_temp4$closed_sls_num1), 1, 0)
ds_temp4
ds_temp4$closed <- ifelse(ds_temp4$closed_mdm_num1 == 1 |
ds_temp4$closed_sls_num1 == 1, 1, 0)
ds_temp4
-- cut --
Is there a better way t
t; 3 2 NA
>
> David C
>
> -Original Message-
> From: Bert Gunter [mailto:bgunter.4...@gmail.com]
> Sent: Thursday, June 23, 2016 1:48 PM
> To: David L Carlson
> Cc: Ivan Calandra; R Help
> Subject: Re: [R] Subscripting problem with is.na()
>
> Not in general,
A
David C
-Original Message-
From: Bert Gunter [mailto:bgunter.4...@gmail.com]
Sent: Thursday, June 23, 2016 1:48 PM
To: David L Carlson
Cc: Ivan Calandra; R Help
Subject: Re: [R] Subscripting problem with is.na()
Not in general, David:
e.g.
> test <- data.frame(a=c(1,NA,2),
7 77
> 8 00
> 9 99
> 10 10 10
>
> -
> David L Carlson
> Department of Anthropology
> Texas A&M University
> College Station, TX 77840-4352
>
> -Original Message-
> From: R-help [mailto:r
t.org] On Behalf Of Ivan Calandra
Sent: Thursday, June 23, 2016 10:14 AM
To: R Help
Subject: Re: [R] Subscripting problem with is.na()
Thank you Bert for this clarification. It is indeed an important point.
Ivan
--
Ivan Calandra, PhD
Scientific Mediator
University of Reims Champagne-Ardenne
GE
Hello,
You could do
ds_test[is.na(ds_test$var1), ] <- 0 # note the comma
or, more generally,
ds_test[] <- lapply(ds_test, function(x) {x[is.na(x)] <- 0; x})
Hope this helps,
Rui Barradas
Citando g.maub...@weinwolf.de:
> Hi All,
>
> I would like to recode my NAs to 0. Using a single vecto
Thank you Bert for this clarification. It is indeed an important point.
Ivan
--
Ivan Calandra, PhD
Scientific Mediator
University of Reims Champagne-Ardenne
GEGENAA - EA 3795
CREA - 2 esplanade Roland Garros
51100 Reims, France
+33(0)3 26 77 36 89
ivan.calan...@univ-reims.fr
--
https://www.resea
Sorry, Ivan, your statement is incorrect:
"When you use a single bracket on a list with only one argument in
between, then R extracts "elements", i.e. columns in the case of a
data.frame. This explains your errors. "
e.g.
> ex <- data.frame(a = 1:3, b = letters[1:3])
> a <- 1:3
> identical(ex[1
My statement "Using a single bracket '[' on a data.frame does the same
as for matrices: you need to specify rows and columns" was not correct.
When you use a single bracket on a list with only one argument in
between, then R extracts "elements", i.e. columns in the case of a
data.frame. This
Dear Georg,
You need to learn a bit more about the subsetting methods, depending on
the object structure you're trying to subset.
More specifically, when you run this: ds_test[is.na(ds_test$var1)]
you get this error: "Error in `[.data.frame`(ds_test,
is.na(ds_test$var1)) : undefined columns s
Suggestion: figure out the correct extraction syntax first. One you do that
replacement will be easy.
See ?Extract for all the messy details.
Best,
Ista
On Jun 23, 2016 10:00 AM, wrote:
> Hi All,
>
> I would like to recode my NAs to 0. Using a single vector everything is
> fine.
>
> But if I us
jhall...@frb.gov writes:
Answering my own question here, so you can ignore this unless you are
really interested in some fairly obscure stuff. It turns out that this works:
singleIndex <- missing(j) && (length(sys.call()) == length(match.call()))
since sys.call() has an element for the empty ar
On Feb 10, 2010, at 2:26 PM, GL wrote:
Dataframe1 contains a list of specific dates. Dataframe2 contains a
large
dataset, one element of which is Date. How do I create a subset of
Dataframe2 that excludes the dates from Dataframe1? I know how to do
it with
a left outer join vs null in SQL
Something like:
> df3 <- df2[ !(df2$date %in% df1$date), ]
Might be what you want.
--
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.s...@imail.org
801.408.8111
> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
> pr
Thank you all.
It's not easy to find the right keywords to search for
some things. My problem was related to the cclust
package, and I still think that the cclust code will
not work for unidimensional data. I will fix the
my copy of the cclust code according to your suggestion.
Moacir Pedroso Jr
This is expected behavior:
?'['
Usage:
x[i]
x[i, j, ... , drop = TRUE]
drop: For matrices and arrays. If 'TRUE' the result is coerced to
the lowest possible dimension (see the examples). This only
works for extracting elements, not for the replacement. See
You need drop=FALSE: see ?'['
> x<- matrix(rnorm(100), ncol=1)
> str(x)
num [1:100, 1] -0.626 0.184 -0.836 1.595 0.330 ...
> str(x[20:30,])
num [1:11] 0.5939 0.9190 0.7821 0.0746 -1.9894 ...
> str(x[20:30,,drop=FALSE])
num [1:11, 1] 0.5939 0.9190 0.7821 0.0746 -1.9894 ...
>
On Tu
On 22/10/2008, at 2:24 AM, Pedroso MOACIR wrote:
Hi all,
Why subscripting a one column matrix drops one dimension?
x<- matrix(rnorm(100), ncol=1)
str(x)
num [1:100, 1] -0.413 -0.845 -1.625 -1.393 0.507 ...
str(x[20:30,])
num [1:11] -0.315 -0.693 -0.771 0.448 0.204 ...
str(x[20:
Two solutions:
1) Follow the Posting Guide
2) Use the function help.request() [new to R-2.8.0] to figure how
what steps to take.
Each method leads to the solution here:
http://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-do-my-matrices-lose-dimensions_003f
On Tue, 24 Jun 2008, Agustin Lobo wrote:
Dear list:
Given
str(b3)
'data.frame': 159 obs. of 6 variables:
$ index_pollution : num 8.228 10.513 0.549 0.915 10.416 ...
$ position_descrip: chr "2" "2" "2" NA ...
$ position_geo: chr "3" "0" "3" "3" ...
$ institution : Factor w/ 3
Agustin Lobo wrote:
> Dear list:
>
> Given
> > str(b3)
> 'data.frame':159 obs. of 6 variables:
> $ index_pollution : num 8.228 10.513 0.549 0.915 10.416 ...
> $ position_descrip: chr "2" "2" "2" NA ...
> $ position_geo: chr "3" "0" "3" "3" ...
> $ institution : Factor w/ 3 le
27 matches
Mail list logo