[R] apply two functions to column

arnaud gaboury arnaud.gaboury at gmail.com
Thu Feb 12 12:15:35 CET 2015


I am little lost between all the possibilities to apply a function to
a data.frame or data.table.

Here is mine:

structure(list(name = c("poisonivy", "poisonivy", "poisonivy",
"poisonivy", "poisonivy", "poisonivy", "poisonivy", "poisonivy",
"cruzecontrol", "agreenmamba", "agreenmamba", "vairis", "vairis",
"vairis", "vairis", "vairis", "vairis", "xaeth"), text = c("ok",
"need items ?", "i didn't submit pass codes for a long now",
"ok", "<@U03AEKYL4>: what app are you talking about ?", "some testing
with my irc client",
"ha ha sorry", "for me there is no such question", "Lol.",
"<@U03AEKWTL|agreenmamba> uploaded a file:
<https://enlightened.slack.com/files/agreenmamba/F03KGRF3W/screenshot_2015-02-09-14-31-15.png|regarding:
should I stay or should I go?>",
"<@U032FHV3S> <http://youtu.be/oGIFublvDes>", "ok, see you around",
"yeah, I had a procrastination rush so I started to decode a little",
"<http://ingress.com/intel|ingress.com/intel> when you submit passcodes",
"intel", "what is the cooldown time or how does it work...;",
"anybody knows how does \"Passcode circuitry too hot. Wait for cool
down to enter another passcode.\" works?",
"and people told that agent their geocities experience would never
amount to anything (the convo yesterday) "
), ts = c("1423594336.000138", "1423594311.000136", "1423594294.000135",
"1423594258.000133", "1423594244.000131", "1423497058.000127",
"1423497041.000126", "1423478555.000123", "1423494427.000125",
"1423492370.000124", "1423478364.000121", "1423594358.000139",
"1423594329.000137", "1423594264.000134", "1423594251.000132",
"1423592204.000130", "1423592174.000129", "1423150354.000112"
)), .Names = c("name", "text", "ts"), class = c("data.table",
"data.frame"), row.names = c(NA, -18L))

As you can see, it is of class data.frame and data.table.

I need to work on last column "t"s. These are characters and are times
in epoch format. I want to have time in Posix. I must thus do two
things:
- characters to numeric : myData$ts <- as.numeric(myData$ts)
- epoch to Posix : mapply(as.POSIXct, tz = 'GMT', origin =
'1970-01-01', myMerge$ts)

I wonder:
- if I can apply these two functions at the same time
- what will be the fastest way : use dplyr package, or work with
data.table ? My real data will be much more important than the one
posted.

Thank you for advice and hint.

-- 

google.com/+arnaudgabourygabx



More information about the R-help mailing list