Hola¡

Ya se cual fue mi error,no fue R...

Gracias, un saludo


2014-07-10 17:43 GMT+02:00 Marta valdes lopez <[email protected]>:

> Hola !!
>
> Estoy utilizando este script hace tiempo y hasta ahora he ido encontrando
> errores que he ido solucionando, pero hoy al utilizarlo otra vez me da el
> error de que al crearme las tablas que pido me borra parte de los nombres
> de los puertos (Harbour), y ya comprobe en el original y aqui estan todos
> bien.Lo que no entiendo es que el script es el mismo y no se porque ahora
> me crea ese error.
>
> setwd("C:/Users/mvaldes/Desktop/DB")
>   library(chron)
>   library(xlsx)
>  #Read output of previous routine
>   #Give FILENAME here
>   filename<-"univerest_50.csv"
>
>     DBxy<-read.csv(filename, sep=";",header=TRUE,dec=",")
>
> DBx<-DBxy
>   names(DBx)<-c("Boat","DateTime","TimeDiff", "Latitude", "Longitude",
> "Course", "Speed", "distNm", "calcSpeed", "calcCourse", "distHb",
> "Harbour", "idTrip","vmsAngle", "calcAngle", "vmsLeg", "calcLeg",
> "Trip_vmsLeg", "Trip_calcLeg", "lengthTrip", "lengthTrip_vmsLeg",
> "lengthTrip_calcLeg","Time", "Date")
>   #Formatting date and time variables
>   DBx$Date<-strptime(DBx$Date, "%d-%m-%Y", tz="GMT")            ###Monicap
> use the same ; other use  Y
>   DBx$Year<-as.POSIXlt(DBx$Date)$year+1900
>   if(filename!="monicap_50.csv") {DBx$Time<-paste(DBx$Time, ":00",
> sep="")}   #NOT necessary for Monicap and Univerest_50
>   DBx$Time<-times(DBx$Time)       #Works for Monicap AND UNIVEREST_50  ONLY
>   DBx$Boat<-gsub("^\\s+|\\s+$", "", DBx$Boat)
>
>
>
>  #Read file with boat codes and gears
>   codeBoats<- read.csv("CODES_2002-2010New.csv",
> sep=",",header=TRUE)            #Laptop
>   codeBoats$CODIGO<-gsub("^\\s+|\\s+$", "", codeBoats$CODIGO)
>  #Assigning a Fishing license based on Boat and Year
>   DBx$gear<-codeBoats$Lic[match(paste(DBx$Boat,DBx$Year),
> paste(codeBoats$CODIGO,codeBoats$Year))]
>    z0<-length(DBx$gear)
>
>   ######PoleLine analyses / MAY 2013 #######Changes are: harbour with
> speed rule (<rest)
>   #Define GEAR HERE based on list above. Analysing BLL boats
>   DBx <- DBx[DBx$gear %in% c("PoleLine"),]
>   z1<-length(DBx$gear)
>
>   #defining speed and distance limits
>       speedFishing<-2.0  #less or equal to, in knots    (NEW MAY 2013
> reduced from 5.3)
>       speedHarb<-1.0   #new speed harbour
>       distHbRule<-3.0    #greater than, in nautical miles nm
>       minTime<-times(c("05:59:59"))        #usual beginning of fishing
> operations
>       maxTime<- times(c("20:59:59"))        #usual finishing of fishing
> operations
>
>        #Selecting Harbour
>         DBharbour<- na.omit(DBx[DBx$distHb<=distHbRule &
> DBx$calcSpeed<=speedHarb,])
>         DBharbour$State<-"Harbour"
>         z2<-length(DBharbour$State)
>         write.table(DBharbour, file =
> paste("C:/Users/mvaldes/Desktop/DB/results_",filename, sep=""), append = F,
> quote = F, sep = ",", dec = ".",
>                   row.names = F, col.names = T)
>   #Selecting Steaming
>         DBsteaming<- na.omit(DBx[DBx$calcSpeed>speedFishing |
> (DBx$distHb<=distHbRule & DBx$calcSpeed>speedHarb),])
>         DBsteaming$State<- "Steaming"
>         DBsteaming$Harbour<-""
>         z4<-length(DBsteaming$State)
>        write.table(DBsteaming, file =
> paste("C:/Users/mvaldes/Desktop/DB/results_",filename, sep=""), append = T,
> quote = F, sep = ",", dec = ".",
>                   row.names = F, col.names = F)
>
>        #Selecting Fishing
>         DBfishing<- na.omit(DBx[DBx$calcSpeed<=speedFishing &
> DBx$distHb>distHbRule & (DBx$Time>minTime & DBx$Time<=maxTime),])
>         DBfishing$State<-"Fishing"
>         DBfishing$Harbour<-""
>         z5<-length(DBfishing$State)
>          write.table(DBfishing, file =
> paste("C:/Users/mvaldes/Desktop/DB/results_",filename, sep=""), append = T,
> quote = F, sep = ",", dec = ".",
>                   row.names = F, col.names = F)
>        #Selecting nigth
>         DBnight<- na.omit(DBx[(DBx$calcSpeed<=speedFishing &
> DBx$distHb>distHbRule &(DBx$Time<=minTime | DBx$Time>maxTime)),])
>         DBnight$State<-"Night"
>         DBnight$Harbour<-""
>         z6<-length(DBnight$State)
>        write.table(DBnight, file =
> paste("C:/Users/mvaldes/Desktop/DB/results_",filename, sep=""), append = T,
> quote = F, sep = ",", dec = ".", row.names = F, col.names = F)
>
> Si alguien lo ve y me puede decir lo agradeceria, o simplemente R me
> vacila ya no se que pensar...
> Muchas gracias por vuestro tiempo, un saludo
>

        [[alternative HTML version deleted]]

_______________________________________________
R-help-es mailing list
[email protected]
https://stat.ethz.ch/mailman/listinfo/r-help-es

Responder a