Dear R users,
I?m trying to build a function to select random samples idf?s from a
database.
So, my data frame had 2 columns and 575 rows. Follow bellow an example of my
database
Idf1 casod
12 1
14 1
15 1
16 1
17 3
18 3
19 3
21 3
25 1
24 1
26 1
28 1
29 3
32 3
33 3
35 1
36 3
37 1
48 3
So my function is
blinding=function(sample){
sort=sample(idf1,10,replace=F)
return(sort2)
}
It is pretty simple and I would like to add one more step in my choice. I
would like to link my choice to casod stats. Thus if casod==3 sample would
be random idfs could not be an idf with casod=1. Does someone can help me?
--
View this message in context: http://r-sig-ecology.471788.n2.nabble.com/Help-with-a-function-tp7578931.html
Sent from the r-sig-ecology mailing list archive at Nabble.com.
Help with a function
10 messages · Jeremy Chacon, Nicholas Hamilton, Bob OHara +3 more
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-sig-ecology/attachments/20140606/ed6ccf96/attachment.pl>
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-sig-ecology/attachments/20140606/01ddd036/attachment.pl>
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-sig-ecology/attachments/20140606/f52dd7d7/attachment.pl>
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-sig-ecology/attachments/20140606/772ecccd/attachment.pl>
Hi O'Hara Thank you for the help Your comand helped me a lot. Was exactly what I wanted. Sampled a subset of my data that must have casod==3 By the way sorry for my english and for the question. I'm trying to learn how to create function in R Cheers, Moreno -- View this message in context: http://r-sig-ecology.471788.n2.nabble.com/Help-with-a-function-tp7578931p7578936.html Sent from the r-sig-ecology mailing list archive at Nabble.com.
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-sig-ecology/attachments/20140606/b2b20f3e/attachment.pl>
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-sig-ecology/attachments/20140606/b354c590/attachment.pl>
Hello,
I would like to thanks everyone for the help.
I did this one:
blinding=function(sampling){
sort1=sample(idf[casod==1],30,replace=F)
sort2=sample(idf[casod==3],30,replace=F)
var1=factor(c(rep(1,30),rep(2,30)),labels=c("Positivo","Negativo"))
var2=cbind(c(pos=sort1,neg=sort2))
var3=sample(1:60,replace=F)
df=data.frame(Status=var1,IDF=var2,TRP=var3)
return(write.csv(df,file="Piloto.csv",row.names=F))
It`s not exactly a function but works for me.
BTW I found this site:
http://manuals.bioinformatics.ucr.edu/home/programming-in-r
I`ll try to learn a little more about r functions
Regards,
Moreno
--
View this message in context: http://r-sig-ecology.471788.n2.nabble.com/Help-with-a-function-tp7578931p7578939.html
Sent from the r-sig-ecology mailing list archive at Nabble.com.
2 days later
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-sig-ecology/attachments/20140609/50f4e999/attachment.pl>