similar to: Why does length("") == 1?

Displaying 20 results from an estimated 4000 matches similar to: "Why does length("") == 1?"

2012 Apr 17
3
Can a matrix have 'list' as rows/columns?
After a lot of processing I get a matrix into M. I expected each row and column to be a vector. But it is a list. R-Inferno says... "Arrays (including matrices) can be subscripted with a matrix of positive numbers. The subscripting matrix has as many columns as there are dimensions in the array—so two columns for a matrix. The result is a vector (not an array) containing the selected
2012 Jul 17
3
complexity of operations in R
Hello! I am optimizing my code in R and for this I need to know a bit more about the internals. It would help tremendously if someone could link me to a page with O()-complexities of all the operations. In this particular case, I need something like a linked list with O(1) insertLast/First ability. I can't preallocate a vector since I do not know the final size of the list ahead of time. The
2012 Jan 26
2
What does [[1]] mean?
I know that [] is used for indexing. I know that [[]] is used for reference to a property of a COM object. I cannot find any explanation of what [[1]] does or, more pertinently, where it should be used. Thank you. [[alternative HTML version deleted]]
2012 Mar 03
1
"Global" Variable in R
Dear all, I would like to ask you if there is a way to define a global variable in R? I am having a bunch of function and I think the easier would be to have a global function defined at some point... Would that be possible? Regards Alex [[alternative HTML version deleted]]
2012 Jun 30
2
incorrect number of subscripts on matrix
Hi, Wondering if anyone could help me out with this error.Im trying to fill a matrix with random numbers taken from an exponential distribution using a loop: x.3<-matrix(rep(0,3000),nrow=1000,byrow=T)for(i in 1:1000){x[i,]<-rexp(3,rate=2/3)} I get the error message: Error in x[i, ] <- rexp(3, rate = 2/3) : incorrect number of subscripts on matrix Any ideas??? Appreciate any thoughts.
2012 Mar 05
2
no partial matching of argument names after dots argument - why?
I noticed that the argument names after the dots argument are not partially matched. foo <- function(one, two, ...){ one + two } > foo(o=1, t=2) [1] 3 foo <- function(one, ..., two){ one + two } > foo(o=1, t=2) Fehler in one + two : 'two' fehlt Can someone explain me the reason for this behavior? THX Mark ???????????????????????????????????? Mark Heckmann Blog:
2012 Dec 15
3
How to speed up the for loop by releasing memeory
Dear list; How can I speed up the run of following code (illustrative) #======================================================================== con<-vector("numeric") for (i in 1:limit) { if(matched data for the ith item found) { if(i==1) {con<-RowOfMatchedData } else {con<-rbind(con,matchedData)} } }
2011 Dec 23
3
if statement problem
Hello, I want to do fisher test for the rows in data file which has value less than 5 otherwise chi square test .The p values from both test should be stored in one resulted file. but there is some problem with bold if statement. I don't know how implement this line properly. x = cbind(obs1,obs2,exp1,exp2) a = matrix(c(0,0,0,0), ncol=2, byrow =TRUE) #matrix with initialized values
2011 Dec 11
3
how to assign a value?
Hi there, I hope to modify values in a vector or matrix in the following code: for (i in 1:9) { assign(paste("a.", i, sep = ""), 1:i) get(paste("a.", i, sep = ""))[i] <- i+50 } I get the following error message: Error in get(paste("a.", i, sep = ""))[i] <- i + 50 : target of assignment expands to non-language object
2011 Sep 12
3
Solve your R problems
R-help is all about solving R problems. So here ya go: http://www.portfolioprobe.com/2011/09/12/solve-your-r-problems/ -- Patrick Burns pburns at pburns.seanet.com twitter: @portfolioprobe http://www.portfolioprobe.com/blog http://www.burns-stat.com (home of 'Some hints for the R beginner' and 'The R Inferno')
2013 Feb 28
2
Fortune?
I think the rule is that you can do anything as long as you don't complain. If you want to complain, you must follow the instructions. -- Jari Oksanen in Re: [Rd] Keeping up to date with R-devel -- Patrick Burns pburns at pburns.seanet.com twitter: @burnsstat @portfolioprobe http://www.portfolioprobe.com/blog http://www.burns-stat.com (home of: 'Impatient R' 'The R
2012 May 20
4
R Memory Issues
---------- Forwarded message ---------- From: Emiliano Zapata <ezapataika@gmail.com> Date: Sun, May 20, 2012 at 12:09 PM Subject: To: R-help@r-project.org Hi, I have a 64 bits machine (Windows) with a total of 192GB of physical memory (RAM), and total of 8 CPU. I wanted to ask how can I make R make use of all the memory. I recently ran a script requiring approximately 92 GB of memory to
2012 Sep 17
3
Can anyone help why the errors are coming and rectify it?
Hi Everyone, Can anyone help why the errors are coming and rectify it? invalid.ids <- c(1,3,5) if (length(invalid.ids)==0) { cat("No Errors found") } else {
2009 Jan 09
5
The R Inferno
"The R Inferno" is now on the Burns Statistics website at http://www.burns-stat.com/pages/Tutor/R_inferno.pdf Abstract: If you are using R and you think you're in hell, this is a map for you. Also, I've expanded the outline concerning R on the Burns Statistics 'Links' page. Suggestions (off-list) for additional items are encouraged. Patrick Burns patrick at
2014 Jan 03
1
wishlist: decreasing argument to is.unsorted
I've just realized that it could be handy to have a 'decreasing' argument in 'is.unsorted'. And I'm cheekily hoping someone else will implement it. It is easy enough to work around (with 'rev'), but would be less hassle with an argument. The case I have in mind uses 'is.unsorted' in 'stopifnot'. Pat -- Patrick Burns pburns at pburns.seanet.com
2012 Apr 26
8
understanding the FUNCTION function
Hello, I am trying to understand why the FUNCTION used in several codes, won't create the object after it finishes running the code. For instance, look at the following: Number<- function(x) {MyNumberIs<-x} When I run Number(5) Everything goes well, except that if I try to call the object MyNumberIs, I won't find it. I understand that this function can assume many parameters,
2013 Mar 02
3
if value is in vector, perform this function
Hi, I'm trying to set up R to run a simulation of two populations in which every 3.5 days, the initial value of one of the populations is reset to 1.5. I'm simulation an experiment we did in which we fed Daphnia populations twice a week with algae, so I want the initial value of the algal population to reset to 1.5 twice a week to simulate that feeding. I've use for loops and if/else
2011 Oct 06
3
Running *slow*
Anyone got any hints on how to make this code more efficient? An early version (which to be fair did more than this one is) ran for 330 hours and produced no output. I have a two column table, Dat, with 12,000,000 rows and I want to produce a lookup table, ltable, in a 1 dimensional matrix with one copy of each of the values in Dat: for (i in 1:nrow(Dat)) { for (j in 1:2) { #If next
2009 Sep 24
2
Date formats in as.Date
I have trouble with this: as.Date("Sep-1981", format="%b-%Y") Returns "NA" >From documentation for strftime '%b' Abbreviated month name in the current locale. (Also matches full name on input.) '%Y' Year with century. What am I doing wrong? cheers Worik [[alternative HTML version deleted]]
2010 Jun 16
5
t-test problem
I have two pairs of related vectors x1,y1 and x2,y2 I wish to do a test for differences in means of x1 and y1, ditto x2 and y2. I am getting odd results. I am not sure I am using 'pt' properly... I have not included the raw vectors as they are long. I am interested if I am using R properly... > c(length(x1), length(y1), length(x2), length(y2)) [1] 3436 1619 2677 2378 First