Sorry, my attempt wasn't quite good enough. I didn't
consider the possibility of a 'negative' value in a
character/factor column. To fix that, see inline below.
On 2010-05-17 14:32, Peter Ehlers wrote:
On 2010-05-17 12:54, Henrique Dallazuanna wrote:
Try this:
newData<- sapply(numdat, functi
On 2010-05-17 12:54, Henrique Dallazuanna wrote:
Try this:
newData<- sapply(numdat, function(x)lapply(strsplit(as.character(x), '-'),
function(.x)mean(as.numeric(.x
There's a potential problem if numdat contains negative numbers.
It would be better to restrict the recoding to character or
Try this:
newData <- sapply(numdat, function(x)lapply(strsplit(as.character(x), '-'),
function(.x)mean(as.numeric(.x
On Mon, May 17, 2010 at 3:29 PM, Juliet Hannah wrote:
> I am recoding some data. Many values that should be 1.5 are recorded
> as 1-2. Some example data and my solution is bel
I am recoding some data. Many values that should be 1.5 are recorded
as 1-2. Some example data and my solution is below. I am curious about
better approaches or any other suggestions. Thanks!
# example input data
myData <- read.table(textConnection("id, v1, v2, v3
a,1,2,3
b,1-2,,3-4
c,,3,4"),head
4 matches
Mail list logo