similar to: How to add rowSums into list?

Displaying 20 results from an estimated 7000 matches similar to: "How to add rowSums into list?"

2007 May 20
2
Number of NA's in every second column
Hi R-users, How do I calculate a number of NA's in a row of every second column in my data frame? As a starting point: dfr <- data.frame(sapply(x, function(x) sample(0:x, 6, replace = TRUE))) dfr[dfr==0] <- NA So, I would like to count the number of NA in row one, two, three etc. of columns X1, X3, X5 etc. Thanks in advance Lauri [[alternative HTML version deleted]]
2007 Dec 03
3
ggplot2: Choosing colours
Dear useRs, I'm trying to specify the colour of a factor with ggplot2. The example below gets me close to what I want, but it's missing a legend. Any ideas? Thanks, Thierry library(ggplot2) dataset <- data.frame(x = rnorm(40), y = runif(40), z = gl(4, 10, labels = LETTERS[1:4])) ggplot(data = dataset, aes(x = x, y = y, group = z)) + geom_point(colour = c("red",
2006 Nov 21
2
using nested ifelse and rowSums to create new variable?
Dear R-help community, If I have a data.frame df as follows: > df x1 x2 x3 x4 x5 x6 1 5 5 1 1 2 1 2 5 5 5 5 1 5 3 1 5 5 5 5 5 4 5 5 1 4 5 5 5 5 1 5 2 4 1 6 5 1 5 4 5 1 7 5 1 5 4 4 5 8 5 1 1 1 1 5 9 1 5 1 1 2 5 10 5 1 5 4 5 5 11 1 5 5 2 1 1 12 5 5 5 4 4 1 13 1 5 1 4 4 1 14 1 1 5 4 5 5 15 1 5 5 4
2006 Oct 25
3
simplification of code using stamp?
Hi I have the following code which I would like to simplify. Id does linear regressions and returns the r-squares, and the coefficients. It runs slow, as it is doing the regressions for each - is it possible to get the values in a dataframe which looks as follow: expert | xx | seeds | r.squared | slope | intercept Thanks in advance, Rainer library(reshape) rsqs <- as.data.frame(
2007 Feb 13
1
RE2: Suddenly "Subscript out of bounds"
If you tell me how to update R itself automatically, I will go for your advice. I am not aware of any method to do it... Bye Rick "ONKELINX, Thierry"
2008 Feb 06
2
Multivariate Maximum Likelihood Estimation
Hi, I am trying to perform Maximum Likelihood estimation of a Multivariate model (2 independent variables + intercept) with autocorrelated errors of 1st order (ar(1)). Does R have a function for that? I could only find an univariate option (ar.mle function) and when writing my own I find that it is pretty memory-consuming (and sometimes wrong) so there must be a better way. Thanks, KB
2008 Feb 12
3
problems plotting geom_line on ggplot2
Se ha borrado un texto insertado con un juego de caracteres sin especificar... Nombre: no disponible Url: https://stat.ethz.ch/pipermail/r-help/attachments/20080212/16ba8b97/attachment.pl
2009 Sep 08
7
Data separated by spaces, getting data into R using field lengths
I have a text file similar to this (separated by spaces): x <- "DF12 This is an example 1 This DF12 This is an 1232 This is DF14 This is 12334 This is an DF15 This 23 This is an example " and I know the field lengths of each variable (there is 5 variables in this data set), which are: varlength <- c(2, 2, 18, 5, 18) How can I import this kind of data into R, using the varlength
2008 Feb 21
4
How to get names of a list into df:s?
R users, I have a simple lapply question. g <- list(a=1:3, b=4:6, c=7:9) g <- lapply(g, function(x) as.data.frame(x)) lapply(g, function(x) cbind(x, var1 = rep(names(g), each=nrow(x))[1:nrow(x)])) I get $a x var1 1 1 a 2 2 a 3 3 a $b x var1 1 4 a 2 5 a 3 6 a $c x var1 1 7 a 2 8 a 3 9 a And I would like to have $a x var1 1 1 a 2 2 a 3 3 a
2007 Oct 04
5
A rebel boxplot question
Dear R list members I am trying to improve a boxplot with 2 data sets. I run somethinkg like boxplot(data1 ~ month, add=F, col = "red", ...) boxplot(data2 ~ month, add=T, col = "blue", ...) The problem is that the data from February are missing for data2, so R think that must take little more space between the data classes in data 2 and then both data gropus are not aligned.
2008 Aug 20
2
Random sequence of days?
Dear list, I tried to find a solution for this problem from the archives but couldn't find any. I would like sample sequence of ten days from vector d d <- seq(as.Date("2007-02-12"), as.Date("2008-08-18"), by="days") so that the days follow each other (sample(d, 10) is not the appropriate solution). Any ideas? Best regards, Lauri
2008 Jan 14
6
Ceiling to the nearest ten?
R-users, Is there a function for ceiling to the nearest ten? a <- 1:10*4 a [1] 4 8 12 16 20 24 28 32 36 40 The resulting vector should look like this ("ceiling to the nearest ten") [1] 10 10 20 20 20 30 30 40 40 40 Thanks in advance Lauri
2007 Sep 10
3
plot legend: combining filled boxes and lines
Hello, I have difficulties combining boxes and lines in plot legend. I searched previous R-posts and found this (with no solution): http://tolstoy.newcastle.edu.au/R/help/06/07/30248.html. Is there a way to avoid boxes behind the line legends? x1 <- rnorm(100) x2 <- rnorm(100, 2) hist(x1, main = "", col = "orange",ylab = "density", xlab = "x", freq =
2007 May 18
4
Simple programming question
Hi R-users, I have a simple question for R heavy users. If I have a data frame like this dfr <- data.frame(id=1:16, categ=rep(LETTERS[1:4], 4), var3=c(8,7,6,6,5,4,5,4,3,4,3,2,3,2,1,1)) dfr <- dfr[order(dfr$categ),] and I want to score values or points in variable named "var3" following this kind of logic: 1. the highest value of var3 within category (variable named
2007 Mar 20
6
Select the last two rows by id group
Hi R-users, Following this post http://tolstoy.newcastle.edu.au/R/help/06/06/28965.html , how do I get last two rows (or six or ten) by id group out of the data frame? Here the example gives just the last row. Sincere thanks, Lauri [[alternative HTML version deleted]]
2007 Jul 18
1
Strange warning in summary.lm
Dear useRs, Lately I noticed a strange warning in the summary of a lm-object. Any idea what this warning is about? I'm using R 2.5.1 on Win XP pro. > x <- rnorm(100) > y <- rnorm(100) > summary(lm(y~x)) Call: lm(formula = y ~ x) Residuals: Min 1Q Median 3Q Max -1,77809 -0,68438 -0,04409 0,63891 2,30863 Coefficients: Estimate Std.
2008 Feb 25
3
Logical statements and subseting data...
Hi, I'm scratching my head as to why I can't use the subset() command to remove one line of data from a data frame. There is just one row (out of 45840) that I'd like to remove and it can be identified using.... > dim(raw.all.clean) [1] 45840 10 > subset(raw.all.clean, Height.1 == 0 & Height.2 == 0) Sample.Name Well SNP Allele.1 Allele.2 Size.1 Size.2
2007 Aug 07
4
Number of days in each month
Hi R-users, What is the best way to achieve a table which contains all days and months between years 2007-2020? I would like to calculate number of days in each month within those years (to data frame). Regards, Lauri [[alternative HTML version deleted]]
2007 Oct 15
2
Variable which has the maximum value of DF
Hi, Suppose I have a data.frame like this Lines <- "var1 var2 var3 var4 var5 var6 0 2 1 2 0 0 2 3 7 6 0 1 1.5 4 9 9 6 0 1.0 6 10 22 3 3 " DF <- read.table(textConnection(Lines), skip=1) names(DF) <- scan(textConnection(Lines), what = "", nlines = 1) How do I find the
2008 Mar 18
3
How to get week of the year, scale 1-52?
R users, I have a vector of dates days <- seq(as.Date("2007/1/1"), as.Date("2008/1/31"), "days") and I would like to have week numbers from 1 to 52 for each year. How do I do that? Now I get 00-53 using format(days, "%W") > range(format(days, "%W")) [1] "00" "53" I have read "Date and Time Classes in R" (R