Excuse me for what I'm sure is a stupid beginner's question, but I've given up trying to find the answer to this question from the help, RSiteSearch, or any of the usual places.

I have a list that looks like this:
>myList
$first
[1] "--" "18" "8" "32"

$second
[1] "--" "--" "40" "54"

I want a straightforward way to replace "--" with NA so that the list looks like:

>myList
$first
[1] NA "18" "8" "32"

$second
[1] NA NA "40" "54"

Now I know I can do something like:

    myList$first <- sub("--",NA,myList$first)

but the real list has lots of components. So is there some easy way to do something like:

    myList <- applier(myList,sub,"--",NA)

where "applier" is a function that will do what I want? I tried using lapply, sapply, etc. without luck.

    Thank,
    Marsh

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to