similar to: don't print object attributes on screen

Displaying 20 results from an estimated 7000 matches similar to: "don't print object attributes on screen"

2012 Feb 23
1
(no subject)
Dear Helpers, I wrote a simple function to standardise variables if they contain more than one value. If the elements of the variable are all identical, then I want the function to return zero. When I submit variables whose elements are all identical to the function, it returns not zero, but NaNs. zt=function(x){if (length(table(x)>1)) y=(x-mean(x))/sd(x) else if (length(table(x)==1)) y=0;
2012 Feb 23
1
FW: NaN from function
Dear Helpers, I wrote a simple function to standardise variables if they contain more than one value. If the elements of the variable are all identical, then I want the function to return zero. When I submit variables whose elements are all identical to the function, it returns not zero, but NaNs. zt=function(x){if (length(table(x)>1)) y=(x-mean(x))/sd(x) else if (length(table(x)==1)) y=0;
2004 Oct 20
2
Odd behaviour with scale()
Moi! A student here has been getting a bit irritated with some side effects of scale() (OS is Windows XP, the behaviour occurs in R 2.0.0, but not 1.7.1). The problem is that she scales a variable in a data frame, then does a regression, and tries to get some predictions for some new data. However, at this point she gets an error (see the example below). This seems to be because the
2016 Apr 02
3
apply mean function to a subset of data
Dear all; This must have a rather simple answer but haven't been able to figure it out: I have a data frame with say 2 groups (group 1 & 2). I want to select from group 1 say "n" rows and calculate the mean; then select "m" rows from group 2 and calculate the mean as well. So far I've been using a for loop for doing it but when it comes to a large data set is
2007 Jun 14
4
question about formula for lm
Dear all; Is there any way to make this to work?: .x<-rnorm(50,10,3) .y<-.x+rnorm(50,0,1) X<-data.frame(.x,.y) colnames(X)<-c("Xvar","Yvar") Ytext<-"Yvar" lm(Ytext~Xvar,data=X) # doesn't run lm(Yvar~Xvar,data=X) # does run The main idea is to use Ytext as input in a function, so you just type "Yvar" and the model should fit....
2016 Apr 03
1
apply mean function to a subset of data
Here are several ways to get there, but your original loop is fine once it is corrected: > for (i in 1:2) smean[i] <- mean(toy$diam[toy$group==i][1:nsel[i]]) > smean [1] 0.271489 1.117015 Using sapply() to hide the loop: > smean <- sapply(1:2, function(x) mean((toy$diam[toy$group==x])[1:nsel[x]])) > smean [1] 0.271489 1.117015 Or use head() > smean <- sapply(1:2,
2016 Apr 02
0
apply mean function to a subset of data
Hi Pedro, This may not be much of an improvement, but it was a challenge. selvec<-as.vector(matrix(c(nsel,unlist(by(toy$diam,toy$group,length))-nsel), ncol=2,byrow=TRUE)) TFvec<-rep(c(TRUE,FALSE),length.out=length(selvec)) toynsel<-rep(TFvec,selvec) by(toy[toynsel,]$diam,toy[toynsel,]$group,mean) Jim On 4/3/16, Pedro Mardones <mardones.p at gmail.com> wrote: > Dear all; >
2007 May 11
3
how to get column/row info from a dist object?
Dear R users; Is it possible to get the row and column number of a particular entry in a dist object? Let's say that I want to find the position of the value 1.1837 (the last entry on the dist object below), that is [6,3]. Can I get those values without transforming the object to a matrix?, i.e. working with the dist object only. 1 2 3 2 0.23935864
2011 Sep 20
5
help in interpreting paired t-test
Dear all; A very basic question. I have the following data: ************************************************************************************ A <- 1/1000*c(347,328,129,122,18,57,105,188,57,257,53,108,336,163, 62,112,334,249,45,244,211,175,174,26,375,346,153,32, 89,32,358,202,123,131,88,36,30,67,96,135,219,122, 89,117,86,169,179,54,48,40,54,568,664,277,91,290,
2009 Mar 14
4
persp plot + plotting grid lines
Dear all; Does anyone know how to add grid lines to a persp plot? I've tried using lines(trans3d..) but the lines of course are superimposed into the actual 3d surface and what I need is something like the plot shown in the following link: http://thermal.gg.utah.edu/tutorials/matlab/matlab_tutorial.html I'll appreciate any ideas Thanks PM
2006 Nov 29
3
R2.4 xyplot + panel.number problem
Hi all; I'm trying to display a 2 panel plot for the Puromycin data from R with 2 different non-linear models fitted to each group. The problem is that as far as I know panel.number doesn't work in the latest version of R. Can anyone give a hint how to solve this? Here is the code that I used before and now doesn't work xyplot(rate ~conc| state,Puromycin,
2008 Jan 29
2
error message + boot library
Dear all; What can be wrong with this simple example? library(boot) d1<-c(rnorm(10,mean=10)) fm<-function(d,i) mean(d[i]) bd1<-boot(d1,fm,10000) > Error: evaluation nested too deeply: infinite recursion / options(expressions=)? Thanks for any idea
2013 Mar 13
1
calculating column difference in a matrix
Dear R users; Consider the following toy example: a <- matrix(c(2,3,4,NA,NA,5,8,NA,8,NA), 5, 2) b <- cbind(a,apply(a, 1, diff, na.rm = TRUE)) What I would like be able to get is: c <- matrix(c(2,3,4,NA,NA,5,8,NA,8,NA,3,5,-4,8,NA), 5, 3) i.e., for each row if both values (column 1 and 2) are NA then the difference must return NA, but if any of those two values is different from NA
2006 Dec 26
2
sequential row selection in dataframe
Dear all; I'm wondering if there is any 'efficient' approach for selecting a sample of 'every nth rows' from a dataframe. For example, let's use the dataframe GAGurine in MASS library: > length(GAGurine[,1]) [1] 314 # select an 75% of the dataset, i.e. = 236 rows, every 2 rows starting from row 1 > test<-GAGurine[seq(1,314,2),] > length(test[,1]) [1] 157 #
2008 Apr 08
1
plot function / par() settings
Dear all; I'm trying to create a 2 x 3 plot (something I know like lattice can do better) using the plot function. However; I'm not sure how to make the width of the plots to be the same on each column. I guess the answer maybe obvious but I haven't been able to figure it out. I'll appreciate any suggestion. Here is the (highly inefficient) code for the first row: par(mfrow =
2007 Nov 06
2
translating R code to C code
I would like to try to implement a big series of nested loops in a C code and then call it from R; however I'm not familiar with C programming. Does anyone know about some sort of reference I can use that help me to translate my code to C? (I'm thinking on something like to Octave to R reference posted in CRAN) thanks PM
2008 Jun 23
1
levelplot question
Dear all; I have a data set with 3 groups and 2 response variables, say z1 and z2, and I would like to create a single plot (using the levelplot function) showing on the first row the leveplots for z1 for each group and on the second row levelplots for z2 for the same groups. I tried plot.trellis using the split option and it's OK but what I would like to achieve is something similar to what
2006 Oct 22
1
least median squares
Does anyone can provide a code to implement least median squares regression in R (not using the lqs function or calling C functions)? Reason: teaching/learning purposes Thanks PM
2012 Sep 16
1
trying to obtain same nls parameters as in example
Dear R-users; I'm working with a a dataset that was previously used to fit a nonlinear model of the form: Y ~ a * (1 + b * log(1 - c * X^d)) The parameters published elsewhere are: a = 1.758863, b = .217217, c = .99031, and d = .054589 However, there is no way I can replicate this result. I've tried several options (including SAS) w/o success. The data is: X <-
2019 Mar 20
3
Como asignar valores de un archivo a otro
Toda la razon!!! merge era todo! Saludos El mié., 20 mar. 2019 a las 10:57, Carlos Ortega (<cof en qualityexcellence.es>) escribió: > Hola Mauricio, > > No, creo que no es lo que dices.. > > Con merge, indicas por qué columna (pueden ser varias) quieres juntar los > dos dataframes y con los parámetros "all.x", "all.y" y "all" indicas si