search for: dt1

Displaying 20 results from an estimated 45 matches for "dt1".

Did you mean: dt
2016 Apr 29
2
selecting columns from a data frame or data table by type, ie, numeric, integer
...his on a data frame. My test code is below #? a technique to get column classes library(data.table) a <- 1:10 b <- c("a","b","c","d","e","f","g","h","i","j") c <- seq(1.1, .2, length = 10) dt1 <- data.table(a,b,c) str(dt1) col.classes <- sapply(dt1, class) head(col.classes) dt2 <- subset(dt1, typeof = "double" | "numeric") str(dt2) dt2?? #? not subset dt2 <- dt1[, list(typeof = "double")] str(dt2) class_data <- dt1[,sapply(dt1,is.integer) | s...
2007 Jun 06
1
fixed effects anova in lme lmer
...output as an anova run in lm(); (2b) specifying that there is no random effect in lmer crashed R (division by zero, I think). Just trying to see the connection of fixed and random effects anova in R. STATA gives me same results for both models up to the point where they differ. Best Toby dt1 = as.data.frame(cbind(c(28,35,27,21,21,36,25,18,26,38,27,17,16,25,22,18),c(1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4))) summary(a1 <- lm(V1~factor(V2)-1, dt1)) anova(a1) summary(a1 <- lm(V1~factor(V2), dt1)) anova(a1) dt1$f = factor(dt1$V2) summary(a2 <- lme(V1~f, dt1)) #1a summary(a2 <-...
2016 Apr 29
0
selecting columns from a data frame or data table by type, ie, numeric, integer
> dt1[ vapply(dt1, FUN=is.numeric, FUN.VALUE=NA) ] a c 1 1 1.1 2 2 1.0 ... 10 10 0.2 Bill Dunlap TIBCO Software wdunlap tibco.com On Fri, Apr 29, 2016 at 9:19 AM, Carl Sutton via R-help < r-help at r-project.org> wrote: > Good morning RGuru's > I have a data frame of 575 co...
2023 Nov 03
2
Sum data according to date in sequence
Hi, I tried this: # extract date from the time stamp dt1 <- cbind(as.Date(dt$EndDate, format="%m/%d/%Y"), dt$EnergykWh) head(dt1) colnames(dt1) <- c("date", "EnergykWh") and my dt1 becomes these, the dates are replace by numbers. dt1 <- cbind(as.Date(dt$EndDate, format="%m/%d/%Y"), dt$EnergykWh) dput(head...
2023 Nov 03
1
Sum data according to date in sequence
...n *Data Munger Guru* *What is the problem that you are trying to solve?Tell me what you want to do, not how you want to do it.* On Fri, Nov 3, 2023 at 2:51?AM roslinazairimah zakaria <roslinaump at gmail.com> wrote: > Hi, > I tried this: > # extract date from the time stamp > dt1 <- cbind(as.Date(dt$EndDate, format="%m/%d/%Y"), dt$EnergykWh) > head(dt1) > colnames(dt1) <- c("date", "EnergykWh") > and > my dt1 becomes these, the dates are replace by numbers. > > dt1 <- cbind(as.Date(dt$EndDate, format="%m/%d/%Y&qu...
2006 Sep 20
1
seq.Date not accepting NULL length.out (PR#9239)
There seems to be a bug in seq.Date such that it will not allow the user to pass in length.out =3D NULL, despite the fact that this is the = default argument. For example: > dt1 <- as.Date("2004-12-31") > dt2 <- as.Date("2005-12-31") > seq.Date(dt1, dt2, length.out =3D NULL, by =3D "month") Error in seq.Date(dt1, dt2, length.out =3D NULL, by =3D "day") :=20 'length.out' must be of length 1 This might be an issue...
2011 May 10
1
Saving multiple 3x3 TIFF graphics inside a loop
...op using tiff figure format (not using PDF or savePlot functions) with no success. Could you please help? Here is a simplified example code: dat=data.frame (ID=rep(1:10,each=10),IDV=rep(seq(1:10),times=10)) dat$DV <- with(dat, 50+15*IDV) dat=dat[order(dat$ID,dat$IDV),] for(i in 1:10){ dt1 = dat[dat$ID==i,] pagei=as.integer(ceiling(i/9)) #This does not work if(i==1) {tiff(file=paste("Outfile",pagei,".tiff",sep="") ,width=17.15,height=17.15,units="cm", res=1200, pointsize=10, compression = "lzw")} if(i==10) {tiff(f...
2023 Nov 02
4
Sum data according to date in sequence
Dear all, I have this set of data. I would like to sum the EnergykWh according date sequences. > head(dt1,20) StationName date time EnergykWh 1 PALO ALTO CA / CAMBRIDGE #1 1/14/2016 12:09 4.680496 2 PALO ALTO CA / CAMBRIDGE #1 1/14/2016 19:50 6.272414 3 PALO ALTO CA / CAMBRIDGE #1 1/14/2016 20:22 1.032782 4 PALO ALTO CA / CAMBRIDGE #1 1/15/2016 8:25 11.004884 5 PALO ALT...
2008 May 08
2
Microseconds for a zoo object?
...file? Thanks Sean > UK[1,3] [1] "17:09:53.824" > UK[1,1] [1] "2007-12-11 00:00:00" > mydates <- paste( substr(UK[,1], 1, 10), UK[,3]) > mydates[1] [1] "2007-12-11 17:09:53.824" > is(mydates) [1] "character" "vector" > dt1 <- as.POSIXct(strptime(as.character(mydates),"%Y-%m-%d %H:%M:%S",tz="GMT")) > dt1[1] [1] "2007-12-11 17:09:53 GMT" > is(dt1) [1] "POSIXt" "oldClass" "POSIXct" "POSIXlt" > >
2013 Aug 16
1
as.Date.character speed improvement suggestion
...x, ...) return(y[idx]) } as.Date.character(x, ...) } ## Example1: Construct a 1-million length character vector of 1000 unique dates ## By considering only unique values, speed is >250x faster > dtch <- format(sample(Sys.Date()-1:1000, 1e6, replace=TRUE)) > system.time(dt1 <- as.Date.character(dtch)) user system elapsed 12.630 23.628 36.262 > system.time(dt2 <- as.Date.character2(dtch)) user system elapsed 0.117 0.019 0.136 > identical(dt1, dt2) [1] TRUE ## Example2: In a "worst case" scenario of a 1,000,002 length characte...
2010 Mar 03
1
empirical copula code
Hi all, I have this data set: ## Empirical copula ## dt1 = ranking ## dt2 = observed uniform data associated with the ranking   Sample data, > dt1         S_i   R_i  [1,]   7.0  10.0  [2,] 232.5 440.5  [3,] 143.0 141.5  [4,] 272.5 222.0  [5,]  46.0  34.0  [6,] 527.0 483.0  [7,] 420.5 563.5  [8,]  23.5  16.5  [9,]  56.5  68.5 [10,] 341.5 382.5   >...
2012 Jun 13
1
histogram fill lattice
Dear all, I would like to change the "fill" pattern of a histogram using histogram() in the lattice package. I know how to do so using hist(), but would prefer to stay within lattice. dt1 <- rnorm(100,0,1) hist(dt1, density=3, angle=45) library(lattice) histogram(dt1, xlab = "Histogram of rnorm(0,1)", type = "count", breaks = 15, col = "grey") With regards, J. Powell [[alternative...
2016 Apr 29
0
selecting columns from a data frame or data table by type, ie, numeric, integer
....table, I had to do some minor changes as shown below. library(data.table) a <- 1:10 b <- c("a","b","c","d","e","f","g","h","i","j") c <- seq(1.1, .2, length = 10) # in case of data frame dt1 <- data.frame(a,b,c) dt1[vapply(dt1, FUN=is.numeric, FUN.VALUE=NA)] a c 1 1 1.1 2 2 1.0 3 3 0.9 4 4 0.8 5 5 0.7 6 6 0.6 7 7 0.5 8 8 0.4 9 9 0.3 10 10 0.2 # in case of data table dt1 <- data.table(a,b,c) dt1[, vapply(dt1, FUN=is.numeric, FUN.VALUE=NA), with=FALSE]...
2012 Mar 05
1
index instead of loop?
...hange anything below. # My first attempt at this fix = function(x) { year = substring(x, 1, 4); mo = substring(x, 5, 6); day = substring(x, 7, 8); ifelse(year=="--", "NA", paste(year, mo, day, sep = "-")) } rd = apply(rd1, 2, fix) dimnames(rd) = dimnames(rd) dt1 <- seq(from =as.Date(z.dates[1]), to = as.Date("2009-03-25"), by = "day") dt = sapply(dt1, as.character) fin = dt ck_rows = length(dt) bad = character(0) start_t_all = Sys.time() for(cn in 1:ncol(ua)){ uac = ua[,cn] tkr = colnames(ua)[cn] rdc = rd[,cn] ua_rd = cbind(...
2003 Sep 29
1
CP for rpart
...or each xerror overlap for different cp's, does that mean we don't have significant improvement for misclassification rate when we split the tree? My data have are two classes with 138 observations and 129 attributes. Here is what I did: >dim(man.dat[,c(1,8:136)]) [1] 138 130 >man.dt1 <- rpart(Target~.,data=man.dat[,c(1,8:136)], >method='class',cp=1e-5, parms=list(split='information')) >plotcp(man.dt1) >printcp(man.dt1) Classification tree: rpart(formula = Target ~ ., data = man.dat[, c(1, 8:136)], method = "class", parms = list(spli...
2003 Jan 18
1
SAS transport files and the foreign package
...utput. libname x SASV5XPT "test.xpt"; libname y SASV5XPT "test2.xpt"; PROC FORMAT; VALUE race 1=green 2=blue 3=purple; RUN; PROC FORMAT CNTLOUT=format;RUN; data test; LENGTH race 3 age 4; age=30; label age="Age at Beginning of Study"; race=2; d1='3mar2002'd ; dt1='3mar2002 9:31:02'dt; t1='11:13:45't; output; age=31; race=4; d1='3jun2002'd ; dt1='3jun2002 9:42:07'dt; t1='11:14:13't; output; format d1 mmddyy10. dt1 datetime. t1 time. race race.; run; /* PROC CPORT LIB=work FILE='test.xpt';run; * no; */ PROC CO...
2009 Nov 02
3
question about difference in date objects
Hi R Community: I want to take the difference in two dates: dt2 - dt1. But, I want the answer in months between those 2 dates. Can you advise me? Please respond to: pzs6 at cdc.gov Thank you! Phil Smith Centers for Disease Control and Prevention
2023 Jan 26
2
Resumen de R-help-es, Vol 167, Envío 10
..."), 10, TRUE) , V3b = sample(c("1","0"), 10, TRUE) , V4a = sample(c("1","0"), 10, TRUE) , V4b = sample(c("1","0"), 10, TRUE)) dt[,":="(seq=.I)] setcolorder(dt,"seq") dt1 <- melt(dt,id.vars=1,measure.vars=2:ncol(dt),variable.name="vrb", value.name="vl") dt1[,":="(vrb_nm=str_sub(vrb,end=2),vrb_tp=str_sub(vrb,start=-1))] dt2 <- dcast(dt1,seq+vrb_nm~vrb_tp,fun.aggregate=\(x) paste0(x,collapse="|"),value.var="vl")...
2008 Jan 06
3
need help
Hi, I'm Roslina, PhD student of University of South Australia, Australia from school Maths and Stats. I use S-Plus before and now has started using R-package. I used to analyse rainfall data using julian date. Is there any similar function that you can suggest to me to be used in R-package? Thank you so much for your attention and help [[alternative HTML version deleted]]
2012 Oct 06
1
arrange data
Dear r-users, I have dailly rainfall data from year 1971 to 2000. I use aggregate to form monthly rainfall data.  What I don't understand is that the data for the year 2000 become on the top, instead of year 1971.  Here are some codes and output: agg_dt1     <- aggregate(x=dt1[,4],by=dt1[,c(1,2)],FUN=sum) > head(agg_dt1,20); tail(agg_dt1,20)    Tahun Bulan     x 1      0     1 398.6 2     71     1 934.9 3     72     1 107.2 4     73     1 236.4 5     74     1  10.5 6     75     1 744.6 7     76     1   9.2 8     77     1 108.7 9     78     1...