similar to: question on function argument

Displaying 20 results from an estimated 10000 matches similar to: "question on function argument"

2008 Jun 16
4
Superimposing Line over Histogram in Density Plot
Hi, Currently I have a density plot generated with this snippet. Is there a way I can add a line curve on top of it? I mean in one figure __BEGIN__ myhist <- hist(x col="blue", main = "Density Plot", xlab = "Exp Level", ) __END__ - Gundala Viswanath Jakarta - Indonesia
2004 Feb 23
2
deleting elements from an array/object
Hello, I created a simple histogram with: myHist<-hist(myData) the object myHist now has two arrays (among the others): myHist$mids myHist$counts Since myHist$counts contains some "0", and I want to calculate the linear fit among myHist$mids and log(myHist$counts), I want remove the elements of both arrays where these "0" occurs. which are the possible solutions to
2010 Nov 10
1
par mfrow in "function" problem
Hi all, I defined the following ############################# myhist=function(x){ hist(x,xlab="",main="") h=hist(x) xfit=seq(min(x),max(x),length=100) yfit=dnorm(xfit,mean(x),sd=sd(x)) yfit=yfit*diff(h$mids[1:2])*length(x) lines(xfit, yfit, col="blue", lwd=2) } ############################# individually, it worked fine however, if I used par(mfrow=c(2,2))
2004 Feb 28
1
Basic general statistical problem.
Hello everyone, I'd like to have suggestions about a common basic statistical approach, hope to be useful also for other R beginners. When you first get some data (i.e length of river) you may want to look at its distribution. Then you probably want to find which law follows this distribution, and to test the goodness of the fit. For doing this simple analysis I am writing some code
2012 Aug 11
1
using eval to handle column names in function calling scatterplot graph function
I am running R version 2.15.1 in Windows XP I am having problems with a function I'm trying to create to: 1. subset a data.frame based on function arguments (colname & parmname) 2. rename the PARMVALUE column in the data.frame based on function argument (xvar) 3. generate charts plotvar <- function(parentdf,colname, parmname,xvar,yvar ){ subdf <-
2006 Apr 27
3
relative frequency plot
Hi All, I want to use "hist" to get the relative frequency plot. But the range of ylab is greater than 1,which I think it should be less than 1 since it stands for the probability. Here is my code: x<-c(1,1,1,0,0,1,1,5,1,1,0,1,1,0,1,0,1,1,0,0,1,1,1,1,1,1,1,1,1,4,1,0,2,1,1,1 ,1,1,0,0,1,0,1,1,1,1,1,1,1,1,1)
2005 Jul 05
1
by (tapply) and for loop differences
I am getting a difference in results when running some analysis using by and tapply compare to using a for loop. I've tried searching the web but had no luck with the keywords I used. I've attached a simple example below to illustrates my problem. I get a difference in the mean of yvar, diff and the p-value using tapply & by compared to a for loop. I cannot see what I am doing wrong.
2009 Jul 01
2
?max (so far...)
Hi, I have a data.frame that is date ordered by row number - earliest date first and most current last. I want to create a couple of new columns that show the max and min values from other columns *so far* - not for the whole data.frame. It seems this sort of question is really coming from my lack of understanding about how R intends me to limit myself to portions of a data.frame. I get the
2009 Jun 30
2
Using functions to change values in a data.frame
I'm having trouble with something that looks easy. (And I'm sure it will be easier within about 1 minute of receiving my first response.) Thanks in advance. I have a collection of data frames that I need to add columns, do some calculations and then fill in the new columns. Since I have a large number of similar data frames I want to do this with functions to make the code more readable
2008 Apr 14
2
Histogram Label Font Size
Hi! I'm having a trouble changing font size of histogram label. I have tried help(hist), but I couldn't find anything explain how to fix label's font size. Could you help me please? Thank you. _________________________________________________________________ Going green? See the top 12 foods to eat organic. 1N1653A [[alternative HTML version deleted]]
2007 Nov 15
1
Writing a helper function that takes in the dataframe and variable names and then does a subset and plot
Hi, I have a large dataframe than I'm writing functions to explore, and to reduce cut and paste I'm trying to write a function that does a subset and then a plot. Firstly, I can write a wrapper around a plot: plotwithfits <- function(formula, data, xylabels=c('','')) { xyplot(formula, data, panel = function(x,y, ...) { panel.xyplot(x,y,
2009 Jul 01
1
running count in data.frame
Hi, I need to keep a running count of events that have happened in my data.frame. I found a document called usingR that had an example of doing this for random coin flips and I tried to modify it. It seems to sort of work in the beginning, but then it stops and I don't understand why. I'm trying to duplicate essentially the Excel capability of =SUM($A$1:$A(Row number)) The example
2007 Jun 14
4
question about formula for lm
Dear all; Is there any way to make this to work?: .x<-rnorm(50,10,3) .y<-.x+rnorm(50,0,1) X<-data.frame(.x,.y) colnames(X)<-c("Xvar","Yvar") Ytext<-"Yvar" lm(Ytext~Xvar,data=X) # doesn't run lm(Yvar~Xvar,data=X) # does run The main idea is to use Ytext as input in a function, so you just type "Yvar" and the model should fit....
2011 Feb 25
1
speed up process
Dear users, I have a double for loop that does exactly what I want, but is quite slow. It is not so much with this simplified example, but IRL it is slow. Can anyone help me improve it? The data and code for foo_reg() are available at the end of the email; I preferred going directly into the problematic part. Here is the code (I tried to simplify it but I cannot do it too much or else it
2011 Apr 18
1
covariance matrix: a erro and simple mixed model question, but id not know answer sorry
Dear list I need your help: Execuse me for my limited R knowledge. #example data set set.seed (134) lm=c(1:4) block = c(rep(lm,6)) gen <- c(rep(1, 4), rep(2, 4), rep(3, 4), rep(4, 4),rep(5, 4),rep(6, 4)) X1 = c( rnorm (4, 10, 4), rnorm (4, 12, 6), rnorm (4, 10, 7),rnorm (4, 5, 2), rnorm (4, 8, 4), rnorm (4,7, 2)) X2 = X1 + rnorm(length(X1), 0,3) yvar <- c(X1, X2) X <- c(rep( 1,
2008 Nov 15
1
Lattice: groups and no groups with panel.superpose
Dear R listers, I am trying to create a lattice plot with independent regression lines per group for each panel, plus one overall regression line per panel. I succeed in having the separate regression lines for each group per panel, but I can't figure out how to add the overall regression line over all groups. I have learnt a lot from the list, but I can't find an example for what I want
2010 Aug 09
1
Different colour in each bar in lattice package
Hi, I try to plot bars with different colours in a barchart graphic. My idea is make that all X-Levels from trat var with different colour (grey scale). I search for a solution but dont find any. Any help? Thanks dados <- structure(list(Medias = c(0.994169096209855, 0.99416342412449, 0.974683544303797, 0.954430379746835, 0.669047619047619, 0.999999998475569, 0.994163424124514,
2013 Sep 26
1
Less than equal to symbol in ggplot2 legend text
Hello, I am trying to add a less than equal to symbol in a ggplot2 legend text. See sample code below. I have tried using the expression function and \u2264. I also tried adding labels to legend.text under theme. Neither of these 3 options work. Please help, Mahesh ++++++++++++++ Extra.column=ifelse(data[,covariate]>cutpoint,1,0) Grp1 <- "\u2264 1.5" Grp2 <-
2011 Apr 01
3
programming: telling a function where to look for the entered variables
Hi there, Could someone help me with the following programming problem..? I have written a function that works for my intended purpose, but it is quite closely tied to a particular dataframe and the names of the variables in this dataframe. However, I'd like to use the same function for different dataframes and variables. My problem is that I'm not quite sure how to tell my function in
2012 Sep 26
2
average environmental data if AnimalID and Time is duplicated
Hello, I tried for about three hours now to solve this problem but I can't figure it out. I am sure someone knows how do it. At least I hope so. I have a data frame somewhat like this: myframe <- data.frame (ID=c("Ernie", "Ernie", "Bert", "Bert"), Timestamp=c("24.09.2012 09:00", "24.09.2012 09:00", "24.09.2012 10:00",