search for: nlevel

Displaying 20 results from an estimated 212 matches for "nlevel".

Did you mean: level
2009 Oct 13
1
vis.gam() contour plots
Greetings, I have what I hope is a simple question. I would like to change my contour interval on the vis.gam( plot.type="contour") in the mgcv package. Is this a situation where I need to modify the function or is there a default value I can change? Thanks
2007 Aug 06
3
Error in using nlevels in apply function
Dear R users, I am currently trying to create my first personnal function and use it with the apply function. The purpose of this function is to create a vector summarizing the number of levels in a given selection of data.frame columns. I tried to transpose the indexation method used by the nlevels function but it doesn't seem to work. I did not find anything uesful in the archives so could someone point to me where my mistake(s) is (are) ? Thanks in advance Sebastien #------------------------- mydata<-data.frame(1:6,1:6,1:6,1:6,1:6,1:6,1:6,1:6,1:6,1:6,1:6,1:6,1:6,1:6,1:6,1:6,1:...
2008 Apr 28
1
error in summary.Design
...quot; "VAR3" "VAR4" "VAR5" "VAR6" "VAR7" "VAR8" summary(mymodel) Error in `contrasts<-`(`*tmp*`, value = "contr.treatment") : contrasts can be applied only to factors with 2 or more levels but, VAR1 is my dependent > nlevels(factor(VAR1)) [1] 2 VAR2 is continuous > summary(psa) Min. 1st Qu. Median Mean 3rd Qu. Max. 0.90 6.05 8.40 10.99 13.15 59.70 and for the remaining variables... > nlevels(factor(VAR3)) [1] 2 > nlevels(factor(VAR4)) [1] 2 > nlevels(factor(VAR5)) [1] 3 > n...
2003 Jan 03
1
Take care with codes()! (was type of representation)
...9, # filled circle col="skyblue", # dot color xlab="Car", # x axis label ylab="Color", # y axis label xaxt="n", # no x axis lables yaxt="n", # no y axis lables bty="n", # no box around the plot xlim=c(0,nlevels(data$Car )+0.5), # extra space on either end of plot ylim=c(0.5,nlevels(data$Color)+1.5) # so dots don't cross into margins ) # add text labels text(x=1:nlevels(data$Car), y=nlevels(data$Car)+1, labels=levels(data$Car)) text(x=0, y=1:nlevels(data$Color), labels=levels(data$Color)...
2009 Apr 04
2
data.frame, converting row data to columns
I have a data frame something like: name wrist nLevel emot 1 4094 3.34 1 frustrated 2 4094 3.94 1 frustrated 3 4094 NA 1 frustrated 4 4094 3.51...
2011 Dec 22
1
overlaid filled contour plots
...con <- url("http://euclid.psych.yorku.ca/SCS/Private/Test/bkde2D-boot.RData") ## print the value to see what objects were saved. print(load(con)) close(con) col <- c("black", rainbow(5, start=.6, end=.1)) clr <- col[c(1,3,6)] contour(dest0$x1, dest0$x2, dest0$fhat, nlevels=4, xlim=c(-8,4), ylim=c(-3,0), cex.lab=1.25, xlab="GNP", ylab="Unemployed" ) contour(dest1$x1, dest1$x2, dest1$fhat, nlevels=4, add=TRUE, col=clr[2]) contour(dest2$x1, dest2$x2, dest2$fhat, nlevels=4, add=TRUE, col=clr[3]) lines(rbind(cm0, cm1, cm2)) points(rbind(...
2005 Jan 27
1
Is glm weird or am I?
...levels. I don't know how (or whether I want) to try to fathom what's up with glm. What I wrote is attached. Here's what I get. ***************************************************** source("lrtest.R") building model: Wgend ~ WAY construct_and_run_model: class of x: integer nlevels(x): 0 class of y: factor nlevels(y): 2 model built model ran -1.070886 0.01171153 building model: Wgend ~ WBWS construct_and_run_model: class of x: integer nlevels(x): 0 class of y: factor nlevels(y): 2 model built model ran 0.0837854 0.01898052 building model: Wgend ~ Wcond construct_...
2003 Mar 08
0
RE: Text Rotation (was: Take care with codes()!)
...r > > xlab="Car", # x axis label > > ylab="Color", # y axis label > > xaxt="n", # no x axis lables > > yaxt="n", # no y axis lables > > bty="n", # no box around the plot > > xlim=c(0,nlevels(data$Car )+0.5), # extra space on > either end of plot > > ylim=c(0.5,nlevels(data$Color)+1.5) # so dots don't > cross into margins > > ) > > > > # add text labels > > text(x=1:nlevels(data$Car), y=nlevels(data$Car)+1, > labels=levels(data...
2011 Mar 19
2
persuade tabulate function to count NAs in a data frame
...rring in columns 'b' to 'e' but considering the fact at the very same time that these distributions should be 'groupped by' the id numbers in column 'id'. It works fine, check it -> matrix(matrix(unlist(lapply(df[,(-(1))],function(x) tapply(x,df$id,tabulate,nbins=nlevels(factor(df[,2])))) [[1]])),ncol=3,nrow=3,byrow=TRUE) matrix(matrix(unlist(lapply(df[,(-(1))],function(x) tapply(x,df$id,tabulate,nbins=nlevels(factor(df[,3])))) [[2]])),ncol=3,nrow=3,byrow=TRUE) matrix(matrix(unlist(lapply(df[,(-(1))],function(x) tapply(x,df$id,tabulate,nbins=nlevels(factor(df[,4])...
2001 Oct 10
1
Wrong df in bartlett.test when subsetting data (PR#1124)
...rect number of df = 9 # Just use the first 5 levels of f # Does not work correctly bartlett.test(X[1:25],f[1:25]) # Should have df = 4, but uses df = 9 bartlett.test(X~f,subset=1:25) # Should have df = 4, but uses df = 9 In version 1.2.2 the problem could be solved by substituting k <- nlevels(g) with k <- length(unique(g)) (I do not get the R-code in the new version get by typing bartlett.test at the prompt.) This might leed to a discussion on whether nlevels should return the number of attained factor levels or the number of "theoretical" levels: nlevels(f) # Re...
2005 Nov 23
1
assign() problem
...ction(image_file){ #require(rimage) require(wavethresh) #reading image file and converting it to grayscale #dimage <- read.jpeg(image_file) #dimage <- imagematrix(dimage) # discrete wavelet decomposition imwdImage <- imwd(image_file) # get a value for the number of decomposition levels #nlevels <- imwdImage$nlevels i <- 0 varname <- paste("level",0:(imwdImage$nlevels-1),sep="") print(varname) while ( i < imwdImage$nlevels) { # set the threshold to 0 on all levels except the one in evaluation # thresholdLevels is the list of levels to set to zero...
2012 Feb 09
2
Lattice 3d coordinate transformation
...nction(x,y,...) predict(fit,data.frame(x=x,y=y))) }) ## # This works to get contours: require(lattice) cloud(z~x+y|g,data=d,layout=c(2,1), type='h', lwd=3, par.box=list(lty=0), scales=list(z=list(arrows=F,tck=0)), panel.3d.cloud = function(x, y, z,rot.mat, distance, zlim.scaled, nlevels=20,...){ add.line <- trellis.par.get("add.line") clines <- contourLines(surf[[packet.number()]],nlevels = nlevels) for (ll in clines) { m <- ltransform3dto3d(rbind(ll$x-.5, ll$y-.5, zlim.scaled[1]), rot.mat, dista...
2009 Dec 10
2
different randomForest performance for same data
...nd after assigning the levels of the training dataset on the testdataset. I only assign the levels and do not change the dataset itself however the models perform different. Why??? Here is my code: > library(randomForest) > load("datasets.RData") # import traindat and testdat > nlevels(traindat$predictor1) [1] 20 > nlevels(testdat$predictor1) [1] 19 > nrow(traindat) [1] 9838 > nrow(testdat) [1] 3841 > set.seed(10) > rf_orig <- randomForest(x=traindat[,-1], y=traindat[,1], xtest=testdat[,-1], ytest=testdat[,1],ntree=100) > data.frame(rf_orig$test$err.rate)[10...
2003 Mar 08
0
RE: Text Rotation (was: Take care with codes()!)
...ot;Car", # x axis label > > > ylab="Color", # y axis label > > > xaxt="n", # no x axis lables > > > yaxt="n", # no y axis lables > > > bty="n", # no box around the plot > > > xlim=c(0,nlevels(data$Car )+0.5), # extra space on > > either end of plot > > > ylim=c(0.5,nlevels(data$Color)+1.5) # so dots don't > > cross into margins > > > ) > > > > > > # add text labels > > > text(x=1:nlevels(data$Car), y=nlevels(da...
2007 Jul 30
1
correlation and matrix
...elating one-level factors, the output is NA) here is my code: lst<-seq(1, 204, by=12) % there are 12 factors for 17 natural resources for (n in lst) { Mx<- matrix(0, byrow = F, ncol = 4, nrow=nrow(dta)) % I extract the 4 factors I have to correlate and I'd like to do it for each n {if (nlevels(dta[,n+4])!=1) Mx[,1]<-dta[,n+4] else Mx[,1]<-NA} {if (nlevels(dta[,n+5])!=1) Mx[,2]<-dta[,n+5] else Mx[,2]<-NA} {if (nlevels(dta[,n+7])!=1) Mx[,3]<-dta[,n+7] else Mx[,3]<-NA} {if (nlevels(dta[,n+8])!=1) Mx[,4]<-dta[,n+8] else Mx[,4]<-NA} p<-0 % I comp...
2013 Jan 16
1
setting the legend scale in contour plots
...ngth.out=nrow(SSTt[,,t])), y=seq(-90,90, length.out=ncol(SSTt[,,t])), SSTt[,,t], xlim=range(seq(-180,180, length.out=nrow(SSTt[,,t])), finite=TRUE), ylim=range(seq(-90,90, length.out=ncol(SSTt[,,t])), finite=TRUE), zlim=range(SSTt[,,t], finite=TRUE), levels=pretty(range(SSTt[,,t], finite=TRUE), nlevels), nlevels=25, color.palette=heat.colors, col=color.palette(length(pretty(range(SSTt[,,t], finite=TRUE), nlevels), nlevels=25)-1), ) } When I try to run it, I get this error: Error in n[1L] : object of type 'closure' is not subsettable Could you please tell me what's wrong? Cheer...
2007 Aug 01
1
Problem to remove loops in a routine
...############# # Plotting routine ############# myPath<-"C:/" #TO BE MODIFIED nTrellisCol<-2 #number of columns per Trellis plot nTrellisRow<-3 #number of lines per Trellis plot nDVID<-nlevels(factor(mydata$DVID)) #number of DVID=observations types nidPlot<-nlevels(factor(mydata$PLOT)) #number of items in the PLOT column nPer<-nlevels(factor(mydata$OCC)) #number of occassions (OCC, PER, etc...) nGRP<-nlevels(factor(mydata$GRP))...
2003 Jan 03
2
type of representation
Hi I have some data that i want to plot but i don't find how to do it. I have car types (bmw,renault,mercedes,seat ...), colors and a number for each car type-color relation.I want to come up with a matrix representation of cars vs colors where in each intersection i could set a dot proportional in size to my third variable. Can anybody give me a clue of hoe to come up with such
2006 Mar 18
0
No subject
...quot;skyblue", # dot color > xlab="Car", # x axis label > ylab="Color", # y axis label > xaxt="n", # no x axis lables > yaxt="n", # no y axis lables > bty="n", # no box around the plot > xlim=c(0,nlevels(data$Car )+0.5), # extra space on either end of plot > ylim=c(0.5,nlevels(data$Color)+1.5) # so dots don't cross into margins > ) > > # add text labels > text(x=1:nlevels(data$Car), y=nlevels(data$Car)+1, labels=levels(data$Car)) > text(x=0, y=1:nlevels(data$Color...
2012 Sep 19
2
Help reproducing a contour plot
...rting data to percentage of total chl a* * * *picoFrac <- Atlantis$Pico/Atlantis$Total_Ch*100* *nanoFrac <- Atlantis$Nano/Atlantis$Total_Ch*100* *microFrac <- Atlantis$Micro/Atlantis$Total_Ch*100* * * * * *library(akima)* * * *par(mfrow = c(3,1)) * * * *contour(interp(Long, dbar, picoFrac),nlevels = 6,* * xlab ="Longitude", main= "Pico", * * ylab ="Depth", ylim = c(-200,0), method = "simple",* * col = "light green")* * * *contour(interp(Long, dbar, nanoFrac), nlevels = 6,* * xlab ="Longitude", main= "Nano",* *...