[R] openNLP package

2011-07-16 Thread Shekhar
Hi all,
Can anyone please help me in using the openNLP package for doing named-
entity extraction?

Regards,
Som

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] How to fit a random data into Beta distribution?

2011-05-05 Thread Shekhar

Hi,

@Steven: Since Beta distribution is a generic distribution by which i
mean that by varying the parameter of alpha and beta we can fit any
distribution.
So to check this i generated a random data from Normal distribution
like

x.norm-rnorm(n=100,mean=10,sd=10);

Now i want to estimate the paramters alpha and beta of the beta
distribution which will fit the above generated random data. That's
what i want to do.

@Ali: When you said you drafted your own procedure, do you mean that
you are calculate the parameters using MLE or bayesian..???Can you
please give me some more ideas into this?

Thanks and Regards,
Som Shekhar

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Remove all whitespaces

2011-05-05 Thread Shekhar
A more elegant way would be:

myString-1 2 3 4 5
myString-paste(unlist(strsplit(myString, )),collapse=)

The output will be 12345

Regards,
Som Shekhar

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Using functions/loops for repetitive commands

2011-05-05 Thread Shekhar
Hi Derek,
You can accomplish your loop jobs by following means:
(a) use for loop
(b) use while loop
(c) use lapply, tapply, or sapply. (i feel lapply is the elegant
way )


---For Loop-
for loops are pretty simple to use and is almost similar to any
other scripting languages you know.( I am referring to Matlab)

(Example 1) lets say you know that you have to run 10 iterations then
you can run it as

for(i in 1:10) print(i)
//it will print the number from 1 to 10

(Example 2) You don't know how many iterations you need to run. Only
thing you have is some vector and you want to do some operation on
that vector. You can do something like this:

myVector-c(20,45,23,45,89)
for(i in seq_along(myVector)) print(myVector[i]

-Using lapply-
In lapply you need to provide mainly two things:
(1)First parameter: vectors or some sequence of numbers
(2)Second parameter: A function which could be user defined function
or some other inbuilt function.

lapply will call the function for every number given in the First
parameter of the function)

For example:

x-c(10,20,20)
lapply(seq_along(x),function(i) {//your logic})

if you see the first parameter i have sent seq_along(x). The outcome
of seq_along(x) will be 1, 2,3.
Now lapply will take each of these numbers and call the function. That
means lapply is calling the function thrice for the current data set
something like this

function(1) { //your logic}
function(2) { }
function(3) { //)

That means your logic inside the function will be executed for each
and every value specified in the first parameter of the lapply
function.

I hope it helps you in some way.

For your problem, i am making a guess that you are using data frame or
matrix to store the data and then you want to automate the data right?
You can try using lapply, i think that would be efficient..Let me
also try ..

Regards,
Som Shekhar

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] How to fit a random data into Beta distribution?

2011-05-04 Thread Shekhar
Hi Steven,
Thanks for the quick reply. i have tried but
its giving me error---Error in optim(x = c(38.1815173696765,
-12.7988197976440, -3.88212459045077,  :
  initial value in 'vmmin' is not finite


i have tried something like this:

library(MASS)
x-rnorm(n=100,mean=10,sd=20);
fitdistr(x,dbeta,start=list(shape1=1,shape2=1)

Please correct me if my understanding is wrong:
In the fitdistr fucntion we are providing the initial values of the
Beta distribution parameters as shape1=1 and shape2=1. This function
will try to fit the data and give us the new parameters of Beta
distribution that approximately fits this data.


I have tried the function with other distribution like Normal, Gamma,
Weibull...its working fine..

Regards,
Som Shekhar




On May 4, 1:25 am, Steven Kennedy stevenkennedy2...@gmail.com wrote:
 library(MASS)
 fitdistr(x,beta,list(shape1=1,shape2=1))



 On Tue, May 3, 2011 at 9:44 PM, Shekhar shekhar2...@gmail.com wrote:

  Hi,
  I have some random data and i want to find out the parameters of Beta
  distribution ( a and b) such that this data approximately fits into
  this distribution. I have tried by plot the histograms and graph, but
  it requires lot of tuning and i am unable to do that. can anyone tell
  me how to do it programmitically in R?

  Regards,
  Som Shekhar

  __
  r-h...@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guidehttp://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.

 __
 r-h...@r-project.org mailing listhttps://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guidehttp://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] How to fit a random data into Beta distribution?

2011-05-03 Thread Shekhar
Hi,
I have some random data and i want to find out the parameters of Beta
distribution ( a and b) such that this data approximately fits into
this distribution. I have tried by plot the histograms and graph, but
it requires lot of tuning and i am unable to do that. can anyone tell
me how to do it programmitically in R?

Regards,
Som Shekhar

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Using Java methods in R

2011-04-23 Thread Shekhar
Hi Hill,
I just finished interfacing the C++ with R, i.e. c++ functions from R
and vice versa. Next thing in pipe line is Java and python.
I just wanted to share some of the things which i think might be
useful for you. Reason being whether its a C++, java or any other
compiled language the interface has to be generic in R. That means
mode of interfacing might be different(using different packages Rcpp
for c++, rJava for Java) but the underlying mechanism remains the
same.

For C++ you will be creating a dll ( windows) and .so( *nix) and for
jave you will be using class.
Now for using c++/java functions with in R or vice versa, you first
should check whether the functions are properly loaded in the R symbol
table or not?

If you are unable to call the java functions in R, then probably you
are unable to load the class into the R environment.

A few steps which i have followed in C++ ( i think must be more or
less same conceptually) could be useful for you:

1) I have a c++ file, i compile it using the command R CMD SHLIB
filename.cpp. On successful completion it creates the library. if you
are getting compilation error then you need to check whether the
header files are in proper path or not.

2) Then for using this function is first use to load the library using
the function dyn.load(library path)

3) If the loading is successful i check whether the required function
is properly loaded into the R symbol table or not by using the
function is.loaded(function name)

4) if it returns true, then i call the function by using .C or .Call
function provided by R.
For more information you can see 
http://groups.google.com/group/brumail/browse_thread/thread/a278dcbb6a8a439a
.

Hope it helps you in someway.

Regards,
Som Shekhar

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.