Displaying 20 results from an estimated 5000 matches similar to: "Arguments of a function"
2010 Jan 08
4
Arguments of a function
Dear all,
I have a question about how to set arguments in my own function. For
example, I have a function that looks like this:
my.f <- function(a = x1, b = x2)
{
x1 = equation 1
x2 = equation 2
x3 = equation 3
y = a + b
}
x1, x2, and x3 are temporary variables (intermediate results) calculated
from other variables within the funciton. I want to use two of these three
2011 Apr 26
6
Tell the difference between characters
Dear all,
I just want to determine if the characters in a character string are the
same or not. For example,
temp <- c("aa", "aA", "ab")
How do I determine the first one have the two same ?a?, and the second and
third have the different characters? Thanks in advance.
Lisa
--
View this message in context:
2010 Jan 25
5
Data transformation
Dear all,
I have a dataset that looks like this:
x <- read.table(textConnection("col1 col2
3 1
2 2
4 7
8 6
5 10"), header=TRUE)
I want to rewrite it as below:
var1 var2 var3 var4 var5 var6 var7 var8 var9 var10
1 0 1 0 0 0 0 0 0 0
0 2 0 0 0 0 0 0 0 0
0 0 0 1 0 0
2011 Apr 27
4
Pause the execution of a function
Dear all,
I am trying to write a script to pause the execution of a function and
provide some additional commands to the function and then continue execution
of the function. For example, when my function detects a wrong number in a
dataset, the function pauses automatically and returns information on the
screen:
?There is a wrong number in the dataset. Would you like to correct it? ?
If I
2009 Dec 03
3
dataset index
Hello, All,
I have a dataset that looks like this:
x <- matrix(c(
0, 0, 0,
0, 0, 0,
0, 1, 0,
0, 1, 0,
0, 1, 0,
1, 2, 1,
1, 2, 1,
1, 3, 1,
1, 3, 1,
1, 3, 1),
ncol = 5, byrow = T,
dimnames = list(1:10, c("gender", "race", "disease")))
I want to write a function to produce several matrices including only ?TRUE?
and ?FALSE? for the different levels of the
2010 Jan 25
2
Delete components of a list
Dear all,
I have a question about deleting components of a list. For example, I have a
list that looks like this:
[[1]]
var1 var2 var3
1 3 4
2 2 1
[[2]]
var1 var2 var3
2 5 1
2 1 7
[[3]]
var1 var2 var3
1 6 7
3 8 4
How to delete, say, the first columns of the list or the second rows? Thank
in advance.
Lisa
--
View
2011 Jun 01
5
Recode numbers
Dear all,
I have two sets of numbers that look like
a <- c(1, 2, 3, 3, 4, 4, 5, 6, 1, 2, 2, 3, 1, 2, 1, 2, 3, 3, 4, 5, 1, 2, 3,
4)
b <- c(1, 5, 8, 9, 14, 20, 3, 10, 12, 6, 16, 7, 11, 13, 17, 18, 2, 4, 15,
19)
I just want to use ?b? to encode ?a? so that ?a? looks like
a1<- c(1, 5, 8, 8, 9, 9, 14, 20, 3, 10, 10, 12, 6, 16, 7, 11, 13, 13, 17,
18, 2, 4, 15, 19)
Does anyone have a
2011 May 26
3
Suppress intermediate results on console
Dear all,
I have a question about how to suppress intermediate results in a function
on console. For example, I will use summary() in my own function that looks
like:
myfunction <- function(?)
{
?
Summary(x)
?
}
Then myfunction() will print ?x? on console that is intermediate result and
doesn?t need showing.
Does someone have any idea or any suggestion? Thank you in advance.
Lisa
2009 Dec 04
1
User's function
Hello, All,
I want to write a function to do some works based on the arguments. For
example, bind some variables (arguments) as this:
myfunction <- function(arg1, arg2, arg3, ?)
{
x <- cbind(arg1, arg2, arg3, ?)
}
myfunction(arg1, arg2, arg3, ?)
The function can automatically determine the number of arguments and bind
them, which means if I assign 2 arguments, the function can bind
2009 Dec 15
2
Reconstruct a dataset
Dear all,
I have a dataset that looks like this:
inividual var1 var2 ?
1 1 1 ?
2 1 2 ?
3 2 1 ?
4 2 2 ?
? ? ? ?
I will random sample 2 individuals from this dataset based on a set of
random numbers, e.g.,
rn1 <- c(0, 0, 1, 1), rn2 <- c(0, 0, 2, 0), rn3 <- c(1, 0, 0, 1), rn4 <-
2009 Nov 24
5
Split column
Hello, R users,
I have a dataset that looks like this:
id var1 var2
1 1 3
2 3 1
3 2 1
4 1 2
5 2 3
I want to split one column to two columns with 1 = 1 and 1, 2 = 1 and 2, 3 =
2 and 2:
id var1.1 var1.2 var2.1 var2.2
1 1 1 2 2
2 2 2 1 1
3 1 2
2011 Mar 21
1
Randomly generating data
Hi, everybody,
I have a problem and need your help.
There are two columns that look like this:
[1,] "t" "f"
[2,] "f" "t"
[3,] "t" "f"
[4,] "t" "t"
[5,] "f" "f"
I just want to generate the third column based on these two columns. First,
I randomly choose one of the two columns,
2006 Aug 03
3
(no subject)
Hey everyone, I'm trying version 1.0rc2, via the rpm at ATrpms. I'm running on CentOS
4.3 on an Opteron system. I have this running stably on a 32 bit system, but I'm
crashing constantly on a 64 bit system.
Here's what I'm getting in my mail logs when I try to log in via IMAP:
Aug 3 15:01:21 lisa dovecot: imap-login: Login: user=<scottz>, method=PLAIN,
2010 Aug 19
2
csv vs. data frame
Hi,
I am neither a statistician nor a user of R. I am a programmer trying to
provide my users (both statisticians and R users) data in a format that
works best for them.
What is a data frame? Is source data easier to work with in this format or
a csv file? Or yet another format?
Thanks for your time.
Bruce
[[alternative HTML version deleted]]
2010 Dec 26
1
A question on Statistics
I am not a pure Statistics background and therefore please forgive me if
this question (which is not R related either) is too trivial.
In many Statistics literature I find following statement: "restrictions in
different coefficients matrices have to be imposed to ensure uniqueness of
the parametrization". Can somebody tell me what is the meaning of Uniqueness
in the parametrization?
2011 Jan 22
2
effect size measure for dependent samples
Any advice on which package I can use for calculating effect sizes for two
dependent samples? compute.es seems only to consider independent samples.
Thanks in advance
Steve Powell
[[alternative HTML version deleted]]
2011 Mar 21
1
value changed after paste() function
Hi all,
I am new user in R, I am trying to to use paste function to concatenate
strings which has been fetched from database table(postgres database), the
following are my code:
when i do:
> sqlFetch(channel,'transactions')
outputs are following(only parts, there are around 200 transactions in
total)
orderid productname price quantity discount
1 T10248 potato 1.80
2011 May 01
8
LISA finite element in wine
I want to use LISA finite element program (http://www.lisa-fet.com/) under my Ubuntu machine.
I did install Wine and it runs ok, then I install LISA and it installed without any error.
However whrn I run LISA, it did not appear on the screen without any error?
Anyone can assist how to me LISA running?
2006 Aug 03
2
(no subject)
On Thu, August 3, 2006 15:28, David Jonas wrote:
> On Thu, 2006-08-03 at 15:07 -0400, Scott Zahn wrote:
>> Hey everyone, I'm trying version 1.0rc2, via the rpm at ATrpms. I'm running on CentOS
>> 4.3 on an Opteron system. I have this running stably on a 32 bit system, but I'm
>> crashing constantly on a 64 bit system.
>>
>> Here's what I'm
2011 Feb 09
2
comparing proportions
Hi, I have a dataset that has 2 groups of samples. For each sample, then
response measured is the number of success (no.success) obatined with the number
of trials (no.trials). So a porportion of success (prpop.success) can be
computed as no.success/no.trials. Now the objective is to test if there is a
statistical significant difference in the proportion of success between the 2
groups of