Skip to content
Prev 313818 / 398503 Next

split character line into rows

Hi,
This could be read using the first method I suggested.? The ?substr() method was suggested as I thought that there will be square brackets in each line.
dat1<-read.table("preila.txt",sep="",header=FALSE,fill=TRUE,dec=",",stringsAsFactors=FALSE)
dat2<-na.omit(dat1)

?dat2$Date<-as.POSIXct(paste(dat2$V1,dat2$V2,sep=" "),format="%Y.%m.%d %H:%M:%S")
? dat3<-dat2[,c(6,3:5)]
? colnames(dat3)[2:4]<-paste0("V",2:4)

str(dat3)
#'data.frame':??? 1437 obs. of? 4 variables:
# $ Date: POSIXct, format: "2010-12-26 00:00:52" "2010-12-26 00:01:52" ...
# $ V2? : num? 689 696 712 721 726 ...
# $ V3? : num? 11.7 11.7 11.7 11.7 11.7 ...
# $ V4? : num? 43 43 43 43 43 43 43 43 43 43 ...
?row.names(dat3)<-1:nrow(dat3)
head(dat3)
#???????????????? Date???? V2??? V3 V4
#1 2010-12-26 00:00:52 688.88 11.69 43
#2 2010-12-26 00:01:52 696.19 11.69 43
#3 2010-12-26 00:02:52 712.26 11.69 43
#4 2010-12-26 00:03:52 720.70 11.69 43
#5 2010-12-26 00:04:52 726.16 11.69 43
#6 2010-12-26 00:05:52 713.26 11.69 43
A.K.
Message-ID: <1355781489.25002.YahooMailNeo@web142604.mail.bf1.yahoo.com>
In-Reply-To: <CAHR3agphi+wXnHQFsTJVj6QZjgV+yf6qOEYE6gPxdZ8krXNYuw@mail.gmail.com>