Displaying 3 results from an estimated 3 matches for "definesampl".
Did you mean:
definesamples
2007 Apr 02
2
(Newbie)Basic Basic global vs. local variables
...other languages before, but I somehow cant figure out R's general
rules for global and local variables. I have put a simple code below, if
anyone can show me what i need to add to make this work, i would greatly
appreciate it!
#----------------------------------------
g_Means<-numeric()
defineSamples<- function()
{
g_Means<-5
}
runit<-function()
{
defineSamples()
g_Means #####<<This returns "numeric(0)", and not "5"
}
runit()
#----------------------------
Basically I can not get the parameter I set from a global scale...
--
View this message in...
2011 Jul 13
1
Error non-numeric argument to binary operator
Dear all,
I have a data frame df and i am using a code shown below.
df[, "total"] <- rowSums(df[, 3:6]) MAKING A NEW COLUMN total in df BY ROWSUMS
defineSamples<- function()
{
readline("enter the number of INDIVIDUALS IN POOL: ")
}
df$ind=definesamples() CALLING THE FUNCTION AND STORING THE INPUT FROM USER IN NEW COLUMN OF df
df[, 3:6] <- apply(df[, 3:6], 2, function(x) x / df[, "total"] * df[, "ind"] * 2)...
2007 Apr 01
2
Reading user input
...n finish my project for this term.
I am making an interactive application with R where I get the user to input
numbers that the program then uses in the analysis. I have figured out a
lot of stuff, yet this is somehow hard to find the answer to:
#--------------------------------------------------
defineSamples<- function()
{
ANSWER<-numeric()
ANSWER<-readline("enter the number of groups: ")
}
runit()
ANSWER # this does not hold the value the user inputs
#-------------------------------------------------
If I then see what ANSWER is storing it says "nume...