Hi,

          I have been using R for a few months and I have this working 
code. Don't seen any problem but this takes a long time. So if I have 
about 30000 rows it takes a few minutes. If I have 100000 it does not seem 
to complete.

Original Data:

Proto Recv-Q Send-Q Local-Address               Foreign-Address  State  
tcp        0            0                    172.20.100.2:60255 
172.20.100.3:8209           ESTABLISHED 
tcp        0         0                    172.20.100.2:60247 
172.20.100.3:8209           ESTABLISHED 
tcp        0         0                     ::ffff:172.20.100.2:80 
::ffff:10.1.5.7:3185        TIME_WAIT 
tcp        0        0                    ::ffff:172.20.100.2:80 
::ffff:10.5.1.3:3189        TIME_WAIT 
tcp        0        0                     ::ffff:172.20.100.2:80 
::ffff:10.5.5.7:3445        TIME_WAIT 
tcp        0        0                    ::ffff:172.20.100.2:80 
::ffff:10.3.29.3:2671       TIME_WAIT 

Parsed Data:

tcp        0            0                    172.20.100.2:60255 
172.20.100.3:8209           ESTABLISHED 
tcp        0         0                    172.20.100.2:60247 
172.20.100.3:8209           ESTABLISHED 

Here I am just splitting at colons and getting IP's and ports. That is 
all. Can this code improved ?

data <- read.table("D:\\Log 
Analysis\\26-9-2013\\concurrentusage-node1",sep="",header=T,stringsAsFactors=FALSE,
 
fill=TRUE)
var <- c("Foreign.Address")
data[,var] <- sapply(data[,var],function(x) 
ifelse(length(unlist(str_split(x,":")))==5,unlist(str_split(x,":"))[4],unlist(str_split(x,":"))[1]))
var <- c("Local.Address")
data[,var] <- sapply(data[,var],function(x) 
ifelse(length(unlist(str_split(x,":")))==5,paste(unlist(str_split(x,":"))[4],":",unlist(str_split(x,":"))[5]),
 paste(unlist(str_split(x,":"))[1],":",unlist(str_split(x,":"))[2])))

Thanks,
Mohan


This e-Mail may contain proprietary and confidential information and is sent 
for the intended recipient(s) only.  If by an addressing or transmission error 
this mail has been misdirected to you, you are requested to delete this mail 
immediately. You are also hereby notified that any use, any form of 
reproduction, dissemination, copying, disclosure, modification, distribution 
and/or publication of this e-mail message, contents or its attachment other 
than by its intended recipient/s is strictly prohibited.

Visit us at http://www.polarisFT.com

        [[alternative HTML version deleted]]

______________________________________________
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