similar to: sequential for loop

Displaying 20 results from an estimated 7000 matches similar to: "sequential for loop"

2007 Jan 14
4
Controlling size of boxplot when it is added in a plot
Greetings, I am trying to add a boxplot to the bottom of a histogram, right between the histogram bars and the x axis. Here is the code I am using at the moment (the par line is probably not relevant for our discussion): hs <- hist(x, breaks = 20, plot = F) par(mar = c(3,3,2,1)) hist(x, breaks = 20, main = NULL, ylim = c(-2, max(hs$counts))) boxplot(x, horizontal = T, axes = T, add =
2008 Mar 05
3
types of vectors / lists
Hello, I am an advanced user of R. Recently I found out that apparently I do not fully understand vectors and lists fully Take this code snippet: T = c("02.03.2008 12:23", "03.03.2008 05:54") Times = strptime(T, "%d.%m.%Y %H:%M") Times # OK class(Times) # OK is.list(Times) # sort of understand and not understand that length(Times)
2007 Mar 01
2
R code for "Statistical Models in S" ?
I just acquired a copy of "Statistical Models in S", I guess most commonly known as the "white book", and realized to my dismay that most of the code is not directly executable in R, and I was wondering if there was a source discussing the things that are different and what the new ways of calling things are. For instance, the first obstacle was the solder.balance data
2007 Feb 22
1
Cross-tabulations next to each other
I have the following relatively simple problem. Say we have three factors, and we want to create a cross-tabulation against each of the other two: x <- factor(rbinom(5, 1, 1/2)) y <- factor(rbinom(5, 1, 1/2)) z <- factor(rbinom(5, 1, 1/2)) table(x,y) table(x,z) This looks like: y x 0 1 0 2 0 1 1 2 z x 0 1 0 1 1 1 2 1 I would like to get (surely this will
2008 Dec 11
3
getting ISO week
Hi all, Is there a simple function already implemented for getting the ISO weeks of a Date object? I couldn't find one, and so wrote my own function to do it, but would appreciate a pointer to the "default" way. If a function is not yet implemented, could the code below be of interest to submit to CRAN? Best Regards, Gustaf --------------------
2007 Feb 04
4
Reading expressions from character vectors
Greetings, I have a problem that I am sure is very straightforward, but I just can't wrap my head around it. I've read the help pages on text, plotmath, expression, substitute, but somehow I can't find the answer to this simple question. Basically consider the following example: plot( NULL, xlim = c(0,2), ylim = c(0,2) ) expressions <- expression( -infinity, infinity )
2008 Mar 05
4
vertex labels in igraph from adjacency matrix
I am getting some unexpected results from some functions of igraph and it is possible that I am misinterpreting the vertex numbers. Eg., the max betweenness measure seems to be from a vertex that is not connected to a single other vertex. Below if my code snippet: require(igraph) my.graph <- graph.adjacency(adjmatrix = my.adj.matrix, mode=c("undirected")) most.between.vert <-
2013 Mar 19
1
Convert to date and time of the year
Dear R Users, I have data for more than 3 years. For each year I want to find the day corresponding to Jaunary 1 of that year. For example: > x <- c('5/5/2007','12/31/2007','1/2/2008') > #Convert to day of year (julian date) - > strptime(x,"%m/%d/%Y")$yday+1 [1] 125 365 2 I want to know how to do the same thing but with time added. But I still
2008 Mar 10
3
Weighting data when running regressions
Dear R-Help, I'm new to R and struggling with weighting data when I run regression. I've tried to use search to solve my problem but haven't found anything helpful so far. I (successfully) import data from SPSS (15) and try to run a linear regression on a subset of my data file where WEIGHT is the name of my weighting variable (numeric), e.g.: library(foreign)
2008 Jun 06
2
write.table() error
Hi, I got following error in write.table() : > write.table(dataa, file="c:/data1.csv", row.names=F, col.names=T, sep=",") Error in file(file, ifelse(append, "a", "w")) : cannot open the connection In addition: Warning message: In file(file, ifelse(append, "a", "w")) : cannot open file 'c:/data1.csv': Permission denied
2007 Dec 17
3
Cannot grasp how to apply "by" here...
I have a data frame named "database" with panel data, a little piece of which looks like this: Symbol Name Trial Factor1 Factor2 External 1 548140 A 1 -3.87 -0.32 0.01 2 547400 B 1 12.11 -0.68 0.40 3 547173 C 1
2006 Nov 08
6
Making a case for using R in Academia
Hello, new to the list, first message. This question perhaps might be more appropriate to R-sig-teaching, and I'd be happy to take it there if this is not the right place for it. I am teaching applied statistics at a small liberal arts college with limited resources, and we are currently using SPSS for our courses. Mainly the reason for this, as I understand it, is that this is what
2008 May 23
2
About Passing Arguments to Function
Hi, Below I have a function mlogl_k, later it's called with "nlm" . __BEGIN__ vsamples<- c(14.7, 18.8, 14, 15.9, 9.7, 12.8) mlogl_k <- function( k_func, x_func, theta_func, samp) { tot_mll <- 0 for (comp in 1:k_func) { curr_mll <- (- sum(dgamma(samp, shape = x_func, scale=theta_func, log = TRUE))) tot_mll <- tot_mll + curr_mll }
2007 Nov 07
3
Indexing, and using an empty string as a name
Hello all, I ran into the following, to me unexpected, behavior. I have (for reasons that don't necessarily pertain to the question at hand, hence I won't go into them) the need/desire to use an empty string for the name of a vector entry. Perhaps I did not read ?"[" very carefully, but it seems to me that he following lines should return "1" at the end:
2005 Jul 23
2
link_stat
Hi there, I set up my company's back up server using rsync. And I've got a strange problem. I searched in the archives of this list, but none of them seems not giving me an idea to solve the problem. If anyone can help, it would be grateful. I'm using cron by a user (non wheel/admin) to rsync everyday during the night. The cron is set in the server to transfer the backing-up
2007 Mar 21
1
bug and patch: strptime first-of-month error in (possibly unsupported use of) "%j" format (PR#9577)
Full_Name: John Brzustowski Version: R-devel-trunk OS: linux (problem under Windows too) Submission from: (NULL) (74.101.124.238) (This bug was discovered by Phil Taylor, Acadia University.) I'm not sure from reading the documentation whether strptime(x, "%j") is meant to be supported, but if so, there is a bug which prevents it from working on the first day of months after
2008 Jun 07
2
Using lm with a matrix?
I'm trying to do a linear regression between the columns of matrices. In example below I want to regress column 1 of matrix xdat with column1 of ydat and do a separate regression between the column 2s of each matrix. But the output I get seems to give correct slopes but incorrect intercepts and another set of slopes with value NA. How do I do this correctly? I'm after the slope and
2010 Oct 01
3
Converting a dataframe column from string to datetime
Hi, I have a dataframe column of the form v<-c("Fri Feb 05 20:00:01.43000 2010","Fri Feb 05 20:00:02.274000 2010","Fri Feb 05 20:00:02.274000 2010","Fri Feb 05 20:00:06.34000 2010") I need to convert this to datetime form. I did the following.. lapply(v,function(x){strptime(x, "%a %b %d %H:%M:%OS %Y")}) This gives me a list that looks like
2008 Mar 09
1
Calling plot with a formula, from within a function, using ..., and xlim
I ran into a weird, to me at least, problem, and hoping someone can shed some light into it. In a nutshell, there seems to be some problem when one calls plot with a formula, from within another function, using ... to pass arguments, and one of those arguments being xlim (and only xlim shows this problem). Here is an example: > plotw <- function(obj,...) { + plot(k~j,
2005 Jan 17
2
Question about time series
I have data in the following format: > DATE [1] "01/13/2004" In order to find the difference between two data points, I presently use brute force to calculate the day of the year: > strptime(DATE, format="%m/%d/%Y")$yday [1] 12 Although this works, it may not be robust over different years. I assume that R is sufficiently clever that a much simpler approach