Re: [R] hist function in a for loop

2013-06-18 Thread Rui Barradas
Hello, Sorry, I forgot to Cc the list. Rui Barradas Em 18-06-2013 16:29, Rui Barradas escreveu: Hello, Inline. Em 18-06-2013 15:54, Dzu escreveu: Dear all, I need to create a for-loop in which I can compute multiple histograms My code is the following : #singlefile includes huge csv file

Re: [R] hist in a for loop

2013-06-18 Thread Rui Barradas
clear. Rui Barradas Em 18-06-2013 21:04, Dizem Uerek escreveu: Hello Thanks for reply I want to compute several histograms in a for loop.I am trying to set the binsize constant in the beginning. #compute the histograms for (i in 1:12) { binsize <- -20 :20/2 hist(single

Re: [R] hist function in a for loop

2013-06-19 Thread Rui Barradas
ll to hist() that does work, without a for loop. Rui Barradas I want to do the following : #I have created a huge csv.files with 44 colums #I want to select the specific colums from these files #CL1 consist data from which I want to compute the histogramms, CL2 is the cloumn which has numbers

Re: [R] to build a data.frame

2013-06-19 Thread Rui Barradas
Hello, Try the following. aggregate(Project ~ Country + Iso, data = df, FUN = length) Hope this helps, Rui Barradas Em 19-06-2013 15:23, Arnaud Michel escreveu: Hello I have the following dataframe df <- data.frame( Project=c("Abaco","Abaco","Abac"

Re: [R] Levene's test output

2013-06-21 Thread Rui Barradas
Hello, The Pr(>F) is a regular p-value, with the usual meaning. Rui Barradas Em 21-06-2013 11:05, pieter escreveu: k. Thanks. Sorry i'm not the biggest statician, but I still find the output write out not the clearest of all. Anyway, that is probably a personal problem. :-) Just one

Re: [R] Levene's test output

2013-06-21 Thread Rui Barradas
Hello, Just to add to the last post, you can try to get that p-value using what that output gives you: df1 <- 1 df2 <- 356 F_stat <- 10.948 pf(F_stat, df1, df2, lower.tail = FALSE) # same value Hope this helps, Rui Barradas Em 21-06-2013 12:11, Rui Barradas escreveu: Hello,

Re: [R] How to define desired numbers to a vector based on the present numbers

2013-06-21 Thread Rui Barradas
engths)[order(order(x))] plot(x, col = cols) Hope this helps, Rui Barradas Em 21-06-2013 16:13, Suparna Mitra escreveu: Hello R experts, I want to define desired numbers to a vector based on the present numbers. Can anybody please help me? Obviously I found worst ways to do it, but I believe the

Re: [R] hdr.den plot colors help

2013-06-21 Thread Rui Barradas
Hello, It's not your first post, you should know to say from which package is the function you're using. As for the question the answer is no, those values are hard coded in the source. What you can do is to download the source and change file hdr.den.R Hope this helps, Rui Ba

Re: [R] I have another question

2013-06-22 Thread Rui Barradas
Hello, At an R prompt type ?lgamma ?nlminb and read the respective help pages. Hope this helps, Rui Barradas Em 22-06-2013 10:54, 심정인 escreveu: Could you tell me what mean is that lgamma, digamma, and nlminb ? [[alternative HTML version deleted

Re: [R] I have a question

2013-06-22 Thread Rui Barradas
Hello, There's a no homework policy. Please ask your question here: http://stackoverflow.com/questions/tagged/r Hope this helps, Rui Barradas Em 22-06-2013 10:06, 심정인 escreveu: Hi! my name is jeong in Sim. Now I'm studying MLE(Maximum Likelyhood Estimation) and MOM(Method of m

Re: [R] Built-in function for extracting mantissa and exponent of a numeric

2013-06-23 Thread Rui Barradas
Hello, Sorry I forgot to Cc the list. And I had forgotten the case where x == 0. extract <- function(x){ e <- ifelse(x == 0, 0, floor(log10(x))) m <- x/10^e list(mantissa = m, exponent = e) } extract(c(0, 1.234e12, 12345678901234, 123e123)) Hope this he

Re: [R] Scaling Statistical

2013-06-23 Thread Rui Barradas
Hello, Sorry, I forgot to Cc the list. Rui Barradas Em 23-06-2013 21:44, Rui Barradas escreveu: Hello, See if the following does what you want. lapply(seq_len(obsv), function(i) adf.test(df[df$ID == i, 3])) Hope this helps, Rui Barradas Em 23-06-2013 19:12, Olga Musayev escreveu: Short

Re: [R] Function in R saving in xls

2013-06-23 Thread Rui Barradas
Hello, To work with xls files, check out package XLConnect. The vignette explains how to use it rather well. Also, don't use attach() It can be confusing and a source for errors. Hope this helps, Rui Barradas Em 23-06-2013 21:54, Sérgio Henrique almeida da silva ju escreveu: I crea

Re: [R] R: Apply a Seasonal ARMA process

2013-06-24 Thread Rui Barradas
he suggested. Hope this helps, Rui Barradas Em 24-06-2013 10:34, Stefano Sofia escreveu: Thank you for your tips. I tried the code that you suggested, but there is a problem with the length of fixed. In the help page it is specified that the length of fixed must be total number of parameters

Re: [R] extracting submatrix from a bigger one

2013-06-24 Thread Rui Barradas
Hello, Try the following. result <- lapply(unique(dataset$ID), function(uid) dataset[dataset$ID == uid, ]) names(result) <- unique(dataset$ID) Hope this helps, Rui Barradas Em 24-06-2013 15:36, matteo escreveu: Hi guys, I'm a newby, so sorry for the easy question. I ha

Re: [R] extracting submatrix from a bigger one

2013-06-24 Thread Rui Barradas
Hello, You don't have a sub-data.frame, what you have is a list, with each element of that list a df. Try to see, for instance, result[[1]]. This should be a data.frame corresponding to the first ID. Rui Barradas Em 24-06-2013 18:03, matteo escreveu: Hi, result <- lapply(unique

Re: [R] extracting submatrix from a bigger one

2013-06-24 Thread Rui Barradas
Hello, I had forgotten the much simpler solutions. The following should do it. split(dataset, dataset$ID) Rui Barradas Em 24-06-2013 18:13, Bert Gunter escreveu: First of all, is your data structure a matrix or a data frame? They are different! Assuming the latter, a shorter version of

Re: [R] Scaling Statistical

2013-06-24 Thread Rui Barradas
3 residuals, all zero, like seen above.) Rui Barradas Em 24-06-2013 20:12, Olga Musayev escreveu: Rui-- thanks so much for the help! I'm getting this error though, which is leaving me stumped: test<-lapply(ids, function(i) { if(!any(is.na <http://is.na>(df[df$ID==i,3]))) {adf.t

Re: [R] Lexical scoping is not what I expect

2013-06-24 Thread Rui Barradas
a <- 5 g(x) } f(2) # 7 Now R is finding 'a'. Because g() exists in the environment of f() (like 'a' does.) Hope this helps, Rui Barradas Em 24-06-2013 21:27, David Kulp escreveu: According to http://cran.r-project.org/doc/contrib/Fox-Companion/appen

Re: [R] SP package

2013-06-25 Thread Rui Barradas
Hello, R is open source. You can download the source code for package sp. http://cran.r-project.org/web/packages/sp/index.html Hope this helps, Rui Barradas Em 25-06-2013 08:06, Dr. Alireza Zolfaghari escreveu: Hi list, I would like to write the function [R_point_in_polygon_sp] in c# as I

Re: [R] return output to console for copying as input

2013-06-25 Thread Rui Barradas
Hello, Maybe ?cat cat(X, "\n") (But it doesn't put the vector elements between quotes.) Hope this helps, Rui Barradas Em 25-06-2013 08:14, nevil amos escreveu: I want to print a vector of strings to the console formatted as if it were input X<-c("a","b&

Re: [R] x-labels in barplots

2013-06-25 Thread Rui Barradas
Hello, Use graphic parameter las = 2. See the help for ?par. Hope this helps, Rui Barradas Em 25-06-2013 07:03, alfonso.carf...@uniparthenope.it escreveu: Hi, I need to generate a barplot in in which the x-labels must to be perpendiculars to the x-axis in my data have a list of probability

Re: [R] Fetch and merge from a data set

2013-06-25 Thread Rui Barradas
Hello, I'm not sure I understand, but it seems as simple as merge(data1, data) Hope this helps, Rui Barradas Em 25-06-2013 10:34, Nico Met escreveu: Dear all, I would like to fetch a list (data1) of entities from a big data file (data) and merged together. for example: data is the

Re: [R] Calculate geometric mean with tapply

2013-06-25 Thread Rui Barradas
Hello, You can write a function gmean and tapply it to your data. gmean <- function(x, na.rm = FALSE){ if(na.rm) x <- x[!is.na(x)] n <- length(x) prod(x)^(1/n) } tapply(data$value, data$group, gmean) Hope this helps, Rui Barradas Em 25-06-2013 11:58, Sh

Re: [R] Heatmap with error message: `x' must be a numeric matrix

2013-06-25 Thread Rui Barradas
ata[] <- sapply(data, function(x) as.numeric(sub(",", "\\.", x))) data1 <- as.matrix(data) heatmap.2(...) # No errors Hope this helps, Rui Barradas Em 25-06-2013 19:49, Gitte Brinch Andersen escreveu: Hi I am trying to do a heatmap, but I can't see what I am d

Re: [R] create index for tapply or by

2013-06-27 Thread Rui Barradas
Hello, Try using ?cut y2 <- cut(x, breaks) by(x, y2, sum) Hope this helps, Rui Barradas Em 27-06-2013 09:24, Witold E Wolski escreveu: Is there a build in function to create an index for tapply or by given a a numeric vector x an a vector of breaks? What I want to do is: x <-

Re: [R] LSD comparison

2013-06-27 Thread Rui Barradas
Hello, After installing the package (just once) you have to load it in the R session (every time you start a session that will use it.) You do this with the following command. library(agricolae) # load the package Hope this helps, Rui Barradas Em 27-06-2013 11:17, bawonpon chonipat

Re: [R] multivariate version of aggregate

2013-06-27 Thread Rui Barradas
Hello, Or use ?sapply. sapply(split(dat[1:2], dat[3]), function(x) cor(x[1], x[2])) Hope this helps, Rui Barradas Em 27-06-2013 20:22, David Carlson escreveu: You can pass a matrix to by() set.seed(42) dat <- data.frame(x=runif(50)*20, y=runif(50)*20, g=rep(LETTERS[1:2], each

Re: [R] when to use & pros/cons of dataframe vs. matrix?

2013-06-27 Thread Rui Barradas
ew = newdat) There are many other examples like this one. If you are doing data modeling, use data frames. Hope this helps, Rui Barradas Em 27-06-2013 19:26, Anika Masters escreveu: When "should" I use a dataframe vs. a matrix? What are the pros and cons? If I have data of all the

Re: [R] multivariate version of aggregate

2013-06-28 Thread Rui Barradas
]))) Hope this helps, Rui Barradas Em 28-06-2013 09:31, Jannis escreveu: Yes, I had a look at that function. From the documentation, however, it did not get clear to me how to split the dataframe into subsets of rows based on an index argument. Like: testframe <- data.frame(a=rnorm(100), b = rnorm(

Re: [R] To transform a dataframe

2013-06-29 Thread Rui Barradas
Hello, The following does what you want but the order of columns is different. reshape(df1, v.names = c("Cat", "Début", "Fin"), idvar = "Mat", timevar = "Cat", direction = "wide") Hope this helps, Rui Barradas Em 29-06

Re: [R] writing to the screen and extra "0"

2013-07-01 Thread Rui Barradas
Hello, Try instead list.files(pattern = "*") Hope this helps, Rui Barradas Em 01-07-2013 19:23, Thomas Grzybowski escreveu: I am using the "write" function like so (R 3.0.1 on linux): "wrt" <- function() { write(system("ls *"),file=&qu

Re: [R] Recoding variables based on reference values in data frame

2013-07-02 Thread Rui Barradas
o[, -1], fun) Kgeno Also, the best way to post data is by using ?dput. dput(head(Kgeno[, 1:5], 30)) # post the output of this Hope this helps, Rui Barradas Em 02-07-2013 21:46, kathleen askland escreveu: I'm new to R (previously used SAS primarily) and I have a genetics data frame consisti

Re: [R] Recoding variables based on reference values in data frame

2013-07-02 Thread Rui Barradas
Mm <- paste0(as.character(x[1]), as.character(x[2])) # Major minor mm <- paste0(as.character(x[2]), as.character(x[2])) # minor minor x[x == MM] <- 0 x[x == Mm] <- 1 x[x == mm] <- 2 x } Rui Barradas Em 02-07-2013 22:15, Rui Barradas

Re: [R] Identifying duplicate rows?

2012-09-10 Thread Rui Barradas
el = "VA", class = "factor"), Value = c(73L, 73L, 76L, 76L, 74L, 75L)), .Names = c("Site", "State", "Value"), class = "data.frame", row.names = c(NA, -6L)) # Now use the argument 'fromLast' dfA$dups <- duplicated(dfA) | dupl

Re: [R] how to create a segplot in black and white?

2012-09-10 Thread Rui Barradas
bands = FALSE, centers = ratioBiomass, [...etc...] Rui Barradas Em 10-09-2012 23:07, barbara costa escreveu: Hi Rui, I'd really need the plot only in black so I ran the following code using your suggestion (with col="black)", but I'm getting the color scale at the right sid

Re: [R] how to make a folder as package in R

2012-09-11 Thread Rui Barradas
Hello, See also http://cran.r-project.org/doc/contrib/Leisch-CreatingPackages.pdf Hope this helps, Rui Barradas Em 11-09-2012 09:53, R. Michael Weylandt escreveu: Start with ?package.skeleton() Cheers, Michael On Tue, Sep 11, 2012 at 9:47 AM, purushothaman wrote: Hi how to make a

Re: [R] Searching from Dataframe.

2012-09-11 Thread Rui Barradas
Hello, Try which("B" == Mylist) Hope this helps, Rui Barradas Em 11-09-2012 13:31, Rantony escreveu: How can I get index from a list if I know the listitem ? For eg:- Mylist<-c("A","B","C") Acually,Here I need to get the index of "B" a

Re: [R] Combine two variables

2012-09-11 Thread Rui Barradas
became reproducible. set.seed(1) df1 <- data.frame(var1=sample(c('a','b','c',NA), replace=TRUE, size=100), var2=sample(c('a','b','c',NA), replace=TRUE, size=100)) sum(is.na(df1$var1) & is.na(df1$var2)) # 8 So I suppose this i

Re: [R] creating several different matrices

2012-09-11 Thread Rui Barradas
Hello, Try, using data and matrix dims of your choice, replicate(100, matrix(rnorm(12), ncol = 3)) Hope this helps, Rui Barradas Em 11-09-2012 15:17, cesare orsini escreveu: Dear people, I need to generate 100 different matrices, without particular characteristics but using only one command

Re: [R] Maintaining specific order when using aggregate or change order on axis

2012-09-11 Thread Rui Barradas
, 'fmax', 'below') dat <- data.frame(Depth = sample(depth, n, TRUE), Value = runif(n)) # This is sorted by increasing Depth agg <- aggregate(Value ~ Depth, data = dat, FUN = mean) ix <- order(depth) # First step agg[order(ix), ] # inverse permutation Hope this helps, Ru

Re: [R] lapply with different size lists?

2012-09-11 Thread Rui Barradas
if (lIf you want 4 column data.frames, uncomment the instruction above (and comment out the previuos one). Hope this helps, Rui Barradas Em 11-09-2012 19:44, Rui Esteves escreveu: Hello, I have 2 functions (a and b) a = function(n) { matrix (runif(n*2,0.0,1), n) } b = function (m, matri

Re: [R] how to qplot two x-axis x1:Farenheit x2:Celsius

2012-09-12 Thread Rui Barradas
;degF",3,line=2) To the op: according to Hadley Wickham, "It's not possible in ggplot2 because plots with multiple y scales are fundamentally flawed." See http://stackoverflow.com/questions/3099219/how-to-use-ggplot2-make-plot-with-2-y-axes-one-y-axis-on-the-left-and-another H

Re: [R] How to resolve the following error: (list) object cannot be coerced to type 'double'

2012-09-12 Thread Rui Barradas
NA ct$p.value [1] 0.1101842 To the op: you should say which library you are using. Even if Hmisc is a very popular one. Hope this helps, Rui Barradas Em 12-09-2012 16:10, R. Michael Weylandt escreveu: On Wed, Sep 12, 2012 at 4:04 PM, Jason Love wrote: Hello, I'd like to t

Re: [R] digit precision in p value of rcorr

2012-09-12 Thread Rui Barradas
cs = c(4.9268, 2.892, 2.6428, 1.1124, 2.7237 )), .Names = c("D.Prime", "T.statistics"), class = "data.frame", row.names = c("1", "2", "3", "4", "5")) library(Hmisc) rc <- rcorr(as.matrix(Var), type="pearson") p

Re: [R] how to create a substraction matrix (subtract a row of every column from the same row in other columns)

2012-09-13 Thread Rui Barradas
value = d2[lower.tri(d2, diag = TRUE)]) res Hope this helps, Rui Barradas Em 12-09-2012 21:45, csmeredith escreveu: Hello I have data like this x1 x2 x3 x4 x5 I want to create a matrix similar to a correlation matrix, but with the difference between the two values, like this x1

Re: [R] [newbie] aggregating table() results and simplifying code with loop

2012-09-13 Thread Rui Barradas
character(unique(unlist(T80[ycols]))) result <- lapply( 4:2, function(.n) do.call(rbind, lapply(covers, makeCovers, .n)) ) names(result) <- paste("nYears", 4:2, sep = ".") str(result) # See the results for 4 years result[[ "nYears.4" ]] # or any o

Re: [R] calculate within-day correlations

2012-09-13 Thread Rui Barradas
Hello, Try the following. Q_use_2 <- split(Q_use, as.Date(Q_use$date)) SC_use_2 <- split(SC_use, as.Date(SC_use$date)) lapply(seq_along(Q_use_2), function(i) cor(Q_use_2[[i]]$Q, SC_use_2[[i]]$SC)) Hope this helps, Rui Barradas Em 14-09-2012 01:35, emorway escreveu: useRs, Here is

Re: [R] problem creating an array

2012-09-13 Thread Rui Barradas
1:2] Hope this helps, Rui Barradas Em 13-09-2012 23:04, Curtis Burkhalter escreveu: Hello, I am having trouble creating a (1000,3,201) array in R from a data set created within the same script. My problem is that I want to take a matrix that is 1000x603 (called "landmat") and separ

Re: [R] compare different data-formats

2012-09-14 Thread Rui Barradas
t the format returned by as.Date uses '-' as separator: as.Date(x, format = "%d.%b.%Y-%H:%M") [1] "2012-08-14" "2012-09-03" Hope this helps, Rui Barradas Em 14-09-2012 10:44, Martin Batholdy escreveu: Hi, I have two data-frames which I want to match by a date

Re: [R] swap hist() colours

2012-09-14 Thread Rui Barradas
Hello, Use ?colorRampPalette nr <- nrow(yes.matrix_11) clrs <- colorRampPalette(c("white", "black"))(nr) barplot(yes.matrix_11, beside =TRUE, ylim=c(0,250), col = clrs) [...etc...] Hope this helps, Rui Barradas Em 14-09-2012 12:33, Robert Pazur escreveu: Hi, i c

Re: [R] ctrl+r does not work sometimes

2012-09-14 Thread Rui Barradas
-6 [5] mvtnorm_0.9-9992 loaded via a namespace (and not attached): [1] fortunes_1.5-0 grid_2.15.1tools_2.15.1 Rui Barradas Em 14-09-2012 19:02, Duncan Murdoch escreveu: On 14/09/2012 10:44 AM, Jie wrote: Dear All, This might be a tiny question but I do not know the reason. On my desktop

Re: [R] USCensus2000 package

2012-09-14 Thread Rui Barradas
Hello, Check the packages UScensus2000blkgrp and UScensus2000tract http://stat.ethz.ch/CRAN/web/packages/UScensus2000blkgrp/index.html http://stat.ethz.ch/CRAN/web/packages/UScensus2000tract/index.html Hope this helps, Rui Barradas Em 14-09-2012 15:22, Michael Leitson escreveu: Does anyone

Re: [R] how to view only readings of a selected data from a column while the other columns remain

2012-09-15 Thread Rui Barradas
Homework. There's a no homework policy, but see ?aggregate. Rui Barradas Em 15-09-2012 10:22, kangam3 escreveu: Hi Friends I am new here and have a problem Year Market Winner BID 1 1990ABC Apple 0.1260 2 1990

Re: [R] Count based on 2 conditions [Beginner Question]

2012-09-16 Thread Rui Barradas
Hello, Since logical values F/T are coded as integers 0/1, you can use this: set.seed(5712) # make it reproducible n <- 1e3 x <- data.frame(A = sample(0:1, n, TRUE), B = sample(0:10, n, TRUE)) count <- sum(x$A == 1 & x$B > 5) # 207 Hope this helps, Rui Barradas Em

Re: [R] qplot: plotting precipitation data

2012-09-16 Thread Rui Barradas
(start), y = peak)) p2 + geom_rect(aes(xmin = as.factor(start), xmax = as.factor(end), ymin = 0, ymax = peak)) The level 5291926 is place last. Shouldn't it be expected to plot as first? Rui Barradas Em 16-09-2012 00:20, John Kane escreveu: Thanks for the data. It makes things much easi

Re: [R] create new variable with ifelse? (reproducible example)

2012-09-16 Thread Rui Barradas
Hello, Here's another one. logic.result <- with(rep_data, know %in% c("very well", "fairly well") & getalong %in% c(4,5)) rep_data$clo <- 1*logic.result # coerce to numeric Rui Barradas Em 16-09-2012 13:29, Stephen Politzer-Ahles escreveu: Hi Niklas, I

Re: [R] two questions about character manipulation

2012-09-16 Thread Rui Barradas
Hello, Try the following. 1) pattern <- "response." m <- regexpr(pattern, ex) #gregexpr to get all "response" regmatches(ex, m) 2) gsub("\\$", "\\.", ex) Hope this helps, Rui Barradas Em 16-09-2012 15:35, Özgür Asar escreveu: Dear all, I wan

Re: [R] qplot: plotting precipitation data

2012-09-16 Thread Rui Barradas
Maybe a bug in ggplot2::geom_rect? I'm Cceing this to Hadley Wickham, maybe he has an answer. Rui Barradas Em 16-09-2012 17:04, John Kane escreveu: -Original Message- From: ruipbarra...@sapo.pt Sent: Sun, 16 Sep 2012 13:13:47 +0100 To: jrkrid...@inbox.com Subject: Re: [R]

Re: [R] multi-column factor

2012-09-16 Thread Rui Barradas
) t3 <- system.time(z3 <- f3(z)) identical(z1, z2) #[1] TRUE identical(z1, z3) #[1] TRUE rbind(t1, t2, t3) user.self sys.self elapsed user.child sys.child t1 2.55 0.473.01 NANA t2 1.57 0.291.87 NANA t3 1.51 0.261.78

Re: [R] two questions about character manipulation

2012-09-16 Thread Rui Barradas
Hello, This should do it. You can collapse the first two instructions, but I've left it like this for clarity. s <- unlist(strsplit(ex, "[,)[:blank:]]")) s <- gsub("^.*\\$", "", s) s[nchar(s) > 0] Rui Barradas Em 16-09-2012 17:26, Özgür Asar escre

Re: [R] [newbie] aggregating table() results and simplifying code with loop

2012-09-17 Thread Rui Barradas
NULL res } f5 <- function(w){ sp <- split(w, w$V8) res <- do.call( rbind, lapply(sp, f4) ) res <- data.frame(res) res } T80 <- read.table("sample.txt", header = TRUE, sep = ";") ycols <- grep("y", names(T80)) ws <

Re: [R] Problem with Stationary Bootstrap

2012-09-17 Thread Rui Barradas
if(10, 0, 10) Y <- 2 + 3*X a <- data.frame(X = X, Y = Y) fun <- function(a){ fit <- lm(Y ~ X, data=a) return(coef(fit)) } result <- boot::tsboot(a, statistic = fun, R = 10, sim = "geom", l = 10, orig.t = TRUE) Hope this helps, Rui Barradas Em 17-09-2012 14:42, Hock Ann L

Re: [R] Boxplot lattice vs standard graphics

2012-09-17 Thread Rui Barradas
ev.new() bwplot(conc~site, data=test, scales = list(y=list(log=10)), panel = function(...){ panel.bwplot(..., stats = mystats) } ) With a median _line_ it would be perfect. (Not a follow-up, it was already answered some time ago, use pch = "|" in panel.bwplot.

Re: [R] Creating missingness in repeated measurement data

2012-09-17 Thread Rui Barradas
s(dat3) <- seq_len(nrow(dat3)) all.equal(dat2, dat3) # only names are different Hope this helps, Rui Barradas Em 17-09-2012 19:32, john james escreveu: > Dear R users, > > I have the following problems. My dataset (dat) is as follows: > > a <- c(1,2,3) > id <- rep(

Re: [R] help

2012-09-17 Thread Rui Barradas
Google est ton ami: http://lmgtfy.com/?q=R+statistiques+fran%C3%A7ais Le deuxième parait prometteur. Bonne chance, Rui Barradas Em 17-09-2012 20:06, Seydou Badiane escreveu: HELLO, I SHALL NEED A HELP. It is my official language(tongue) is French, even if I manage little in English, I shall

Re: [R] help with calculation from dataframe with multiple entries per sample

2012-09-17 Thread Rui Barradas
Hello, Try the following. sp <- split(mydata, mydata$Sample) do.call(rbind, lapply(sp, function(x){x$Gain <- x$Mass[3] - x$Mass[2]; x})) Hope this helps, Rui Barradas Em 18-09-2012 00:15, Julie Lee-Yaw escreveu: > Hi > > I have a dataframe similar to: > >> Sample<-c

Re: [R] help with calculation from dataframe with multiple entries per sample

2012-09-17 Thread Rui Barradas
Or diff(x[2:3]) Rui Barradas Em 18-09-2012 01:05, David Winsemius escreveu: On Sep 17, 2012, at 5:00 PM, David Winsemius wrote: On Sep 17, 2012, at 4:15 PM, Julie Lee-Yaw wrote: Hi I have a dataframe similar to: Sample<-c(1,1,1,2,2,2,3,3,3) Time<-c(1,2,3,1,2,3,1,2,3) M

Re: [R] Formula in a data-frame

2012-09-18 Thread Rui Barradas
Volume.y) Importance <- Fi*Vi/sum(Fi*Vi) 3) Maybe you can combine both ways and find a use for the data.frame 'm1'. And have m1$Importance <- ...etc... Hope this helps, Rui Barradas Em 18-09-2012 05:48, Raoni Rodrigues escreveu: Hello all, I'm new in R, and I

Re: [R] Appending many different and separate Excel files using R

2012-09-18 Thread Rui Barradas
you do in your post. With the side effect that any other software package would be able to access, and get rid of Excel dependency. But if for some reason you need Excell, then the error message is clear, only file extensions xls and xlsx are allowed. Rui Barradas Em 18-09-2012 13:54, Amir Kasa

Re: [R] [newbie] aggregating table() results and simplifying code with loop

2012-09-18 Thread Rui Barradas
st elements precisely to have simplified access to each combination of Crop and Period. (Condition 19, the last one, comes first because split sorts its output by list element name, and 'crop' is the first.) Rui Barradas John Kane Kingston ON Canada -Original Message- F

Re: [R] Conditional operations in R

2012-09-18 Thread Rui Barradas
(dat, as.numeric(sub("%", "", pct_total))/100) str(dat) # see its STRucture top <- which(dat$pct_total >= median(dat$pct_total)) # make index vector sum(dat$pct_total[top]) Hope this helps, Rui Barradas Em 18-09-2012 15:41, ramoss escreveu: Hello, I am a newbie to R

Re: [R] Data frame divison by another data frame with common groups and different length

2012-09-18 Thread Rui Barradas
Hello, Try the following. agg <- aggregate(buddleiat ~ samplet + datet, data = traffic, FUN = mean) mrg <- merge(encounters, agg, by.x = c("samplec", "datec"), by.y = c("samplet", "datet")) mrg$Div <- with(mrg, Bladen/buddleiat)

Re: [R] Estimating the ECDF

2012-09-18 Thread Rui Barradas
Hello, I'm not sure I understand the question, but is it something like this? set.seed(3648) x <- rnorm(100) plot(ecdf(x), cex = 0.5) # Now create a function; don't use # uppercase F, it's a symbol for FALSE. f <- ecdf(x) f(0) # Should be near 0.5 Hope this helps, Rui B

Re: [R] [newbie] aggregating table() results and simplifying code with loop

2012-09-18 Thread Rui Barradas
re unlikely to occur. That's what P. Burns is talking about when he says that "Surprise in movies and novels is good. Surprise in computer code is bad." To understand a function look at the way it is called, and to what happens in it. Forget almost all of the rest, the exception b

Re: [R] Importing a CSV file

2012-09-19 Thread Rui Barradas
Hello, Try ?read.csv. dat <- read.csv("C:\\Users\\Anthi\\Desktop\\R\\A.csv") Note that unlike what happens with load() you'll need an explicit assignment. Hope this helps, Rui Barradas Em 19-09-2012 09:54, Anthi Oikonomou escreveu: > Hi, > I am trying to import c

Re: [R] Importing a CSV file

2012-09-19 Thread Rui Barradas
such thing as c:\\\\ ---> c:\\). Rui Barradas Sarah -Oorspronkelijk bericht- Van: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] Namens Sarah Goslee Verzonden: woensdag 19 september 2012 15:44 Aan: Anthi Oikonomou CC: r-h...@stat.math.ethz.ch Onderwerp: Re: [R]

Re: [R] Help reproducing a contour plot

2012-09-19 Thread Rui Barradas
%3Cbr%3EMaunga_Whau_Volcano,21 Hope this helps, Rui Barradas Em 19-09-2012 16:55, Tinus Sonnekus escreveu: Hi All, I am trying to reproduce this using R instead. [image: Full-size image (38 K)] I tried using the following code *SChla <- read.csv("SM_Chla_data.csv")* *Atlantis <- SChla[16

Re: [R] histogram plot spacing problem

2012-09-19 Thread Rui Barradas
Hello, Try the following. x <- rnorm(100) hist(x, xaxt = "n") axis(1, at = pretty(x), pos = 0) Hope this helps, Rui Barradas Em 19-09-2012 18:51, firespot escreveu: Hi, So I plot a histogram using the built-in hist function: hist(rnorm(100), ...). Now the y-axis starts at

Re: [R] issue accessing help files

2012-09-19 Thread Rui Barradas
manually create it whenever this happened. And to issue a print statement after a missed ?function one. Apparently the error message was waiting to be displayed somewhere. The problem was corrected with R 2.15.0 so I recommened you update your installation of R. Hope this helps, Rui Barrada

Re: [R] Data Frame (Very Simple Problem)

2012-09-19 Thread Rui Barradas
'b'. This time it's a vector, not a data.frame. The ifelse corrected is # 'b' is now 1-dim ifelse(b[1] < Sys.time()+5*60, rnorm(1,0,5), Sys.sleep) (Why the '*' and the double quotes?) Then I've realized that you had restarted the counting, but startin

Re: [R] Merging two or more frequency tables

2012-09-19 Thread Rui Barradas
e epoch of incredulity it was the season of Light it was the season of Darkness" fun(x, y) z <- "It was the era of R" fun(x, y, z) Hope this helps, Rui Barradas Em 19-09-2012 20:08, mcelis escreveu: I am new to R and am looking to merge two or more frequency tables into one. I

Re: [R] correlating matrices

2012-09-19 Thread Rui Barradas
s! ?predict.lm Without 'newdata' it gives you the fitted values. With new data it gives you predictions. Beware, 'newdata' must be a data.frame. Hope this helps, Rui Barradas Because I dont have two but six matrices as independent variables, so it becomes pretty lengthy. I

Re: [R] (no subject)

2012-09-20 Thread Rui Barradas
Maybe it is longer, but it's also more general, it issues an error if the tables are not 1-dim. That's where most of the function's extra lines are. Otherwise it's the same as your first solution. The second one has the problem you've mentioned. Rui Barradas Em 20

Re: [R] Line over Boxplot

2012-09-20 Thread Rui Barradas
by=5), lty=2) abline(v=seq(1, 30, by=1), lty=2) boxplot (TMAX ~ HOUR, data=soton.df, xlab="Forecast Hour", ylab="MAX TEMP", main="GEFS $$MM$DD ${HH}Z FORECAST MAX TEMPS", whiskcol="red", col="red", outline=TRUE, ylim=c(0, 1

Re: [R] question on assigning an argument in a function that is create by the function itself

2012-09-20 Thread Rui Barradas
t(datas, level) sm <- sapply(sp, function(x) cumsum( x[[column]] )) as.vector(sm) } cut.paste.2(dummy, level3) cut_paste(dummy, "datas2", level3) cut.paste.1(dummy, level3) cut_paste(dummy, "datas1", level3) Hope this helps, Rui Barradas Thanks very much! Ben

Re: [R] effective way to return only the first argument of "which()"

2012-09-21 Thread Rui Barradas
else *which = NA_INTEGER; UNPROTECT(1); return(Which); } SEXP firstGreaterDbl(SEXP X, SEXP A){ R_len_t *which, i = 0; double *x = REAL(X), *a = REAL(A); SEXP Which; PROTECT(Which = allocVector(INTSXP, 1)); which = INTEGER(Which); while(x[i] <= a[0]

Re: [R] correlating matrices

2012-09-21 Thread Rui Barradas
. (And why cbind, by the way?) 2. Use something folloing these lines. (Untested, obviously, without a data example.) pred <- predict(...etc...) no_na <- complete.cases( cbind(matrix1, matrix2) ) matrix1[ no_na, ] <- pred[1, ] matrix2[ no_na, ] <- pred[2, ] Hope this helps, Rui Barrad

Re: [R] reading mzxml files

2012-09-21 Thread Rui Barradas
Hello, For questions like this, install.packages('sos') # if not yet installed library(sos) # load into R session findFn('mzxml ') The frist two look promising. Hope this helps, Rui Barradas Em 21-09-2012 20:02, Greg Barding escreveu: Hi Everyone, So I've b

Re: [R] efficient overlapping average curve on original curves

2012-09-21 Thread Rui Barradas
lines in ggplot2 using transparency in order to give a visual picture of where there are more lines. Hope this helps, Rui Barradas Em 22-09-2012 00:11, eliza botto escreveu: Dear useRs, my question could be very basic for which i apologize in advance. Each column of a matrix with dimensions 365

Re: [R] efficient overlapping average curve on original curves

2012-09-21 Thread Rui Barradas
om_line(data = dm, colour = alpha("blue", 1/5)) + geom_line(data = dm, aes(y = avg), colour = "darkblue") Rui Barradas Em 22-09-2012 02:02, arun escreveu: HI, Similar graph in xyplot: set.seed(1) mat <- matrix(rnorm(100*37), ncol = 37) mat <- apply(mat, 2, cumsum) mat1&

Re: [R] Confused by code?

2012-09-24 Thread Rui Barradas
here are three 1s in 'z'). The same goes for 'y'. Correct: # Create an index matrix z.inx <- which(z == 1, arr.ind = TRUE) z.inx # Test x1 <- x2 <- x3 <- x # Use copies to test x1[z == 1] <- y[z == 1] x2[z.inx] <- y[z.inx] # 1 and 0 to T/F x3[as.logical(z)] <

Re: [R] serial subtraction within a vector

2012-09-24 Thread Rui Barradas
Hello, Try diff(v) Hope this helps, Rui Barradas Em 24-09-2012 12:00, Hermann Norpois escreveu: Hello, I have a vector (numeric) v-> c(a,b,c,d,e) and I want to create the vector n->c(b-a,c-b,d-c,e-d). How can I do that? Thank you Hermann [[alternative HTML version d

Re: [R] Rows not common in dataframes

2012-09-24 Thread Rui Barradas
Hello, See also ?setdiff Hope this helps, Rui Barradas Em 24-09-2012 08:30, Milan Bouchet-Valat escreveu: Le lundi 24 septembre 2012 à 13:22 +1000, Chintanu a écrit : Hi, I have two dataframes (Dataframe_A, Dataframe_B) with the same no. of columns. The first column of both the dataframes

Re: [R] List creation based on matrix

2012-09-24 Thread Rui Barradas
t;b", "c", "d", "e"), class = "factor"), X = 1:5), .Names = c("A", "X"), row.names = c(NA, -5L), class = "data.frame") Rui Barradas Em 24-09-2012 12:20, benrgillespie escreveu: Hi guys, It would be great if you could help me

Re: [R] Confused by code?

2012-09-24 Thread Rui Barradas
used as to why the logical condition is returning numbers, are you sure of that?) Anyway, the right way would be to index 'mPV' using a logical or an index matrix. Hope this helps, Rui Barradas If so I am still confused as this is not what I thought was supposed to by happen

Re: [R] Confused by code?

2012-09-24 Thread Rui Barradas
I've just reread my answer and it's not very clear. Not at all. Inline. Em 24-09-2012 18:34, Rui Barradas escreveu: Hello, Inline. Em 24-09-2012 15:31, Bazman76 escreveu: Thanks Rui Barrudas and Peter Alspach, I understand better now: x<-matrix(c(1,0,0,0,2,0,0,0,2),nrow=3)

Re: [R] passing a matrix from R to C code

2012-09-24 Thread Rui Barradas
Hello, Also, R uses doubles, not floats. Hope this helps, Rui Barradas Em 24-09-2012 23:27, Peter Langfelder escreveu: Erin, you seem to confuse R and C syntax a bit, among other things. See below. On Mon, Sep 24, 2012 at 3:03 PM, Erin Hodgess wrote: Dear R People: I'm working

Re: [R] Script to count unique values from two linked matricies

2012-09-25 Thread Rui Barradas
Hello, Try the following. countTrait <- function(x) length( unique(x[x != 0]) ) presence <- 1*(!is.na(dat1[-1])) result <- apply(presence, 2, function(x) apply(dat2[, -1]*x, 2, countTrait)) result <- t(result) rowSums(result) #Site1 Site2 Site3 # 5 7 3 Hope this

Re: [R] how to pass a function to a function inside a function

2012-09-25 Thread Rui Barradas
same mistake, you simply return the function without ever calling it. Hope this helps, Rui Barradas Em 25-09-2012 13:28, Al Ehan escreveu: Hi, I'm trying to compile two functions into one function. the first funtion is called 'fs' which is self-made function, another f

<    12   13   14   15   16   17   18   19   20   21   >