similar to: how does while work

Displaying 20 results from an estimated 3000 matches similar to: "how does while work"

2002 Mar 20
3
check without loop
i am probably just missing this one, but how can i check to see if a number is a part of a vector? i know i could do a loop checking for equivalence for each element, but i am thinking that there must be a simpler way to do it than that ( i think that i have even done it in the past, but can't remember how!) thanks what i am working with: (hope this makes sense) arclist [1] 2 2 6
2001 Oct 30
2
extracting object names as strings
Hi, I'm looking for a function which returns the name of the argument object as a string: >vect <- 1:3 >function(vect) "vect" I've looked at 'name', 'names', 'objects', none seem to do exactly what I want. ls/objects comes close, but I can't figure out how to force it to give me only one object name. daver
2002 Mar 08
2
? about sample
i am trying to use the sample command and have one question about it: i am getting the error Error in sample(length(x), size, replace, prob) : insufficient positive probabilities when i use something like: sample (1:4, prob=c(0,0,1,0))[1] i was expecting that to return a 3 every time while this is not exactly what i am using it for, i need the capabilities to deal with zeros (as the
2002 Apr 08
2
changing the form of a list
i have a 2 x n matrix that is a paired list of connections, i am working with that looks something like: 1 2 1 3 1 5 2 1 2 3 3 1 3 2 4 5 5 1 5 4 for later operations it would be helpful if i could change this into the form of: 1 2 3 5 2 1 3 3 1 2 4 5 5 1 4 the initial list is randomly generated and the max number of times that any one number can appear is previoulsy defined by a limiting
2002 Feb 25
5
another basic ?
i am sure that there is a simple solution that i am just overlooking, but there is no logical test for = there is one for != and >,<, >=, <=... what do i do if i need to check if something IS EQUAL or is there an easy way, in working with a matrix of size n x 3, to sort the matrix by one of the columns? specifically what i am trying to do is i have a matrix with individual and
2002 Feb 18
3
i think i asked the wrong ?
me again, new to R, haven't programmed in a long time at all sorry to ask what is probably basic a while ago i asked how to remove an element from a list apparently what i am using is not a list but a vector, didn't realize there was a list data type could also use a matrix for what i am doing, is there a way to remove single elements from either of those? thanks for any help, if i was
2002 Apr 29
2
efficiency
i have a set of files that i am reading into R one at a time and applying to a function that i have written where each is a 'table' n (columns) x 10000 (rows) n varies across the files and most of the rows only have data in the first few columns currently i am reading them in with the command: read.table(file="2.75.0.997.1", header=FALSE, sep="", skip=13, fill=,
2001 Oct 09
3
find indices of nonzero elements
Hi, Is there a function func(x) where x is an array such that it returns a list of the indices of all non-zero elements of the array? for example: a: 1 0 0 0 0 1 0 1 0 func(a) returns two vectors r and c: r c 1 1 2 3 3 2 daver +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |David Richmond It works on a | + Dept. of Sociology complex scientific
2001 Sep 28
3
evaluating the contents of a string
Hi, suppose I do: b <- matrix(1:9,3,3) bname <- "b" now dim(b) returns [1] 3 3 and dim(bname) returns NULL is there a function to pass bname to such that dim returns the dimensions of b? like dim(somefunc(bname)) returns [1] 3 3 does 'somefunc' exist? daver +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |David Richmond It
2002 Apr 17
1
concat
i have a function that returns a list containing a variety of variable types i am trying to run the function multiple times and return the output into a variable with a semi-consistent naming pattern i.e., for ten trials i want to return the list into variables trial1,trial2,...trial10 is there a generic way to get this to happen i have a similar process that does the same thing to an external
2002 May 14
2
tapply and empty subsets
I am using tapply to compute means by group, as in > tapply(y, z, mean) 1 2 3 21.00757 20.50031 NA where y is a vector and z a factor with levels 1:3. I would like to get a zero instead of the NA I get when a subset is empty. The problem is that FUN is not applied to empty cells of the ragged array. (Of course I am willing to define a function my.mean that returns
2010 Aug 18
3
libreadline problem
Hello, Recently updated Ubuntu to 10.04, I have installed the r-base and r-base-dev packages from CRAN with sudo apt-get install r-base But now when I want to start R I get the following error: gpetris at definetti:~$ R /usr/lib/R/bin/exec/R: symbol lookup error: /usr/local/lib/libreadline.so.6: undefined symbol: PC Any clue??? Has anybody seen that before? I have tried to reinstall the
2003 Oct 29
1
restarting split.screen
Is there a way of `restarting' split.screen? This is what I am getting: > close.screen() [1] 10 11 12 13 > close.screen(all=TRUE) Error in par(args) : parameter "i" in "mfg" is out of range > graphics.off() > x11() > close.screen() [1] 10 11 12 13 > close.screen(all=TRUE) Error in par(args) : parameter "i" in "mfg" is out of range As
2007 Jan 18
4
Reading contingency tables
I am trying to read an ftable using read.ftable, but I get the following error message: > jobSatTable <- read.ftable("http://definetti.uark.edu/~gpetris/stat5333/jobSatisfaction.dat",skip=2) Error in seek(file, where = 0) : no applicable method for "seek" In addition: Warning messages: 1: no non-missing arguments to max; returning -Inf 2: no non-missing arguments to
2004 May 12
4
non-interactive call to R (running an R package as a stand-alone application)
Is there a way I can have R automatically execute the commands in a source file without ever having to use R interactively? If so, what arguments should I pass to the UNIX call to R? I need to do this to run several R jobs in parallel. An alternative may be to have R and an R package behave as a stand-alone application that can be called from the UNIX command line. Is there any documentation on
2008 Oct 09
2
Two math expressions in plot
Hello! I am trying to put two math expressions in the title of a plot. As you can see below, I can place correctly one expression at a time, but not both. Ideally I would like to have them separated by a comma. Any suggestions? > k <- 1 > n.eff <- c(20, 30) > ### this works > plot(0,0, main = substitute(n == k, list(k = k))) > ### this works > plot(0,0, main =
2012 May 25
1
knitr customization
I am trying to transition from Sweave to knitr, but there are a few things about customization of the appearence of R input and output that I did not get yet. Maybe somebody on the list can help me. In my Sweave presentations I used a slanted font for the R input and a normal font for the output, both in a small font. I also indented everything by an extra 2em. All this was achieved by the
2011 Mar 09
4
Help with read.csv
Hello, I have a file that looks like this: Date,Hour,DA_DMD,DMD,DA_RTP,RTP,, 1/1/2006,1,3393.9,3412,76.65,105.04,, 1/1/2006,2,3173.3,3202,69.20,67.67,, 1/1/2006,3,3040.0,3051,69.20,77.67,, 1/1/2006,4,2998.2,2979,67.32,69.10,, 1/1/2006,5,3005.8,2958,65.20,68.34,, where the ',' is the separator and I tried to read it into R, but... > y <- read.csv("Data/Data_tmp.csv",
2004 Feb 06
3
quantile function
I am trying to `cut' a continuous variable into contiguous classes containing approximately an equal number of observations. I thought quantile() was the appropriate function to use in order to find the breakpoints, but I end up with classes of different sizes - see example below. Does anybody have an explanation for that? And what is the `recommended' way of computing what I am looking
2003 Oct 24
5
how to remove NaN columns ?
How can I remove columns with NaN entries ? Here is my simple example: > data <- read.csv("test.csv") > xdata <- data[3:length(data)] > xs <- lapply(xdata, function(x){(x - mean(x))/sqrt(var(x))}) > x <- data.frame(xs) > x C D E F 1 -0.7071068 NaN -0.7071068 -0.7071068 2 0.7071068 NaN 0.7071068 0.7071068