Hola a todos, Me gustaria pedir vuestra ayuda a encontrar el error que no consigo encontrar en este archivo. He revisado todo mil veces y probado y no doy con ello.Adjunto el archivo con Google drive porque es muy grande. ? monicap_50.csv <https://docs.google.com/file/d/0B8o2KrPEgG7ATlBMc19lTVk1d3M/edit?usp=drive_web> ? Este es el script, y lo que no entiendo que pasa es que tengo 592044 datos despues de limpiar los NA quedan 586561 datos , y cuando utilizo el script la suma de z2+z4+z5+z6 , que son los estados deberia de darme lo mismo que Z1 que es el valor total de datos pero no se que error existe que me dan mas datos que los que hay.He comparado con el archivo en excel y los datos de na estan correctos. library(chron) library(xlsx) filename<-"monicap_50.csv" DBxy<-read.csv(filename, sep=";",header=TRUE,dec=",") DBx<-na.omit(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") 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) z1<-length(DBx$gear) z1 #defining speed and distance limits speedFishing<-2.0 speedHarb<-1.0 distHbRule<-3.0 speedSteam<-2.0 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" #MONICAP= 10618; UNIVER1= ; UNIVER2= ; UNIVEREST= 1028 z2<-length(DBharbour$State) #Selecting Steaming DBsteaming<- na.omit(DBx[(DBx$calcSpeed>speedFishing) | (DBx$distHb<=distHbRule & DBx$calcSpeed>speedHarb),]) DBsteaming$State<- "Steaming" #MONICAP= 88398; UNIVER1= ; UNIVER2= ; UNIVEREST= 53748 DBsteaming$Harbour<-"" z4<-length(DBsteaming$State) #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) #Selecting nigth DBnight<- na.omit(DBx[(DBx$calcSpeed<=speedFishing & DBx$distHb>distHbRule &(DBx$Time<=minTime | DBx$Time>maxTime)),]) DBnight$State<-"Night" #MONICAP=10434; UNIVER1= 16677; UNIVER2= 25789 DBnight$Harbour<-"" z6<-length(DBnight$State) Si alguien ve el error y puede echarme una mano agradeceria, si no pues seguire peleandome con el archivo! Muchas gracias, un saludo ------------ próxima parte ------------ Se ha borrado un adjunto en formato HTML... URL: <https://stat.ethz.ch/pipermail/r-help-es/attachments/20140709/12392d7c/attachment-0001.html> ------------ próxima parte ------------ A non-text attachment was scrubbed... Name: CODES_2002-2010New.csv Type: text/csv Size: 113916 bytes Desc: no disponible URL: <https://stat.ethz.ch/pipermail/r-help-es/attachments/20140709/12392d7c/attachment-0001.bin>
[R-es] error com un archivo
5 messages · Marta valdes lopez, Carlos J. Gil Bellosta, Carlos Ortega
An embedded and charset-unspecified text was scrubbed... Name: no disponible URL: <https://stat.ethz.ch/pipermail/r-help-es/attachments/20140709/33de1273/attachment.pl>
An embedded and charset-unspecified text was scrubbed... Name: no disponible URL: <https://stat.ethz.ch/pipermail/r-help-es/attachments/20140709/0efeccef/attachment.pl>
An embedded and charset-unspecified text was scrubbed... Name: no disponible URL: <https://stat.ethz.ch/pipermail/r-help-es/attachments/20140709/2d5c58e4/attachment.pl>
An embedded and charset-unspecified text was scrubbed... Name: no disponible URL: <https://stat.ethz.ch/pipermail/r-help-es/attachments/20140709/cadb8064/attachment.pl>