Re: [R] Replacing null values

2011-07-30 Thread Niklaus Kuehnis
On 30.07.2011 21:58, Jeffrey Joh wrote: Sorry about the last message. I forgot to turn the HTML off. I would like to reorder a table by column A, df2 <- df[order(df$A),] then fill column B with the values above it. for (i in 1:nrow(df2)) { if (is.na(df2$B[i]) | df2$B[i] == "NULL") df2$

[R] Mediation with censored outcome

2011-07-07 Thread Niklaus Kuehnis
Hi all, Is it possible to test mediation effects with a censored outcome variable using the 'mediation' package? While on p. 1f. of Imai, Keele, Tingley and Yamamoto (2011) the tobit model is mentioned for use with 'mediate', Table 1 (p. 8) shows that tobit via vglm cannot be used to estimat

[R] agrep: How to match with more than 1 substitution?

2011-06-23 Thread Niklaus Kuehnis
Hi all I'm trying to match a numeric code to a vector of numeric codes: a <- c(12345, 12346, 12347) agrep(12349, a, max.distance=list(substitutions=1)) # [1] 1 2 3 agrep(12399, a, max.distance=list(substitutions=2)) # integer(0) I didn't expect the latter result as substituting two characters

[R] What does "smaller than" comparison do on strings?

2011-05-25 Thread Niklaus Kuehnis
What's the logic behind the following, and where can I find any documentation about it? In particular, why are 2:9 - as characters - not regarded as being smaller than 10? # R-Code: a <- as.character(1:12) a < 10 # [1] TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE