[R] how to judge a virable is a integer?

2014-10-18 Thread PO SU


Dear usRers,
   I want to judge virable is or not a integer?
  e.g.  is.integer(1)  FALSE   because it is a numeric, but i want it's true.
as.integer may not be used. because i don't know a is 1 or 1.1.





--

PO SU
mail: desolato...@163.com 
Majored in Statistics from SJTU
__
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 judge a virable is a integer?

2014-10-18 Thread Berend Hasselman

On 18-10-2014, at 12:41, PO SU rhelpmaill...@163.com wrote:

 
 
 Dear usRers,
I want to judge virable is or not a integer?
   e.g.  is.integer(1)  FALSE   because it is a numeric, but i want it's true.
 as.integer may not be used. because i don't know a is 1 or 1.1.
 

is.integer is surely what you need if you wish to test if a variable is integer.
See this

# a - 1
# b - 1L

# is.integer(a)
[1] FALSE

# is.integer(b)
[1] TRUE

See the help for is.integer to see how you can test for a wholenumber, which 
might be what you want.

Berend

__
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 judge a virable is a integer?

2014-10-18 Thread PO SU

But i use a-10/b ,  b is some value ,may be  5, maybe 5.5 
not in the form  xxL ,so how can i do in the situation to judge a ?






--

PO SU
mail: desolato...@163.com 
Majored in Statistics from SJTU



At 2014-10-18 18:58:48, Berend Hasselman b...@xs4all.nl wrote:

On 18-10-2014, at 12:41, PO SU rhelpmaill...@163.com wrote:

 
 
 Dear usRers,
I want to judge virable is or not a integer?
   e.g.  is.integer(1)  FALSE   because it is a numeric, but i want it's true.
 as.integer may not be used. because i don't know a is 1 or 1.1.
 

is.integer is surely what you need if you wish to test if a variable is 
integer.
See this

# a - 1
# b - 1L

# is.integer(a)
[1] FALSE

# is.integer(b)
[1] TRUE

See the help for is.integer to see how you can test for a wholenumber, which 
might be what you want.

Berend

__
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 judge a virable is a integer?

2014-10-18 Thread S Ellison
 But i use a-10/b ,  b is some value ,may be  5, maybe 5.5
If you do floating point arithmetic on integers you'll usually get floating 
point answers, including the 5.0.

See FAQ 7.31 for the usual floating point problem, and ?all.equal for the usual 
answer to it. You could see if a result is close to an integer by,for example, 
using all.equal to compare it to itself after rounding.

S

***
This email and any attachments are confidential. Any use...{{dropped:8}}

__
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 judge a virable is a integer?

2014-10-18 Thread PO SU

It's due to that, 1 is a numeric, 1.2 is a numeric, though it's true. but 
deeply, when i want to know 1 is an integer,  there seems no easy way to get 
the answer.
So, is there anyone happen to know it?




--

PO SU
mail: desolato...@163.com 
Majored in Statistics from SJTU



At 2014-10-18 20:10:09, S Ellison s.elli...@lgcgroup.com wrote:
 But i use a-10/b ,  b is some value ,may be  5, maybe 5.5
If you do floating point arithmetic on integers you'll usually get floating 
point answers, including the 5.0.

See FAQ 7.31 for the usual floating point problem, and ?all.equal for the 
usual answer to it. You could see if a result is close to an integer by,for 
example, using all.equal to compare it to itself after rounding.

S

***
This email and any attachments are confidential. Any use, copying or
disclosure other than by the intended recipient is unauthorised. If 
you have received this message in error, please notify the sender 
immediately via +44(0)20 8943 7000 or notify postmas...@lgcgroup.com 
and delete this message and any copies from your computer and network. 
LGC Limited. Registered in England 2991879. 
Registered office: Queens Road, Teddington, Middlesex, TW11 0LY, UK
__
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 judge a virable is a integer?

2014-10-18 Thread Sergio Fonda
Don't know if this trivial reply will be useful

a=5
is.numeric(a)
[1] TRUE
b=try
is.numeric(b)
[1] FALSE
 Il 18/ott/2014 16:29 PO SU rhelpmaill...@163.com ha scritto:


 It's due to that, 1 is a numeric, 1.2 is a numeric, though it's true. but
 deeply, when i want to know 1 is an integer,  there seems no easy way to
 get the answer.
 So, is there anyone happen to know it?




 --

 PO SU
 mail: desolato...@163.com
 Majored in Statistics from SJTU



 At 2014-10-18 20:10:09, S Ellison s.elli...@lgcgroup.com wrote:
  But i use a-10/b ,  b is some value ,may be  5, maybe 5.5
 If you do floating point arithmetic on integers you'll usually get
 floating point answers, including the 5.0.
 
 See FAQ 7.31 for the usual floating point problem, and ?all.equal for the
 usual answer to it. You could see if a result is close to an integer by,for
 example, using all.equal to compare it to itself after rounding.
 
 S
 
 ***
 This email and any attachments are confidential. Any use, copying or
 disclosure other than by the intended recipient is unauthorised. If
 you have received this message in error, please notify the sender
 immediately via +44(0)20 8943 7000 or notify postmas...@lgcgroup.com
 and delete this message and any copies from your computer and network.
 LGC Limited. Registered in England 2991879.
 Registered office: Queens Road, Teddington, Middlesex, TW11 0LY, UK
 __
 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.


[[alternative HTML version deleted]]

__
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 judge a virable is a integer?

2014-10-18 Thread Sergio Fonda
Sorry for my previous hurry misunderstanding.
Try this link:
http://stackoverflow.com/questions/3476782/how-to-check-if-the-number-is-integer


2014-10-18 16:25 GMT+02:00 PO SU rhelpmaill...@163.com:


 It's due to that, 1 is a numeric, 1.2 is a numeric, though it's true. but
 deeply, when i want to know 1 is an integer,  there seems no easy way to
 get the answer.
 So, is there anyone happen to know it?




 --

 PO SU
 mail: desolato...@163.com
 Majored in Statistics from SJTU



 At 2014-10-18 20:10:09, S Ellison s.elli...@lgcgroup.com wrote:
  But i use a-10/b ,  b is some value ,may be  5, maybe 5.5
 If you do floating point arithmetic on integers you'll usually get
 floating point answers, including the 5.0.
 
 See FAQ 7.31 for the usual floating point problem, and ?all.equal for the
 usual answer to it. You could see if a result is close to an integer by,for
 example, using all.equal to compare it to itself after rounding.
 
 S
 
 ***
 This email and any attachments are confidential. Any use, copying or
 disclosure other than by the intended recipient is unauthorised. If
 you have received this message in error, please notify the sender
 immediately via +44(0)20 8943 7000 or notify postmas...@lgcgroup.com
 and delete this message and any copies from your computer and network.
 LGC Limited. Registered in England 2991879.
 Registered office: Queens Road, Teddington, Middlesex, TW11 0LY, UK
 __
 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.


[[alternative HTML version deleted]]

__
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 judge a virable is a integer?

2014-10-18 Thread Sergio Fonda
Further and last trial:

 a=5.102 a-floor(a)==0[1] FALSE a=5.9 a-floor(a)==0[1] FALSE a=19 
 a-floor(a)==0[1] TRUE

All the best,

Sergio



2014-10-18 16:25 GMT+02:00 PO SU rhelpmaill...@163.com:


 It's due to that, 1 is a numeric, 1.2 is a numeric, though it's true. but
 deeply, when i want to know 1 is an integer,  there seems no easy way to
 get the answer.
 So, is there anyone happen to know it?




 --

 PO SU
 mail: desolato...@163.com
 Majored in Statistics from SJTU



 At 2014-10-18 20:10:09, S Ellison s.elli...@lgcgroup.com wrote:
  But i use a-10/b ,  b is some value ,may be  5, maybe 5.5
 If you do floating point arithmetic on integers you'll usually get
 floating point answers, including the 5.0.
 
 See FAQ 7.31 for the usual floating point problem, and ?all.equal for the
 usual answer to it. You could see if a result is close to an integer by,for
 example, using all.equal to compare it to itself after rounding.
 
 S
 
 ***
 This email and any attachments are confidential. Any use, copying or
 disclosure other than by the intended recipient is unauthorised. If
 you have received this message in error, please notify the sender
 immediately via +44(0)20 8943 7000 or notify postmas...@lgcgroup.com
 and delete this message and any copies from your computer and network.
 LGC Limited. Registered in England 2991879.
 Registered office: Queens Road, Teddington, Middlesex, TW11 0LY, UK
 __
 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.


[[alternative HTML version deleted]]

__
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] seqinr ?: Splitting a factor name into several columns. Dealing with metabarcoding data.

2014-10-18 Thread Anna Zakrisson Braeunlich
Thank you! That was a easy and fast solution!

May I post a follow-up question? (I am not sure if this would rather should be 
posted as a new question, but I post it here and then I can re-post it if this 
is the wrong place to ask this). I am ever so grateful for your help!
/Anna


# FOLLOW-UP QUESTION 


df1 - data.frame(cbind(Identifier = c(M123.B23.VJHJ, M123.B24.VJHJ,
   M123.B23.VLKE, M123.B23.HKJH,
   M123.B24.LKJH),
   Sequence = c(ATATATATATA, 
ATATATATATA,
ATATAGCATATA, 
ATATATAGGGTA,
ATCGCGCGAATA))) 



# as a follow-up question:
# How can I split the identifier in df1 above into several columns based on the 
# separating dots? The real data includes thousands of rows.
# This is what I want it to look like in the end:

df1_solution - data.frame(cbind(Identifier1 = c(M123, M123,
   M123, M123,
   M123),
Identifier2 = c(B23, B24, B23, B23, B24),
Identifier3 = c(VJHJ, VJHJ, VLKE, HKJH, LKJH),
Sequence = c(ATATATATATA, ATATATATATA,
 ATATAGCATATA, ATATATAGGGTA,
 ATCGCGCGAATA)))

# I am very grateful for your help! I am no whiz at R and everything I know
# is self-taught. Therefore, some basics can turn out to be quite some
# obsatcles for me. 
# /Anna

º`•. . • `•. .• `•. . º`•. . • `•. .• `•. .º`•. . • `•. .• 
`•. .º

Anna Zakrisson Braeunlich
PhD student

Department of Ecology, Environment and Plant Sciences
Stockholm University
Svante Arrheniusv. 21A
SE-106 91 Stockholm
Sweden/Sverige

Lives in Berlin.
For paper mail:
Katzbachstr. 21
D-10965, Berlin
Germany/Deutschland

E-mail: anna.zakris...@su.se
Tel work: +49-(0)3091541281
Mobile: +49-(0)15777374888
LinkedIn: http://se.linkedin.com/pub/anna-zakrisson-braeunlich/33/5a2/51b

º`•. . • `•. .• `•. . º`•. . • `•. .• `•. .º`•. . • `•. .• 
`•. .º


From: Ista Zahn [istaz...@gmail.com]
Sent: 13 October 2014 15:42
To: Anna Zakrisson Braeunlich
Cc: r-help@r-project.org
Subject: Re: [R] seqinr ?: Splitting a factor name into several columns. 
Dealing with metabarcoding data.

Hi Anna,


On Sun, Oct 12, 2014 at 3:24 AM, Anna Zakrisson Braeunlich
anna.zakris...@su.se wrote:
 Hi,

 I have a question how to split a factor name into different columns. I have 
 metabarcoding data and need to merge the FASTA-file with the taxonomy- and 
 counttable files (dataframes). To be able to do this merge, I need to isolate 
 the common identifier, that unfortunately is baked in with a lot of other 
 labels in the factor name eg:
 sequence identifier: 
 M01271_77_0.A8J0P_1_1101_10150_1525.1.322519.sample_1.sample_2

 I want to split this name at every . to get several columns:
 column1: M01271_77_0
 column2: A8J0P_1_1101_10150_1525
 column3: 1
 column4: 322519
 column5: sample_1
 column6: sample_2

 I must add that I have no influence on how these names are given. This is how 
 thay are supplied from Illumina Miseq. I just need to be able to deal with it.

 Here is some extremely simplified dummy data to further show the issue at 
 hand:

 df1 - data.frame(cbind(X = 1:10, Y = rnorm(10)),
   Z.identifierA.B1298712 = factor(rep(LETTERS[1:2], each = 
 5)))
 df2 - data.frame(cbind(B = 13:22, K = rnorm(10)),
   Q.identifierA.B4668726 = factor(rep(LETTERS[1:2], each = 
 5)))

 # I have metabarcoding data with one FASTA-file, one count table and one 
 taxonomy file
 # Above dummy data is just showing the issue at hand. I want to be able to 
 merge my three
 # original data frames (here, the dummy data is only two dataframes). The 
 problem is that
 # the only identifier that is commmon for the dataframes is hidden in the
 # factor name eg: Z.identifierA.1298712 and Q.identifierA.4668726. I hence 
 need to be able
 # to split this name up into different columns to get identifierA alone as 
 one column name
 # Then I can merge the dataframes.
 # How can I do this in R. I know that it can be done in excel, but I would 
 like to
 # produce a complete R-script to get a fast pipeline and avoid copy and paste 
 errors.
 # This is what I want it to look:

 df1.goal - data.frame(cbind(X = 1:10, Y = rnorm(10)),
   Z = factor(rep(LETTERS[1:2], each = 5)),
   identifierA = factor(rep(LETTERS[1:2], each = 5)),
   B1298712 = factor(rep(LETTERS[1:2], each = 5)))

Use strsplit to separate the components, something like

separateNames - strsplit(names(df1)[3], split = \\.)[[1]]
for(name in separateNames) {
df1[[name]] - df1[[3]]
}
df1[[3]] - NULL


[R] Smoothing Data-dplyr

2014-10-18 Thread umair durrani
Please note that I have already asked this question on stackoverflow.com but 
did not get a satisfactory answer. I have a data set containing velocities of 
2169 vehicles recorded at 
intervals of 0.1 seconds. So, there are many rows for an individual 
vehicle. Here I am reproducing the data only for the vehicle # 2:   
 dput(uma)
structure(list(Vehicle.ID = c(2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 
2, 2), Frame.ID = 13:445, Vehicle.velocity = c(40, 40, 40, 40, 
40, 40, 40, 40.02, 40.03, 39.93, 39.61, 39.14, 38.61, 38.28, 
38.42, 38.78, 38.92, 38.54, 37.51, 36.34, 35.5, 35.08, 34.96, 
34.98, 35, 34.99, 34.98, 35.1, 35.49, 36.2, 37.15, 38.12, 38.76, 
38.95, 38.95, 38.99, 39.18, 39.34, 39.2, 38.89, 38.73, 38.88, 
39.28, 39.68, 39.94, 40.02, 40, 39.99, 39.99, 39.65, 38.92, 38.52, 
38.8, 39.72, 40.76, 41.07, 40.8, 40.59, 40.75, 41.38, 42.37, 
43.37, 44.06, 44.29, 44.13, 43.9, 43.92, 44.21, 44.59, 44.87, 
44.99, 45.01, 45.01, 45, 45, 45, 44.79, 44.32, 43.98, 43.97, 
44.29, 44.76, 45.06, 45.36, 45.92, 46.6, 47.05, 47.05, 46.6, 
45.92, 45.36, 45.06, 44.96, 44.97, 44.99, 44.99, 44.99, 44.99, 
45.01, 45.02, 44.9, 44.46, 43.62, 42.47, 41.41, 40.72, 40.49, 
40.6, 40.76, 40.72, 40.5, 40.38, 40.43, 40.38, 39.83, 38.59, 
37.02, 35.73, 35.04, 34.85, 34.91, 34.99, 34.99, 34.97, 34.96, 
34.98, 35.07, 35.29, 35.54, 35.67, 35.63, 35.53, 35.53, 35.63, 
35.68, 35.55, 35.28, 35.06, 35.09, 35.49, 36.22, 37.08, 37.8, 
38.3, 38.73, 39.18, 39.62, 39.83, 39.73, 39.58, 39.57, 39.71, 
39.91, 40, 39.98, 39.97, 40.08, 40.38, 40.81, 41.27, 41.69, 42.2, 
42.92, 43.77, 44.49, 44.9, 45.03, 45.01, 45, 45, 45, 45, 45, 
45, 45, 45, 45, 45, 45, 44.99, 45.03, 45.26, 45.83, 46.83, 48.2, 
49.68, 50.95, 51.83, 52.19, 52, 51.35, 50.38, 49.38, 48.63, 48.15, 
47.87, 47.78, 48.01, 48.63, 49.52, 50.39, 50.9, 50.96, 50.68, 
50.3, 50.05, 49.94, 49.87, 49.82, 49.82, 49.88, 49.96, 50, 50, 
49.98, 49.98, 50.16, 50.64, 51.43, 52.33, 53.01, 53.27, 53.22, 
53.25, 53.75, 54.86, 56.36, 57.64, 58.28, 58.29, 57.94, 57.51, 
57.07, 56.64, 56.43, 56.73, 57.5, 58.27, 58.55, 58.32, 57.99, 
57.89, 57.92, 57.74, 57.12, 56.24, 55.51, 55.1, 54.97, 54.98, 
55.02, 55.03, 54.86, 54.3, 53.25, 51.8, 50.36, 49.41, 49.06, 
49.17, 49.4, 49.51, 49.52, 49.51, 49.45, 49.24, 48.84, 48.29, 
47.74, 47.33, 47.12, 47.06, 47.07, 47.08, 47.05, 47.04, 47.25, 
47.68, 47.93, 47.56, 46.31, 44.43, 42.7, 41.56, 41.03, 40.92, 
40.92, 40.98, 41.19, 41.45, 41.54, 41.32, 40.85, 40.37, 40.09, 
39.99, 39.99, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 39.98, 
39.97, 40.1, 40.53, 41.36, 42.52, 43.71, 44.57, 45.01, 45.1, 
45.04, 45, 45, 45, 45, 45, 45, 44.98, 44.97, 45.08, 45.39, 45.85, 
46.2, 46.28, 46.21, 46.29, 46.74, 47.49, 48.35, 49.11, 49.63, 
49.89, 49.94, 49.97, 50.14, 50.44, 50.78, 51.03, 51.12, 51.05, 
50.85, 50.56, 50.26, 50.06, 50.1, 50.52, 51.36, 52.5, 53.63, 
54.46, 54.9, 55.03, 55.09, 55.23, 55.35, 55.35, 55.23, 55.07, 
54.99, 54.98, 54.97, 55.06, 55.37, 55.91, 56.66, 57.42, 58.07, 
58.7, 59.24, 59.67, 59.95, 60.02, 60, 60, 60, 60, 60, 60.01, 
60.06, 60.23, 60.65, 61.34, 62.17, 62.93, 63.53, 64, 64.41, 64.75, 
65.04, 65.3, 65.57, 65.75, 65.74, 65.66, 65.62, 65.71, 65.91, 
66.1, 66.26, 66.44, 66.61, 66.78, 66.91, 66.99, 66.91, 66.7, 
66.56, 66.6, 66.83, 67.17, 67.45, 67.75, 68.15, 68.64, 69.15, 
69.57, 69.79, 69.79, 69.72, 69.72, 69.81, 69.94, 70, 70.01, 70.02, 
70.03)), row.names = c(NA, 433L), class = data.frame, .Names = 
c(Vehicle.ID, 
Frame.ID, Vehicle.velocity))  
I am trying to smooth the data using dplyr. Here is the code:  
 uma - tbl_df(uma)
uma - uma %% # take data frame 
  group_by(Vehicle.ID)  %%  # group by Vehicle ID
  mutate(i = 1:length(Frame.ID), im1 = i-1, Nai = length(Frame.ID) - i,
 Dv = pmin(im1, 

[R] command for plm

2014-10-18 Thread Amarjit Singh
Dear allI am trying to carry out step-wise panel regression analysis by making 
adaptation in the use of plm package. Say, I am trying to regress the explained 
variable (DEP) on 3 explanatory variables (EX1, EX2, EX3) using a panel data 
set (dat). Of course, the required set of instructions would be:require(plm)reg 
- plm(DEP ~ EX1 + EX2 + EX3, data = dat, method = within)                    
                                              ... (A)But, what I wish to do 
(for the purpose of carrying out the analysis iteratively) is as follows:dep - 
DEPexp - c(EX1, EX2, EX3)and then use somehow these dep and exp to get 
a  statement compatible with (A). I tried the following
frm - as.formula(paste(dep, ~, exp))
reg - plm(frm, data = dat, method = within)But it did not work properly. I 
could get the output only in respect of DEP ~ EX1, whereas I need the same in 
respect of DEP ~ EX1 + EX2 + EX3.Kindly help.  RegardsAmarjit Singh
[[alternative HTML version deleted]]

__
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] Build a package on one Mac but unable to load this on another Mac

2014-10-18 Thread althu07
Hi, I build a package on one Mac. I can install the package on another Mac
but it cannot be loaded. The following is the error message.

Error in dyn.load(file, DLLpath = DLLpath, ...) :
unable to load shared object
'/Library/Frameworks/R.framework/Versions/3.1/Resources/library/mypkgfe/libs/mypkgfe.so':
dlopen(/Library/Frameworks/R.framework/Versions/3.1/Resources/library/mypkgfe/libs/mypkgfe.so,
6): Library not loaded: /usr/local/lib/libgfortran.3.dylib
Referenced from:
/Library/Frameworks/R.framework/Versions/3.1/Resources/library/mypkgfe/libs/mypkgfe.so
Reason: image not found
Error: package or namespace load failed for ‘mypkgfe’

If I install the gfortran on the user's Mac, the package can be installed
and loaded successfully. But I don't think this is a good option to solve
this problem as it requires too much on the user's end. Is there anyway to
build the package so that it can be successfully loaded even the Mac
doesn't have gfortran preinstalled?

It seems the Mavericks OS X can load the package but not the Snow Leopard
OS X. I am wondering if this has anything to do with the fact that R for
Snow Leopard doesn't include GNU Fortran.

Thanks!

[[alternative HTML version deleted]]

__
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 judge a virable is a integer?

2014-10-18 Thread William Dunlap
It sounds like you want an 'is.integral' function to tell if a
number acts like a mathematical integer, as opposed to
'is.integer', which tells if a number is stored as a 32-bit
computer integer.  The test will depend on what properties
of mathematical integers you are most interested in.

   is.integral - function (x)  (floor(x) == x)  (abs(x) + 1  abs(x))
will return TRUE if x has no fractional part and the number's
putative successor (predecessor if negative) is different than
the number.  That latter test is equivalent (roughly) to log2(abs(x))53 and
comes into play when you run out of bits in the mantissa of
a double precision number.  (One might want it to return NA in
that case, but I think FALSE works better.)


Bill Dunlap
TIBCO Software
wdunlap tibco.com


On Sat, Oct 18, 2014 at 3:41 AM, PO SU rhelpmaill...@163.com wrote:


 Dear usRers,
I want to judge virable is or not a integer?
   e.g.  is.integer(1)  FALSE   because it is a numeric, but i want it's true.
 as.integer may not be used. because i don't know a is 1 or 1.1.





 --

 PO SU
 mail: desolato...@163.com
 Majored in Statistics from SJTU
 __
 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-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] Smoothing Data-dplyr

2014-10-18 Thread David Winsemius

On Oct 18, 2014, at 7:57 AM, umair durrani wrote:

 Please note that I have already asked this question on stackoverflow.com but 
 did not get a satisfactory answer.

You should say what was unsatisfactory about the answer you were offered:
http://stackoverflow.com/questions/26434652/data-smoothing-in-r

You got 3 answers that appeared to be improvements including one using Rcpp 
that gave you a 6 thousand fold improvement in running time.

-- 
David.

 I have a data set containing velocities of 2169 vehicles recorded at 
 intervals of 0.1 seconds. So, there are many rows for an individual 
 vehicle. Here I am reproducing the data only for the vehicle # 2:   
 dput(uma)
 structure(list(Vehicle.ID = c(2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 
 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 
 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 
 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 
 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 
 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 
 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 
 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 
 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 
 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 
 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 
 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 
 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 
 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 
 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 
 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 
 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 
 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 
 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 
 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 
 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 
 2, 2), Frame.ID = 13:445, Vehicle.velocity = c(40, 40, 40, 40, 
 40, 40, 40, 40.02, 40.03, 39.93, 39.61, 39.14, 38.61, 38.28, 
 38.42, 38.78, 38.92, 38.54, 37.51, 36.34, 35.5, 35.08, 34.96, 
 34.98, 35, 34.99, 34.98, 35.1, 35.49, 36.2, 37.15, 38.12, 38.76, 
 38.95, 38.95, 38.99, 39.18, 39.34, 39.2, 38.89, 38.73, 38.88, 
 39.28, 39.68, 39.94, 40.02, 40, 39.99, 39.99, 39.65, 38.92, 38.52, 
 38.8, 39.72, 40.76, 41.07, 40.8, 40.59, 40.75, 41.38, 42.37, 
 43.37, 44.06, 44.29, 44.13, 43.9, 43.92, 44.21, 44.59, 44.87, 
 44.99, 45.01, 45.01, 45, 45, 45, 44.79, 44.32, 43.98, 43.97, 
 44.29, 44.76, 45.06, 45.36, 45.92, 46.6, 47.05, 47.05, 46.6, 
 45.92, 45.36, 45.06, 44.96, 44.97, 44.99, 44.99, 44.99, 44.99, 
 45.01, 45.02, 44.9, 44.46, 43.62, 42.47, 41.41, 40.72, 40.49, 
 40.6, 40.76, 40.72, 40.5, 40.38, 40.43, 40.38, 39.83, 38.59, 
 37.02, 35.73, 35.04, 34.85, 34.91, 34.99, 34.99, 34.97, 34.96, 
 34.98, 35.07, 35.29, 35.54, 35.67, 35.63, 35.53, 35.53, 35.63, 
 35.68, 35.55, 35.28, 35.06, 35.09, 35.49, 36.22, 37.08, 37.8, 
 38.3, 38.73, 39.18, 39.62, 39.83, 39.73, 39.58, 39.57, 39.71, 
 39.91, 40, 39.98, 39.97, 40.08, 40.38, 40.81, 41.27, 41.69, 42.2, 
 42.92, 43.77, 44.49, 44.9, 45.03, 45.01, 45, 45, 45, 45, 45, 
 45, 45, 45, 45, 45, 45, 44.99, 45.03, 45.26, 45.83, 46.83, 48.2, 
 49.68, 50.95, 51.83, 52.19, 52, 51.35, 50.38, 49.38, 48.63, 48.15, 
 47.87, 47.78, 48.01, 48.63, 49.52, 50.39, 50.9, 50.96, 50.68, 
 50.3, 50.05, 49.94, 49.87, 49.82, 49.82, 49.88, 49.96, 50, 50, 
 49.98, 49.98, 50.16, 50.64, 51.43, 52.33, 53.01, 53.27, 53.22, 
 53.25, 53.75, 54.86, 56.36, 57.64, 58.28, 58.29, 57.94, 57.51, 
 57.07, 56.64, 56.43, 56.73, 57.5, 58.27, 58.55, 58.32, 57.99, 
 57.89, 57.92, 57.74, 57.12, 56.24, 55.51, 55.1, 54.97, 54.98, 
 55.02, 55.03, 54.86, 54.3, 53.25, 51.8, 50.36, 49.41, 49.06, 
 49.17, 49.4, 49.51, 49.52, 49.51, 49.45, 49.24, 48.84, 48.29, 
 47.74, 47.33, 47.12, 47.06, 47.07, 47.08, 47.05, 47.04, 47.25, 
 47.68, 47.93, 47.56, 46.31, 44.43, 42.7, 41.56, 41.03, 40.92, 
 40.92, 40.98, 41.19, 41.45, 41.54, 41.32, 40.85, 40.37, 40.09, 
 39.99, 39.99, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 39.98, 
 39.97, 40.1, 40.53, 41.36, 42.52, 43.71, 44.57, 45.01, 45.1, 
 45.04, 45, 45, 45, 45, 45, 45, 44.98, 44.97, 45.08, 45.39, 45.85, 
 46.2, 46.28, 46.21, 46.29, 46.74, 47.49, 48.35, 49.11, 49.63, 
 49.89, 49.94, 49.97, 50.14, 50.44, 50.78, 51.03, 51.12, 51.05, 
 50.85, 50.56, 50.26, 50.06, 50.1, 50.52, 51.36, 52.5, 53.63, 
 54.46, 54.9, 55.03, 55.09, 55.23, 55.35, 55.35, 55.23, 55.07, 
 54.99, 54.98, 54.97, 55.06, 55.37, 55.91, 56.66, 57.42, 58.07, 
 58.7, 59.24, 59.67, 59.95, 60.02, 60, 60, 60, 60, 60, 60.01, 
 60.06, 60.23, 60.65, 61.34, 62.17, 62.93, 63.53, 64, 64.41, 64.75, 
 65.04, 65.3, 65.57, 65.75, 65.74, 65.66, 65.62, 65.71, 65.91, 
 66.1, 66.26, 66.44, 66.61, 66.78, 66.91, 66.99, 66.91, 66.7, 
 66.56, 66.6, 66.83, 67.17, 67.45, 67.75, 68.15, 68.64, 69.15, 
 69.57, 69.79, 69.79, 69.72, 69.72, 69.81, 

Re: [R] Build a package on one Mac but unable to load this on another Mac

2014-10-18 Thread David Winsemius

On Oct 18, 2014, at 8:42 AM, althu07 wrote:

 Hi, I build a package on one Mac. I can install the package on another Mac
 but it cannot be loaded. The following is the error message.
 
 Error in dyn.load(file, DLLpath = DLLpath, ...) :
 unable to load shared object
 '/Library/Frameworks/R.framework/Versions/3.1/Resources/library/mypkgfe/libs/mypkgfe.so':
 dlopen(/Library/Frameworks/R.framework/Versions/3.1/Resources/library/mypkgfe/libs/mypkgfe.so,
 6): Library not loaded: /usr/local/lib/libgfortran.3.dylib
 Referenced from:
 /Library/Frameworks/R.framework/Versions/3.1/Resources/library/mypkgfe/libs/mypkgfe.so
 Reason: image not found
 Error: package or namespace load failed for ‘mypkgfe’
 
 If I install the gfortran on the user's Mac, the package can be installed
 and loaded successfully. But I don't think this is a good option to solve
 this problem as it requires too much on the user's end. Is there anyway to
 build the package so that it can be successfully loaded even the Mac
 doesn't have gfortran preinstalled?
 
 It seems the Mavericks OS X can load the package but not the Snow Leopard
 OS X. I am wondering if this has anything to do with the fact that R for
 Snow Leopard doesn't include GNU Fortran.

As far as Macs are concerned there are two forks in the R versions: one running 
on Snow Leopard, Lion and Mountain Lion and the other running on Mavericks and 
Yosemite. If you submit the package to CRAN it will build two different 
versions using the correct toolchains (and the correct XQuartz and Java 
packages). If  you are doing this on your own, you will need to have two 
different versions each with the correct toolchains. This is something that is 
described in the admin documents. And future questions should go to the correct 
mailing list: R-SIG-Mac: https://stat.ethz.ch/mailman/listinfo/r-sig-mac


 
 Thanks!
 
   [[alternative HTML version deleted]]

And like rhelp, R-SIG-Mac is a plain text mailing list.

 __
 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.

David Winsemius
Alameda, CA, USA

__
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] Build a package on one Mac but unable to load this on another Mac

2014-10-18 Thread Amos B. Elberg
You could include just that library in your distribution, and change the 
dynamic link path using install_name_tool. I assume how to do so in detail is 
beyond the intended scope of this mailing list.


 On Oct 18, 2014, at 11:42 AM, althu07 alth...@gmail.com wrote:
 
 Hi, I build a package on one Mac. I can install the package on another Mac
 but it cannot be loaded. The following is the error message.
 
 Error in dyn.load(file, DLLpath = DLLpath, ...) :
 unable to load shared object
 '/Library/Frameworks/R.framework/Versions/3.1/Resources/library/mypkgfe/libs/mypkgfe.so':
 dlopen(/Library/Frameworks/R.framework/Versions/3.1/Resources/library/mypkgfe/libs/mypkgfe.so,
 6): Library not loaded: /usr/local/lib/libgfortran.3.dylib
 Referenced from:
 /Library/Frameworks/R.framework/Versions/3.1/Resources/library/mypkgfe/libs/mypkgfe.so
 Reason: image not found
 Error: package or namespace load failed for ‘mypkgfe’
 
 If I install the gfortran on the user's Mac, the package can be installed
 and loaded successfully. But I don't think this is a good option to solve
 this problem as it requires too much on the user's end. Is there anyway to
 build the package so that it can be successfully loaded even the Mac
 doesn't have gfortran preinstalled?
 
 It seems the Mavericks OS X can load the package but not the Snow Leopard
 OS X. I am wondering if this has anything to do with the fact that R for
 Snow Leopard doesn't include GNU Fortran.
 
 Thanks!
 
[[alternative HTML version deleted]]
 
 __
 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-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] Build a package on one Mac but unable to load this on another Mac

2014-10-18 Thread Prof Brian Ripley

On 18/10/2014 17:34, Amos B. Elberg wrote:

You could include just that library in your distribution, and change the 
dynamic link path using install_name_tool. I assume how to do so in detail is 
beyond the intended scope of this mailing list.


In fact you just need to change the path, as that library is included in 
the CRAN R distribution (which I guess is what it being used, although 
no one said which R it was).  Look in 
/Library/Frameworks/R.framework/Versions/Current/Resources/lib  


It is also most likely possible to link against a static libgfortran, as 
we do on Windows.


But this is indeed the wrong list: see the posting guide which it seems 
neither of you have read.  Follow-ups to R-sig-mac 





On Oct 18, 2014, at 11:42 AM, althu07 alth...@gmail.com wrote:

Hi, I build a package on one Mac. I can install the package on another Mac
but it cannot be loaded. The following is the error message.

Error in dyn.load(file, DLLpath = DLLpath, ...) :
unable to load shared object
'/Library/Frameworks/R.framework/Versions/3.1/Resources/library/mypkgfe/libs/mypkgfe.so':
dlopen(/Library/Frameworks/R.framework/Versions/3.1/Resources/library/mypkgfe/libs/mypkgfe.so,
6): Library not loaded: /usr/local/lib/libgfortran.3.dylib
Referenced from:
/Library/Frameworks/R.framework/Versions/3.1/Resources/library/mypkgfe/libs/mypkgfe.so
Reason: image not found
Error: package or namespace load failed for ‘mypkgfe’

If I install the gfortran on the user's Mac, the package can be installed
and loaded successfully. But I don't think this is a good option to solve
this problem as it requires too much on the user's end. Is there anyway to
build the package so that it can be successfully loaded even the Mac
doesn't have gfortran preinstalled?

It seems the Mavericks OS X can load the package but not the Snow Leopard
OS X. I am wondering if this has anything to do with the fact that R for
Snow Leopard doesn't include GNU Fortran.

Thanks!

[[alternative HTML version deleted]]



--
Brian D. Ripley,  rip...@stats.ox.ac.uk
Emeritus Professor of Applied Statistics, University of Oxford
1 South Parks Road, Oxford OX1 3TG, UK

__
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 judge a virable is a integer?

2014-10-18 Thread PO SU

Tks for your help, after investigate in your link, i find there seems three 
ways can be adoped:
1.    is.wholenumber - function(x, tol = .Machine$double.eps^0.5)  abs(x - 
round(x))  tol)
 e.g. is.wholenumber(1)
2.   x%%1==0


3. all.equal(a, as.integer(a))


and also included your last suggestion using floor. and also tks for other 
helpers!








--

PO SU
mail: desolato...@163.com 
Majored in Statistics from SJTU

At 2014-10-18 22:48:15, Sergio Fonda sergio.fond...@gmail.com wrote:
 


Sorry for my previous hurry misunderstanding.
Try this link:
http://stackoverflow.com/questions/3476782/how-to-check-if-the-number-is-integer




2014-10-18 16:25 GMT+02:00 PO SU rhelpmaill...@163.com:



It's due to that, 1 is a numeric, 1.2 is a numeric, though it's true. but 
deeply, when i want to know 1 is an integer,  there seems no easy way to get 
the answer.

So, is there anyone happen to know it?









--



PO SU

mail: desolato...@163.com

Majored in Statistics from SJTU







At 2014-10-18 20:10:09, S Ellison s.elli...@lgcgroup.com wrote:

 But i use a-10/b ,  b is some value ,may be  5, maybe 5.5

If you do floating point arithmetic on integers you'll usually get floating 
point answers, including the 5.0.



See FAQ 7.31 for the usual floating point problem, and ?all.equal for the 
usual answer to it. You could see if a result is close to an integer by,for 
example, using all.equal to compare it to itself after rounding.



S



***

This email and any attachments are confidential. Any use, copying or

disclosure other than by the intended recipient is unauthorised. If

you have received this message in error, please notify the sender

immediately via +44(0)20 8943 7000 or notify postmas...@lgcgroup.com

and delete this message and any copies from your computer and network.

LGC Limited. Registered in England 2991879.

Registered office: Queens Road, Teddington, Middlesex, TW11 0LY, UK

__

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-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 judge a virable is a integer?

2014-10-18 Thread William Dunlap
3. all.equal(a, as.integer(a))

Note that this one tests if 'a' can be stored accurately as a 32-bit signed
integer.  If you want to know if 'a' can be used as an accurate count, then
you want to test if a+1a (use abs() in case a is negative).  E.g., try this
for a-2^49-1, about 5*10^14.

You have to decide what properties of integers you are interested in.

Bill Dunlap
TIBCO Software
wdunlap tibco.com


On Sat, Oct 18, 2014 at 10:02 AM, PO SU rhelpmaill...@163.com wrote:

 Tks for your help, after investigate in your link, i find there seems three 
 ways can be adoped:
 1.is.wholenumber - function(x, tol = .Machine$double.eps^0.5)  abs(x - 
 round(x))  tol)
  e.g. is.wholenumber(1)
 2.   x%%1==0


 3. all.equal(a, as.integer(a))


 and also included your last suggestion using floor. and also tks for other 
 helpers!








 --

 PO SU
 mail: desolato...@163.com
 Majored in Statistics from SJTU

 At 2014-10-18 22:48:15, Sergio Fonda sergio.fond...@gmail.com wrote:



 Sorry for my previous hurry misunderstanding.
 Try this link:
 http://stackoverflow.com/questions/3476782/how-to-check-if-the-number-is-integer




 2014-10-18 16:25 GMT+02:00 PO SU rhelpmaill...@163.com:



 It's due to that, 1 is a numeric, 1.2 is a numeric, though it's true. but 
 deeply, when i want to know 1 is an integer,  there seems no easy way to get 
 the answer.

 So, is there anyone happen to know it?









 --



 PO SU

 mail: desolato...@163.com

 Majored in Statistics from SJTU







 At 2014-10-18 20:10:09, S Ellison s.elli...@lgcgroup.com wrote:

 But i use a-10/b ,  b is some value ,may be  5, maybe 5.5

If you do floating point arithmetic on integers you'll usually get floating 
point answers, including the 5.0.



See FAQ 7.31 for the usual floating point problem, and ?all.equal for the 
usual answer to it. You could see if a result is close to an integer by,for 
example, using all.equal to compare it to itself after rounding.



S



***

This email and any attachments are confidential. Any use, copying or

disclosure other than by the intended recipient is unauthorised. If

you have received this message in error, please notify the sender

immediately via +44(0)20 8943 7000 or notify postmas...@lgcgroup.com

and delete this message and any copies from your computer and network.

LGC Limited. Registered in England 2991879.

Registered office: Queens Road, Teddington, Middlesex, TW11 0LY, UK

 __

 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-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-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] Microsoft fighting against cxxfunction() and winning

2014-10-18 Thread Dirk Eddelbuettel

On 17 October 2014 at 11:57, Rainer K. SACHS wrote:
| Running Windows 7, 64 bit (but also including, I think, 32 bit R files)
| RStudio 0.98.501
| win-library 3.1
| 
| Getting error messages, probably related to add_path, for the
| following example script; I did look within RStudio and on the
| internet but can't understand the errors, let alone fix them, so any
| hints would be appreciated.
| 
| library(inline)
| library(Rcpp)
| library(devtools)
| f2 - cxxfunction( signature(x = integer, y = numeric ) , '
|   return wrap( asint(x) * asdouble(y) ) ;
| ', plugin = Rcpp )
| fx( 2L, 5 )
| # add_path(Rtools\\bin,after=0)
| # add_path(Rtools\\gcc-4.6.3\\bin,after=1)
| # get_path()

1)  Wrong list. This is an Rcpp question; you should ask those on rcpp-devel
(where you need to be subscribed to post).

2)  You are making your life way too complicated by sticking to a valid,
documented (and working, I may add) method which has long been
superseeded by Rcpp Attributes).  So one really quick way of writing
what you spec up there is

R library(Rcpp)
R cppFunction(double f2(int x, double y) { return x * y; })
R f2( 2L, 5)
[1] 10
R 

3)  Like some people, I find Windows a little cumbersome due to the need for
fiddling for PATH settings and the like -- but there are heuristics that
help.  If you do the above in RStudio and have, say, not all tools in
your path, RStudio will check and tell you so.  Give it a try.

Hope this helps, and that you find Rcpp helpful.  Please bring further
questions to the rcpp-devel list.

Dirk

| 
| 1) If I run as is, the error message is:
| Error in compileCode(f, code, language = language, verbose = verbose) :
|   Compilation ERROR, function(s)/method(s) not created! Warning message:
| running command 'make -f C:/PROGRA~1/R/R-31~1.1/etc/x64/Makeconf -f
| C:/PROGRA~1/R/R-31~1.1/share/make/winshlib.mk
| SHLIB_LDFLAGS='$(SHLIB_CXXLDFLAGS)' SHLIB_LD='$(SHLIB_CXXLD)'
| SHLIB=file1a2c862738.dll WIN=64 TCLBIN=64
| OBJECTS=file1a2c862738.o' had status 127
| In addition: Warning message:
| running command 'C:/PROGRA~1/R/R-31~1.1/bin/x64/R CMD SHLIB
| file1a2c862738.cpp 2 file1a2c862738.cpp.err.txt' had status 1
| 
| 2) If I uncomment the commented lines I get a longer, more
| interesting, even less comprehensible error message:
| Error in compileCode(f, code, language = language, verbose = verbose) :
|   Compilation ERROR, function(s)/method(s) not created! cygwin warning:
|   MS-DOS style path detected: C:/PROGRA~1/R/R-31~1.1/etc/x64/Makeconf
|   Preferred POSIX equivalent is:
| /cygdrive/c/PROGRA~1/R/R-31~1.1/etc/x64/Makeconf
|   CYGWIN environment variable option nodosfilewarning turns off this 
warning.
|   Consult the user's guide for more details about POSIX paths:
| http://cygwin.com/cygwin-ug-net/using.html#using-pathnames
| Syntax error: EOF in backquote substitution
| make: *** [file20681e531a0b.o] Error 2
| Warning message:
| running command 'make -f C:/PROGRA~1/R/R-31~1.1/etc/x64/Makeconf -f
| C:/PROGRA~1/R/R-31~1.1/share/make/winshlib.mk
| SHLIB_LDFLAGS='$(SHLIB_CXXLDFLAGS)' SHLIB_LD='$(SHLIB_CXXLD)'
| SHLIB=file20681e531a0b.dll WIN=64 TCLBIN=64
| OBJECTS=file20681e531a0b.o' had status 2
| In addition: Warning message:
| running command 'C:/PROGRA~1/R/R-31~1.1/bin/x64/R CMD SHLIB
| file20681e531a0b.cpp 2 file20681e531a0b.cpp.err.txt' had status 1
| 
| 
| 3) If I try to read cygwin-ug-net/using.html they don't seem to
| address 64 bit Windows.
| 
| Any suggestions? Thank you, Ray Sachs
| 
| __
| 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.

-- 
http://dirk.eddelbuettel.com | @eddelbuettel | e...@debian.org

__
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] Checking if a matrix exists/is defined

2014-10-18 Thread Steven Yen
Hello
Can someone help me with the following, specifically in judging 
whether a matrix exists. I have trouble with the first line below. In 
this case, matrix obj$hessian exists and is 74 x 74. I receive the 
error message:

Warning message:
In all(w$hessian) : coercing argument of type 'double' to logical

Thank you all.

---
if (!all(obj$hessian)|OPG){
   vb-obj$gradientObs; vb-solve(t(vb)%*%vb)
   vb.method-; v(b)=inv(G'G)
} else {
   vb- solve(-obj$hessian)
   vb.method-; v(b)=inv(-H)
} 
[[alternative HTML version deleted]]

__
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] Checking if a matrix exists/is defined

2014-10-18 Thread Richard M. Heiberger
all() takes a logical argument, not numeric.  See ?all

I think you are looking for
is.null(obj$hessian)

If this isn't what you are looking for, please send a reproducible example
to the entire list.

Rich

On Sun, Oct 19, 2014 at 12:17 AM, Steven Yen sye...@gmail.com wrote:
 Hello
 Can someone help me with the following, specifically in judging
 whether a matrix exists. I have trouble with the first line below. In
 this case, matrix obj$hessian exists and is 74 x 74. I receive the
 error message:

 Warning message:
 In all(w$hessian) : coercing argument of type 'double' to logical

 Thank you all.

 ---
 if (!all(obj$hessian)|OPG){
vb-obj$gradientObs; vb-solve(t(vb)%*%vb)
vb.method-; v(b)=inv(G'G)
 } else {
vb- solve(-obj$hessian)
vb.method-; v(b)=inv(-H)
 }
 [[alternative HTML version deleted]]

 __
 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-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.