Re: [R] ggplot aestetics: beginner question - I am lost in endless possibilites

2016-12-15 Thread Hadley Wickham
You are going to find your life much easier if you:

* Organise your code so it's easier to read
* Use a consistent naming scheme for your variables
* Learn a bit more about how to modify variables succintly

Here's my rewriting of your script to make it easier to see what's going on.

library(tidyverse)

df <- tibble(
  name = c("Ernie","Ernie","Ernie", "Leon","Leon","Leon"),
  recorded_time = c("03.01.2011","04.01.2011","05.01.2011",
"04.01.2011","05.01.2011","06.01.2011"),
  known_state = c("breeding","moulting","moulting", "breeding","breeding",NA)
)
df$recorded_time <- lubridate::dmy(df$recorded_time)

ggplot(df) +
  geom_tile(
aes(recorded_time, name, fill = known_state),
colour = "black",
height = 0.5
  ) +
  scale_fill_discrete(na.value = "white")

Hadley

On Thu, Dec 15, 2016 at 8:22 PM, Dagmar  wrote:
> # Dear all,
> # I hope someone can help me with this. I am so lost and can't find a
> solution even though I spent hours on searching for a solution of that tiny
> problem.
> # Maybe someone of you could give me hint?
> #This is my string:
> exdatframe <- data.frame(Name=c("Ernie","Ernie","Ernie",
> "Leon","Leon","Leon"),
>   recordedTime=c("03.01.2011","04.01.2011","05.01.2011",
> "04.01.2011","05.01.2011","06.01.2011"),
>knownstate =c("breeding","moulting","moulting",
>  "breeding","breeding",NA))
> exdatframe
>
> exdatframeT <- as.POSIXct
> (strptime(as.character(exdatframe$recordedTime),"%d.%m.%Y"))
> exdatframeT
> exdatframe2 <- cbind(exdatframe, exdatframeT)
> exdatframe2$recordedTime <-NULL
> exdatframe2
> str(datframe)
>
> library(ggplot2)
> ggplot(exdatframe2)+geom_tile(aes(x=exdatframeT,y=Name,fill=knownstate),
> height=0.5)
>
> # Now all I want is:
> # 1) a black outline around the bars. Adding colour="black" like I have
> found elsewere on the internet doesn't work
> # 2) change the colours: E.g. I want white for NAs. I can't find a command
> to describe my wishes.
>
> #?
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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://hadley.nz

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] ggplot aestetics: beginner question - I am lost in endless possibilites

2016-12-15 Thread John Kane via R-help
I cannot see how you get that code to run. It certainly does not on my machine 
and some of the manipulations don't make any sense as far as I can see.
I changed variable and data.frame names so I would not have to type so much and 
read in the data with the "stringsAsFactors = FALSE" option.
I then parsed the dates (called 'known' in my data.frame) using the package 
"lubridate"
dat1$mydate <- dmy(dat1$mydate)

My resulting data.frame called dat1 is presented in dput() format below.
Do I understand you correctly in that you want the NA values plotted as "white" 
and the outline on the tiles in black?
In any case as my first steps here is a revised program to just get the 
tileswith no effort to get the outline or change the colours of the fill.



 

On Thursday, December 15, 2016 4:24 AM, Dagmar  wrote:
 

 # Dear all,
# I hope someone can help me with this. I am so lost and can't find a 
solution even though I spent hours on searching for a solution of that 
tiny problem.
# Maybe someone of you could give me hint?
#This is my string:
exdatframe <- data.frame(Name=c("Ernie","Ernie","Ernie", 
"Leon","Leon","Leon"),
              recordedTime=c("03.01.2011","04.01.2011","05.01.2011",
"04.01.2011","05.01.2011","06.01.2011"),
                knownstate =c("breeding","moulting","moulting",
                              "breeding","breeding",NA))
exdatframe

exdatframeT <- as.POSIXct 
(strptime(as.character(exdatframe$recordedTime),"%d.%m.%Y"))
exdatframeT
exdatframe2 <- cbind(exdatframe, exdatframeT)
exdatframe2$recordedTime <-NULL
exdatframe2
str(datframe)

library(ggplot2)
ggplot(exdatframe2)+geom_tile(aes(x=exdatframeT,y=Name,fill=knownstate), 
height=0.5)

# Now all I want is:
# 1) a black outline around the bars. Adding colour="black" like I have 
found elsewere on the internet doesn't work
# 2) change the colours: E.g. I want white for NAs. I can't find a 
command to describe my wishes.

#?

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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 -- To UNSUBSCRIBE and more, see
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] data manipulation

2016-12-15 Thread John Kane via R-help
That should read "now" instead of "not"
 

On Thursday, December 15, 2016 6:49 PM, John Kane  
wrote:
 

 It downloaded a file for me earlier but I am not getting the 404 error and I 
did not bother to save the download.  Shrug.
 

On Wednesday, December 14, 2016 6:57 AM, John Kane via R-help 
 wrote:
 

 xx <- read.csv("http://massey.ac.nz/~pscoperwait/ts/cbe.dat;)
gives me something. Since we have no idea of what you are doing I don't know if 
the data has downloaded correctly 

    On Tuesday, December 13, 2016 1:38 PM, Farshad Fathian 
 wrote:
 

 Hi,

 

I couldn't access to data file about PSCoperwait by
http://massey.ac.nz/~pscoperwait/ts/cbe.dat.

 

Looking forward to hearing from you,


    [[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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 -- To UNSUBSCRIBE and more, see
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 -- To UNSUBSCRIBE and more, see
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] data manipulation

2016-12-15 Thread John Kane via R-help
It downloaded a file for me earlier but I am not getting the 404 error and I 
did not bother to save the download.  Shrug.
 

On Wednesday, December 14, 2016 6:57 AM, John Kane via R-help 
 wrote:
 

 xx <- read.csv("http://massey.ac.nz/~pscoperwait/ts/cbe.dat;)
gives me something. Since we have no idea of what you are doing I don't know if 
the data has downloaded correctly 

    On Tuesday, December 13, 2016 1:38 PM, Farshad Fathian 
 wrote:
 

 Hi,

 

I couldn't access to data file about PSCoperwait by
http://massey.ac.nz/~pscoperwait/ts/cbe.dat.

 

Looking forward to hearing from you,


    [[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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 -- To UNSUBSCRIBE and more, see
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 -- To UNSUBSCRIBE and more, see
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 show a plot without overlaying the text on top of the another text?

2016-12-15 Thread Jim Lemon
Hi Marna,
After a bit of experimenting I came up with the following function
that "flags" each point to be labeled an allows the operator to
manually place the label for that point:

placeLabels<-function(x,y,labels,pointer=TRUE,cex=1,labelcol=par("fg"),
 labelbg="white",border=par("fg"),pointercol=par("fg"),
 pch=1,col=1,bg="white",flagcol="red") {

 nlabels<-length(labels)
 if(length(labelcol) < nlabels) labelcol<-rep(labelcol,length.out=nlabels)
 if(length(labelbg) < nlabels) labelbg<-rep(labelbg,length.out=nlabels)
 if(length(border) < nlabels) border<-rep(border,length.out=nlabels)
 if(length(pointercol) < nlabels) pointercol<-rep(pointercol,length.out=nlabels)
 if(length(pch) < nlabels) pch<-rep(pch,length.out=nlabels)
 if(length(col) < nlabels) col<-rep(col,length.out=nlabels)
 if(length(bg) < nlabels) bg<-rep(bg,length.out=nlabels)
 for(i in 1:nlabels) {
  points(x[i],y[i],pch=19,col=flagcol)
  labelxy<-locator(1)
  if(pointer)
   segments(x[i],y[i],labelxy$x,labelxy$y,col=pointercol[i])
  boxed.labels(labelxy$x,labelxy$y,labels[i],
   col=labelcol[i],bg=labelbg[i],border=border[i])
  points(rep(x[i],2),rep(y[i],2),pch=c(19,pch[i]),
   col=c("white",col[i]),bg=c(NA,bg[i]))
 }
}
x<-rnorm(10)
y<-rnorm(10)
plot(x,y)
library(plotrix)
placeLabels(x,y,LETTERS[1:10],flagcol="purple")

Jim


On Wed, Dec 14, 2016 at 10:37 AM, Marna Wagley  wrote:
> Hi R user,
> I have created using metaNMDS (Nonmetirc Multidimensional Scaling, MDS) to
> show species composition but some of the species are concentrated at some
> of the sites so that the name of the species are overlaid and it was
> almost impossible to read the species name in the figure. I was wondering how
> we can show the plot without overlaying the text on top of another.
> I used the following to create the plot. would you mind to suggest me?
>
> comm.bc.mds <- metaMDS(dat, dist = "bray")
> ordiplot(comm.bc.mds, display = "sites", type = "text")
> ordipointlabel(comm.bc.mds,font = c(1, 1), cex = c(0.5, 0.3))
>
> Thanks
>
> MW
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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 -- To UNSUBSCRIBE and more, see
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 show a plot without overlaying the text on top of the another text?

2016-12-15 Thread Greg Snow
Some tools that might help include spread.labels from the plotrix
package, spread.labs from the TeachingDemos package, and
dynIdentify/TkIdentify from the TeachingDemos package.

On Tue, Dec 13, 2016 at 4:37 PM, Marna Wagley  wrote:
> Hi R user,
> I have created using metaNMDS (Nonmetirc Multidimensional Scaling, MDS) to
> show species composition but some of the species are concentrated at some
> of the sites so that the name of the species are overlaid and it was
> almost impossible to read the species name in the figure. I was wondering how
> we can show the plot without overlaying the text on top of another.
> I used the following to create the plot. would you mind to suggest me?
>
> comm.bc.mds <- metaMDS(dat, dist = "bray")
> ordiplot(comm.bc.mds, display = "sites", type = "text")
> ordipointlabel(comm.bc.mds,font = c(1, 1), cex = c(0.5, 0.3))
>
> Thanks
>
> MW
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.



-- 
Gregory (Greg) L. Snow Ph.D.
538...@gmail.com

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Merging two columns of unequal length

2016-12-15 Thread Jim Lemon
Hi Bailey,
I may be misunderstanding what you are doing as I can't work out how
you get unequal column lengths, but this may help:

myval<-matrix(sample(1:365,740,TRUE),ncol=74)
mydata<-as.data.frame(cbind(1950:1959,myval))
lakenames<-paste(rep(LETTERS[1:26],length.out=74),
 rev(rep(letters[1:25],length.out=74)),
 rep(letters[1:24],length.out=74),sep="")
names(mydata)<-c("Year",lakenames)
res<-vector("list",74)
for (i in 1:74){
 thisval<-mydata[,i+1]
 lake.lm<-lm(thisval ~ Year,mydata)
 res[[i]]<-residuals(lake.lm)
}
# this will cause an error with as.data.frame
res[[20]]<-res[[20]][-1]
# pad the short column with NA
res<-lapply(res,function(x,length.out) x[1:length.out],10)
res.df<-as.data.frame(res)
names(res.df)<-lakenames
print(res.df)

Jim


On Tue, Dec 13, 2016 at 10:41 AM, Bailey Hewitt  wrote:
> Dear R Help,
>
>
> I am trying to put together two columns of unequal length in a data frame. 
> Unfortunately, so far I have been unsuccessful in the functions I have tried 
> (such as cbind). The code I am currently using is : (I have highlighted the 
> code that is not working)
>
>
> y<- mydata[,2:75]
>
> year <- mydata$Year
>
> res <- data.frame()
>
> for (i in 1:74){
>
>   y.val <- y[,i]
>
>   lake.lm= lm(y.val ~ year)
>
>   lake.res=residuals(lake.lm)
>
>   new.res <- data.frame(lake.res=lake.res)
>
>   colnames(new.res) <- colnames(y)[i]
>
> #cbind doesn't work because of the unequal lengths of my data columns
>
>   res <- cbind(res, new.res)
>
>   print(res)
>
> }
>
>
> mydata is a csv file with "Year" from 1950 on as my first column and then 
> each proceeding column has a lake name and a day of year (single number) in 
> each row.
>
>
> Please let me know if there is any more information I can provide as I am new 
> to emailing in this list. Thank you for your time!
>
>
> Bailey Hewitt
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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 -- To UNSUBSCRIBE and more, see
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] Need some help with regular expression

2016-12-15 Thread David Winsemius

> On Dec 15, 2016, at 8:46 AM, Steven Nagy  wrote:
> 
> I tried to send this email, but it didn't go through. I guess pictures are
> not allowed to send through HTML formatted emails?
> I'm re-sending it again without the picture, just comment there instead as
> placeholder.
> 
> Thanks,
> Steven
> 
> 
> From: Steven Nagy [mailto:nst...@gmail.com] 
> Sent: Monday, December 12, 2016 10:50 PM
> To: 'Bert Gunter' 
> Cc: 'R-help' 
> Subject: RE: [R] Need some help with regular expression
> 
> Hi Bert and all,
> 
> Sorry I was too busy at work and didn't have much time to continue this
> until now.
> So I studied "?regexp" and I can understand your regular expression now:
> sub(".*: *([[:alnum:]]* *-> *STU|STU *-> *[[:alnum:]]*).*","\\1",x)
> 
> But I also wanted to split up these results in 2 columns, so your previous
> command would give me this result:
> [1] "NMA -> STU" "STU -> REG" "-> STU"
> 
> and I wanted to further split them up to show this:
> From  To
> NMA   STU
> STU   REG
>   STU

So one more step:

> strsplit( sub(".*: *([[:alnum:]]* *-> *STU|STU *-> 
> *[[:alnum:]]*).*","\\1",x), split="-> ")

[[1]]
[1] "NMA " "STU" 

[[2]]
[1] "STU " "REG" 

[[3]]
[1] """STU"

> 
Well, maybe 2:

> sapply(  strsplit( sub(".*: *([[:alnum:]]* *-> *STU|STU *-> 
> *[[:alnum:]]*).*","\\1",x), split="-> "), "[",1 )
[1] "NMA " "STU " ""
> sapply(  strsplit( sub(".*: *([[:alnum:]]* *-> *STU|STU *-> 
> *[[:alnum:]]*).*","\\1",x), split="-> "), "[",2 )
[1] "STU" "REG" "STU"
> 


> I still don’t quite understand the backreferences, and how could I have 2
> backreferences, one for the left side of the “->” sign and one for the right
> side?
> 
> So it seems like I need to apply the “sub” function twice, similar how I
> used the “strapply” function twice in my original post:
> strapply(strapply(a, "(file://w+ -> STU|STU -> file://w+)", c, backref = -1,
> perl = TRUE), "(file://w+) -> (file://w+)", c, backref = -2, perl = TRUE)
> 
> or maybe there would be a more simple way of using only 1 “sub” function and
> 2 backreferences?
> 
> Also I’m not sure what do I do after I get the data? How could I represent
> the member type changes graphically? We need to analyze the behavior of
> switching from STU to another type or from another type to STU.
> Google Analytics has a nice chart under Behavior Flow, or Users Flow, and it
> looks like this:
>  Users Flow showing flows from one category to another one and further to
> another one>
> 
> 
> 
> Is there any graphical representation in R that is similar to this?
> 
> Thanks a lot,
> Steven
> 
> -Original Message-
> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Bert Gunter
> Sent: Sunday, November 20, 2016 10:05 PM
> To: Aliz Csonka 
> Cc: R-help 
> Subject: Re: [R] Need some help with regular expression
> 
> Although others may respond, I think you will do much better studying
> ?regexp, which will answer all your questions. I believe the effort you will
> make figuring it out will pay dividends for your future R/regular expression
> usage that you cannot gain from my direct explanation.
> 
> Good luck.
> 
> Best,
> Bert
> Bert Gunter
> 
> "The trouble with having an open mind is that people keep coming along and
> sticking things into it."
> -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
> 
> 
> On Sun, Nov 20, 2016 at 6:40 PM, Steven Nagy 
> wrote:
>> Thanks a lot Bert. That's amazing. I am very new to both R and regular 
>> expressions. I don't really understand the regular expression that you 
>> used below.
>> And looks like I don't even need any special library, like the 
>> "gsubfn" for the strapply function.
>> I was trying to use the regexr.com website to analyze your regular 
>> expression, but it doesn't seem to match any text there.
>> Can you explain me the regular expression that you used?
>> ".*: *([[:alnum:]]* *-> *STU|STU *-> *[[:alnum:]]*).*"
>> So the dot in the front means any character and the star after that 
>> means that it can repeat 0 or more times, right?
>> Then followed by a colon character ":" and a space, and what is the 
>> next star after that? It means that the sequence before that again can 
>> repeat 0 or more times?
>> And what are the double square brackets?
>> Is ":alnum:" specific to R? I don't think "regexr.com" understands 
>> that. Or maybe that site is for regular expressions in Javascript, and 
>> the syntax is different in R?
>> 
>> Thank you,
>> Steven
>> 
>> -Original Message-
>> From: Bert Gunter [mailto:bgunter.4...@gmail.com]
>> Sent: Sunday, November 20, 2016 2:15 PM
>> To: Steven Nagy 
>> Cc: R-help 
>> Subject: Re: [R] Need some help with regular expression
>> 
>> If I understand you correctly, I think you are making it more complex 
>> than necessary. Using your 

Re: [R] WaveletComp with as.POSIXct Showing Error on Date for: 2000-01-01 Format

2016-12-15 Thread MacQueen, Don
Your code is nearly unreadable, probably because you posted in HTML instead of 
plain text. Plain text is the standard expected on R-help.

The only apparent date/time conversion in your code is the use of as.POSIXct(). 
You are missing a closing quote mark after the date.

If I fix that, then on my system as.POSIXct() succeeds:

> seq(as.POSIXct("2002-01-01"), by = "hour", length.out = 5)
[1] "2002-01-01 00:00:00 PST" "2002-01-01 01:00:00 PST"
[3] "2002-01-01 02:00:00 PST" "2002-01-01 03:00:00 PST"
[5] "2002-01-01 04:00:00 PST"

Your warning (not error) messages refer to an unknown timezone. So check your 
timezone, for example:

> Sys.getenv('TZ')
[1] "US/Pacific"

I hope this helps.
-Don


On 12/13/16, 9:33 AM, "R-help on behalf of Muhammad Anees" 
 wrote:

Dear All,

I tried to find an answer everywhere including stackoverflows and manuals
but there is no specific solution that might have helped. Hence, I am sure
you will bear with me for this first query.

I am trying to replicate production of Wavelet Coherency using the
following codes: I dont know why the two errors/warnings appear and my
resultant figures dont show up the time as I use the format of Date as
2000-01-01

Code used is:

> library(WaveletComp)> x<- API> y<- TFS> my.data = data.frame(x = x, y = 
y)> my.wc = analyze.coherency(my.data, my.pair = c("x","y"),+   
loess.span = 0,+   dt = 1/24, dj = 1/100,+  
 lowerPeriod = 1/2,+   make.pval = 
T, n.sim = 10)> wc.image(my.wc, n.levels = 250,+  siglvl.contour = 0.1, 
siglvl.arrow = 0.05,+  legend.params = list(lab = "cross-wavelet power 
levels"))> wc.image(my.wc, n.levels = 250, color.key = "interval",+  
siglvl.contour = 0.1, siglvl.arrow = 0.05, which.arrow.sig = "wt",+  
legend.params = list(lab = "cross-wavelet power levels"))> wc.image(my.wc, 
which.image = "wc", n.levels = 250,+  siglvl.contour = 0.1, 
siglvl.arrow = 0.05,+  legend.params = list(lab = "wavelet coherence 
levels"))> my.date = seq(as.POSIXct("2002-01-01),+   by = "hour", 
length.out = 24*96)



Warning messages:1: In strptime(xx, f <- "%Y-%m-%d %H:%M:%OS", tz = tz) :
  unknown timezone '%F %T'2: In as.POSIXct.POSIXlt(x) : unknown
timezone '%F %T'3: In strptime(x, f, tz = tz) : unknown timezone '%F
%T'4: In as.POSIXct.POSIXlt(as.POSIXlt(x, tz, ...), tz, ...) :
  unknown timezone '%F %T'




I would be happier to see a suggestion for removing this warning and
get the results as the time axis showing Date as in the data on the
figures of my output from above.

Regards



--
Muhammad Anees
Assistant Professor,
The Econometrician &
Statistical Consultant @
www.aneconomist.com

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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 -- To UNSUBSCRIBE and more, see
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] Need some help with regular expression

2016-12-15 Thread Jeff Newmiller
Actually, the issue of mail formatting is discussed in the Posting Guide, but 
some key points are:

1) Only a very few types of file attachments are allowed.

2) email processed through the mailing list automatically strips HTML, which 
often leaves us looking at something full of wacko characters and with no 
formatting. As the PG says... this is a plain text mailing list... don't send 
HTML email to it. Fortunately R is plain text, so if you focus on short, 
reproducible examples then your meaning will come through just fine. 
-- 
Sent from my phone. Please excuse my brevity.

On December 15, 2016 8:46:55 AM PST, Steven Nagy  wrote:
>I tried to send this email, but it didn't go through. I guess pictures
>are
>not allowed to send through HTML formatted emails?
>I'm re-sending it again without the picture, just comment there instead
>as
>placeholder.
>
>Thanks,
>Steven
>
>
>From: Steven Nagy [mailto:nst...@gmail.com] 
>Sent: Monday, December 12, 2016 10:50 PM
>To: 'Bert Gunter' 
>Cc: 'R-help' 
>Subject: RE: [R] Need some help with regular expression
>
>Hi Bert and all,
>
>Sorry I was too busy at work and didn't have much time to continue this
>until now.
>So I studied "?regexp" and I can understand your regular expression
>now:
>sub(".*: *([[:alnum:]]* *-> *STU|STU *-> *[[:alnum:]]*).*","\\1",x)
>
>But I also wanted to split up these results in 2 columns, so your
>previous
>command would give me this result:
>[1] "NMA -> STU" "STU -> REG" "-> STU"
>
>and I wanted to further split them up to show this:
>From   To
>NMASTU
>STUREG
>   STU
>
>I still don’t quite understand the backreferences, and how could I have
>2
>backreferences, one for the left side of the “->” sign and one for the
>right
>side?
>
>So it seems like I need to apply the “sub” function twice, similar how
>I
>used the “strapply” function twice in my original post:
>strapply(strapply(a, "(file://w+ -> STU|STU -> file://w+)", c, backref
>= -1,
>perl = TRUE), "(file://w+) -> (file://w+)", c, backref = -2, perl =
>TRUE)
>
>or maybe there would be a more simple way of using only 1 “sub”
>function and
>2 backreferences?
>
>Also I’m not sure what do I do after I get the data? How could I
>represent
>the member type changes graphically? We need to analyze the behavior of
>switching from STU to another type or from another type to STU.
>Google Analytics has a nice chart under Behavior Flow, or Users Flow,
>and it
>looks like this:
>Users Flow showing flows from one category to another one and further
>to
>another one>
>
>
>
>Is there any graphical representation in R that is similar to this?
>
>Thanks a lot,
>Steven
>
>-Original Message-
>From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Bert
>Gunter
>Sent: Sunday, November 20, 2016 10:05 PM
>To: Aliz Csonka 
>Cc: R-help 
>Subject: Re: [R] Need some help with regular expression
>
>Although others may respond, I think you will do much better studying
>?regexp, which will answer all your questions. I believe the effort you
>will
>make figuring it out will pay dividends for your future R/regular
>expression
>usage that you cannot gain from my direct explanation.
>
>Good luck.
>
>Best,
>Bert
>Bert Gunter
>
>"The trouble with having an open mind is that people keep coming along
>and
>sticking things into it."
>-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
>
>
>On Sun, Nov 20, 2016 at 6:40 PM, Steven Nagy 
>wrote:
>> Thanks a lot Bert. That's amazing. I am very new to both R and
>regular 
>> expressions. I don't really understand the regular expression that
>you 
>> used below.
>> And looks like I don't even need any special library, like the 
>> "gsubfn" for the strapply function.
>> I was trying to use the regexr.com website to analyze your regular 
>> expression, but it doesn't seem to match any text there.
>> Can you explain me the regular expression that you used?
>> ".*: *([[:alnum:]]* *-> *STU|STU *-> *[[:alnum:]]*).*"
>> So the dot in the front means any character and the star after that 
>> means that it can repeat 0 or more times, right?
>> Then followed by a colon character ":" and a space, and what is the 
>> next star after that? It means that the sequence before that again
>can 
>> repeat 0 or more times?
>> And what are the double square brackets?
>> Is ":alnum:" specific to R? I don't think "regexr.com" understands 
>> that. Or maybe that site is for regular expressions in Javascript,
>and 
>> the syntax is different in R?
>>
>> Thank you,
>> Steven
>>
>> -Original Message-
>> From: Bert Gunter [mailto:bgunter.4...@gmail.com]
>> Sent: Sunday, November 20, 2016 2:15 PM
>> To: Steven Nagy 
>> Cc: R-help 
>> Subject: Re: [R] Need some help with regular expression
>>
>> If I understand you correctly, I think you are making it more 

Re: [R] Need some help with regular expression

2016-12-15 Thread Steven Nagy
I tried to send this email, but it didn't go through. I guess pictures are
not allowed to send through HTML formatted emails?
I'm re-sending it again without the picture, just comment there instead as
placeholder.

Thanks,
Steven


From: Steven Nagy [mailto:nst...@gmail.com] 
Sent: Monday, December 12, 2016 10:50 PM
To: 'Bert Gunter' 
Cc: 'R-help' 
Subject: RE: [R] Need some help with regular expression

Hi Bert and all,

Sorry I was too busy at work and didn't have much time to continue this
until now.
So I studied "?regexp" and I can understand your regular expression now:
sub(".*: *([[:alnum:]]* *-> *STU|STU *-> *[[:alnum:]]*).*","\\1",x)

But I also wanted to split up these results in 2 columns, so your previous
command would give me this result:
[1] "NMA -> STU" "STU -> REG" "-> STU"

and I wanted to further split them up to show this:
FromTo
NMA STU
STU REG
STU

I still don’t quite understand the backreferences, and how could I have 2
backreferences, one for the left side of the “->” sign and one for the right
side?

So it seems like I need to apply the “sub” function twice, similar how I
used the “strapply” function twice in my original post:
strapply(strapply(a, "(file://w+ -> STU|STU -> file://w+)", c, backref = -1,
perl = TRUE), "(file://w+) -> (file://w+)", c, backref = -2, perl = TRUE)

or maybe there would be a more simple way of using only 1 “sub” function and
2 backreferences?

Also I’m not sure what do I do after I get the data? How could I represent
the member type changes graphically? We need to analyze the behavior of
switching from STU to another type or from another type to STU.
Google Analytics has a nice chart under Behavior Flow, or Users Flow, and it
looks like this:




Is there any graphical representation in R that is similar to this?

Thanks a lot,
Steven

-Original Message-
From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Bert Gunter
Sent: Sunday, November 20, 2016 10:05 PM
To: Aliz Csonka 
Cc: R-help 
Subject: Re: [R] Need some help with regular expression

Although others may respond, I think you will do much better studying
?regexp, which will answer all your questions. I believe the effort you will
make figuring it out will pay dividends for your future R/regular expression
usage that you cannot gain from my direct explanation.

Good luck.

Best,
Bert
Bert Gunter

"The trouble with having an open mind is that people keep coming along and
sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )


On Sun, Nov 20, 2016 at 6:40 PM, Steven Nagy 
wrote:
> Thanks a lot Bert. That's amazing. I am very new to both R and regular 
> expressions. I don't really understand the regular expression that you 
> used below.
> And looks like I don't even need any special library, like the 
> "gsubfn" for the strapply function.
> I was trying to use the regexr.com website to analyze your regular 
> expression, but it doesn't seem to match any text there.
> Can you explain me the regular expression that you used?
> ".*: *([[:alnum:]]* *-> *STU|STU *-> *[[:alnum:]]*).*"
> So the dot in the front means any character and the star after that 
> means that it can repeat 0 or more times, right?
> Then followed by a colon character ":" and a space, and what is the 
> next star after that? It means that the sequence before that again can 
> repeat 0 or more times?
> And what are the double square brackets?
> Is ":alnum:" specific to R? I don't think "regexr.com" understands 
> that. Or maybe that site is for regular expressions in Javascript, and 
> the syntax is different in R?
>
> Thank you,
> Steven
>
> -Original Message-
> From: Bert Gunter [mailto:bgunter.4...@gmail.com]
> Sent: Sunday, November 20, 2016 2:15 PM
> To: Steven Nagy 
> Cc: R-help 
> Subject: Re: [R] Need some help with regular expression
>
> If I understand you correctly, I think you are making it more complex 
> than necessary. Using your example (thanks!!), the following should 
> get you
> started:
>
>
>> x<- c("Name.MEMBER_TYPE: NMA -> STU ; CATEGORY:  -> 1 ; CITY:
>> MISSISSAUGA -> Mississauga ; ZIP: L5N1H9 -> L5N 1H9 ; COUNTRY: CAN -> 
>> ; MEMBER_STATUS:  -> N", "Name.MEMBER_TYPE: STU -> REG ; CATEGORY: 1
>> ->","Name.MEMBER_TYPE: -> STU")
>>
>> x
> [1] "Name.MEMBER_TYPE: NMA -> STU ; CATEGORY:  -> 1 ; CITY:
> MISSISSAUGA -> Mississauga ; ZIP: L5N1H9 -> L5N 1H9 ; COUNTRY: CAN -> 
> ;
> MEMBER_STATUS:  -> N"
>
> [2] "Name.MEMBER_TYPE: STU -> REG ; CATEGORY: 1 ->"
> [3] "Name.MEMBER_TYPE: -> STU"
>>
>> sub(".*: *([[:alnum:]]* *-> *STU|STU *-> *[[:alnum:]]*).*","file://1",x)
> [1] "NMA -> STU" "STU -> REG" "-> STU"
>
>
> I am sure that you can get things to the form you desire in one go 
> with some fiddling of the above, but it was easier for me to write the 
> 

Re: [R] Computing growth rate

2016-12-15 Thread Brijesh Mishra
Yes, Mr Hasselman. This works like charm now. I also realise where I
was making an error. Now I have two very good options to choose from.
Spoilt for choices...

Many Many Thanks,

Brijesh

On Thu, Dec 15, 2016 at 7:53 PM, Berend Hasselman  wrote:
>
>> On 15 Dec 2016, at 13:34, Brijesh Mishra  wrote:
>>
>> Dear Mr Hasselman,
>>
>> I missed you mail, while I was typing my own mail as a reply to Mr.
>> Barradas suggestion. In fact, I implemented your suggestion even
>> before reading it. But, I have a concern that I have noted (though its
>> only hypothetical- such a scenario is very unlikely to occur). Is
>> there a way to restrict such calculations co_code1 wise?
>
> Like this?
>
> df2 <- ddply(df1,"co_code1", transform,
> growth=c(NA, ifelse(diff(fyear1)==1, (exp(diff(log(sales1)))-1)*100,NA))
> )
>
>
> But do also look at Petr Pikal's solution. Which of the two solutions you 
> prefer depends on what you want in your special case.
>
> Berend

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Computing growth rate

2016-12-15 Thread Brijesh Mishra
Wow, Mr Petr. The placing of diff(fyear1) was very clever indeed. Just
to understand the steps intended by you-

exp(diff(log(sales1))/diff(fyear1))- 1)
= exp(((log(sales1(t)/sales1(t-1)))/(fyear1(t)-fyear(t-1)))-1)
= exp(log(sales(t)/sales(t-1))^(1/(delta(fyear1-1
= ((sales(t)/(sales(t-1)))^(1/(delta(fyear1)))-1

This gives the CAGR, which saves some precious data-points (in my
dataset, it may prove a big boon). I spent a significant amount of
time today to figure out something like this, which you did so easily.

Many Thanks,

Brijesh

On Thu, Dec 15, 2016 at 7:21 PM, PIKAL Petr  wrote:
> Hi
>
> Maybe you does not need if or ifelse but just divide by years difference.
>
> d2<-ddply(df1,"co_code1",transform, 
> growth=c(NA,exp(diff(log(sales1))/diff(fyear1))- 1)*100)
>
> Cheers
> Petr
>
>> -Original Message-
>> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Berend
>> Hasselman
>> Sent: Thursday, December 15, 2016 1:18 PM
>> To: Brijesh Mishra 
>> Cc: r-help mailing list 
>> Subject: Re: [R] Computing growth rate
>>
>>
>> > On 15 Dec 2016, at 04:40, Brijesh Mishra 
>> wrote:
>> >
>> > Hi,
>> >
>> > I am trying to calculate growth rate (say, sales, though it is to be
>> > computed for many variables) in a panel data set. Problem is that I
>> > have missing data for many firms for many years. To put it simply, I
>> > have created this short dataframe (original df id much bigger)
>> >
>> > df1<-data.frame(co_code1=rep(c(1100, 1200, 1300), each=7),
>> > fyear1=rep(1990:1996, 3), sales1=rep(seq(1000,1600, by=100),3))
>> >
>> > # this gives me
>> > co_code1 fyear1 sales1
>> > 1  1100   1990   1000
>> > 2  1100   1991   1100
>> > 3  1100   1992   1200
>> > 4  1100   1993   1300
>> > 5  1100   1994   1400
>> > 6  1100   1995   1500
>> > 7  1100   1996   1600
>> > 8  1200   1990   1000
>> > 9  1200   1991   1100
>> > 10 1200   1992   1200
>> > 11 1200   1993   1300
>> > 12 1200   1994   1400
>> > 13 1200   1995   1500
>> > 14 1200   1996   1600
>> > 15 1300   1990   1000
>> > 16 1300   1991   1100
>> > 17 1300   1992   1200
>> > 18 1300   1993   1300
>> > 19 1300   1994   1400
>> > 20 1300   1995   1500
>> > 21 1300   1996   1600
>> >
>> > # I am now removing a couple of rows
>> > df1<-df1[-c(5, 8), ]
>> > # the result is
>> >   co_code1 fyear1 sales1
>> > 1  1100   1990   1000
>> > 2  1100   1991   1100
>> > 3  1100   1992   1200
>> > 4  1100   1993   1300
>> > 6  1100   1995   1500
>> > 7  1100   1996   1600
>> > 9  1200   1991   1100
>> > 10 1200   1992   1200
>> > 11 1200   1993   1300
>> > 12 1200   1994   1400
>> > 13 1200   1995   1500
>> > 14 1200   1996   1600
>> > 15 1300   1990   1000
>> > 16 1300   1991   1100
>> > 17 1300   1992   1200
>> > 18 1300   1993   1300
>> > 19 1300   1994   1400
>> > 20 1300   1995   1500
>> > 21 1300   1996   1600
>> > # so 1994 for co_code1 1100 and 1990 for co_code1 1200 have been
>> > removed. If I try,
>> > d<-ddply(df1,"co_code1",transform, growth=c(NA,exp(diff(log(sales1)))-
>> 1)*100)
>> >
>> > # this apparently gives wrong results for the year 1995 (as shown
>> > below) as growth rates are computed considering yearly increment.
>> >
>> >   co_code1 fyear1 sales1growth
>> > 1  1100   1990   1000NA
>> > 2  1100   1991   1100 10.00
>> > 3  1100   1992   1200  9.090909
>> > 4  1100   1993   1300  8.33
>> > 5  1100   1995   1500 15.384615
>> > 6  1100   1996   1600  6.67
>> > 7  1200   1991   1100NA
>> > 8  1200   1992   1200  9.090909
>> > 9  1200   1993   1300  8.33
>> > 10 1200   1994   1400  7.692308
>> > 11 1200   1995   1500  7.142857
>> > 12 1200   1996   1600  6.67
>> > 13 1300   1990   1000NA
>> > 14 1300   1991   1100 10.00
>> > 15 1300   1992   1200  9.090909
>> > 16 1300   1993   1300  8.33
>> > 17 1300   1994   1400  7.692308
>> > 18 1300   1995   1500  7.142857
>> > 19 1300   1996   1600  6.67
>> > # I thought of using the formula only when the increment of fyear1 is
>> > only 1 while in a co_code1, by using this formula
>> >
>> > d<-ddply(df1,
>> > "co_code1",
>> > transform,
>> > if(diff(fyear1)==1){
>> >   growth=(exp(diff(log(df1$sales1)))-1)*100
>> > } else{
>> >   growth=NA
>> > })
>> >
>> > But, this doesn't work. I am getting the following error.
>> >
>> > In if (diff(fyear1) == 1) { :
>> >  the condition has length > 1 and only the first element will be used
>> > (repeated a few times).
>> >
>> > # I have searched for a solution, but somehow couldn't get one. Hope
>> > that some kind soul will guide me here.
>> >
>>
>> In your case use ifelse() as explained by Rui.
>> But it can 

Re: [R] Computing growth rate

2016-12-15 Thread Brijesh Mishra
Dear Mr. Barradas,

Thanks a lot for pointing that. I tried that in a few steps-
1. when I evaluated

d<-ddply(df1,"co_code1",transform, growth <- ifelse(diff(fyear1)==1,
(exp(diff(log(df1$sales1)))-1)*100, NA))

I got the following, i.e., I was not getting the growth column automatically.

co_code1 fyear1 sales1
1  1100   1990   1000
2  1100   1991   1100
3  1100   1992   1200
4  1100   1993   1300
5  1100   1995   1500
6  1100   1996   1600
7  1200   1991   1100
8  1200   1992   1200
9  1200   1993   1300
10 1200   1994   1400
11 1200   1995   1500
12 1200   1996   1600
13 1300   1990   1000
14 1300   1992   1200
15 1300   1993   1300
16 1300   1994   1400
17 1300   1995   1500
18 1300   1996   1600

2. When, just for the heck of it, the assign mark (<-) was changed to
'=' as done previously,

d<-ddply(df1,"co_code1",transform, growth = ifelse(diff(fyear1)==1,
(exp(diff(log(df1$sales1)))-1)*100, NA))

It was no longer evaluated-error was

"Error in data.frame(list(co_code1 = c(1100, 1100, 1100, 1100, 1100, 1100 :
  arguments imply differing number of rows: 6, 5"

3. The following gives the desired result

df1$growth<-c(NA, ifelse(diff(df1$fyear1)==1,
(exp(diff(log(df1$sales1)))-1)*100, NA))

But now I am no longer restricting each iteranation to
'co_code1'-hypothetically if one co_code1 is followed by another with
incremental 'fyear1' difference as 1, growth will be evaluated.

Is there a better and more elegant way of doing it?

Thanks and regards,

Brijesh

On Thu, Dec 15, 2016 at 5:02 PM, Rui Barradas  wrote:
> Hello,
>
> That is a very common mistake. if() accepts only one TRUE/FALSE, for a
> vectorized version you need ?ifelse. Something like the following
> (untested).
>
> growth <- ifelse(diff(fyear1)==1, (exp(diff(log(df1$sales1)))-1)*100, NA)
>
> Hope this helps,
>
> Rui Barradas
>
>
> Em 15-12-2016 03:40, Brijesh Mishra escreveu:
>>
>> Hi,
>>
>> I am trying to calculate growth rate (say, sales, though it is to be
>> computed for many variables) in a panel data set. Problem is that I
>> have missing data for many firms for many years. To put it simply, I
>> have created this short dataframe (original df id much bigger)
>>
>> df1<-data.frame(co_code1=rep(c(1100, 1200, 1300), each=7),
>> fyear1=rep(1990:1996, 3), sales1=rep(seq(1000,1600, by=100),3))
>>
>> # this gives me
>> co_code1 fyear1 sales1
>> 1  1100   1990   1000
>> 2  1100   1991   1100
>> 3  1100   1992   1200
>> 4  1100   1993   1300
>> 5  1100   1994   1400
>> 6  1100   1995   1500
>> 7  1100   1996   1600
>> 8  1200   1990   1000
>> 9  1200   1991   1100
>> 10 1200   1992   1200
>> 11 1200   1993   1300
>> 12 1200   1994   1400
>> 13 1200   1995   1500
>> 14 1200   1996   1600
>> 15 1300   1990   1000
>> 16 1300   1991   1100
>> 17 1300   1992   1200
>> 18 1300   1993   1300
>> 19 1300   1994   1400
>> 20 1300   1995   1500
>> 21 1300   1996   1600
>>
>> # I am now removing a couple of rows
>> df1<-df1[-c(5, 8), ]
>> # the result is
>> co_code1 fyear1 sales1
>> 1  1100   1990   1000
>> 2  1100   1991   1100
>> 3  1100   1992   1200
>> 4  1100   1993   1300
>> 6  1100   1995   1500
>> 7  1100   1996   1600
>> 9  1200   1991   1100
>> 10 1200   1992   1200
>> 11 1200   1993   1300
>> 12 1200   1994   1400
>> 13 1200   1995   1500
>> 14 1200   1996   1600
>> 15 1300   1990   1000
>> 16 1300   1991   1100
>> 17 1300   1992   1200
>> 18 1300   1993   1300
>> 19 1300   1994   1400
>> 20 1300   1995   1500
>> 21 1300   1996   1600
>> # so 1994 for co_code1 1100 and 1990 for co_code1 1200 have been
>> removed. If I try,
>> d<-ddply(df1,"co_code1",transform,
>> growth=c(NA,exp(diff(log(sales1)))-1)*100)
>>
>> # this apparently gives wrong results for the year 1995 (as shown
>> below) as growth rates are computed considering yearly increment.
>>
>> co_code1 fyear1 sales1growth
>> 1  1100   1990   1000NA
>> 2  1100   1991   1100 10.00
>> 3  1100   1992   1200  9.090909
>> 4  1100   1993   1300  8.33
>> 5  1100   1995   1500 15.384615
>> 6  1100   1996   1600  6.67
>> 7  1200   1991   1100NA
>> 8  1200   1992   1200  9.090909
>> 9  1200   1993   1300  8.33
>> 10 1200   1994   1400  7.692308
>> 11 1200   1995   1500  7.142857
>> 12 1200   1996   1600  6.67
>> 13 1300   1990   1000NA
>> 14 1300   1991   1100 10.00
>> 15 1300   1992   1200  9.090909
>> 16 1300   1993   1300  8.33
>> 17 1300   1994   1400  7.692308
>> 18 1300   1995   1500  7.142857
>> 19 1300   1996   1600  6.67
>> # I thought of using the formula only when the increment of fyear1 is
>> only 1 while in a co_code1, by using this formula
>>
>> d<-ddply(df1,
>>   "co_code1",
>> 

[R] [R-pkgs] Announcing XGR

2016-12-15 Thread Hai Fang
Dear R users,

I am happy to announce that the package 'XGR' (Exploring Genomic Relations
available at http://cran.r-project.org/package=XGR) has been on CRAN since
this April. Now it gets published in Genome Medicine (see
http://dx.doi.org/10.1186/s13073-016-0384-y). Together with its web app,
XGR is able to provide a user-friendly tool for exploring genomic relations
at the gene, SNP and genomic region level.

Best regards,

Dr Hai Fang
Wellcome Trust Centre for Human Genetics
University of Oxford
Roosevelt Drive Headington
Oxford OX3 7BN

[[alternative HTML version deleted]]

___
R-packages mailing list
r-packa...@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-packages

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Computing growth rate

2016-12-15 Thread Brijesh Mishra
Dear Mr Hasselman,

I missed you mail, while I was typing my own mail as a reply to Mr.
Barradas suggestion. In fact, I implemented your suggestion even
before reading it. But, I have a concern that I have noted (though its
only hypothetical- such a scenario is very unlikely to occur). Is
there a way to restrict such calculations co_code1 wise?

Many thanks,

Brijesh

On Thu, Dec 15, 2016 at 5:48 PM, Berend Hasselman  wrote:
>
>> On 15 Dec 2016, at 04:40, Brijesh Mishra  wrote:
>>
>> Hi,
>>
>> I am trying to calculate growth rate (say, sales, though it is to be
>> computed for many variables) in a panel data set. Problem is that I
>> have missing data for many firms for many years. To put it simply, I
>> have created this short dataframe (original df id much bigger)
>>
>> df1<-data.frame(co_code1=rep(c(1100, 1200, 1300), each=7),
>> fyear1=rep(1990:1996, 3), sales1=rep(seq(1000,1600, by=100),3))
>>
>> # this gives me
>> co_code1 fyear1 sales1
>> 1  1100   1990   1000
>> 2  1100   1991   1100
>> 3  1100   1992   1200
>> 4  1100   1993   1300
>> 5  1100   1994   1400
>> 6  1100   1995   1500
>> 7  1100   1996   1600
>> 8  1200   1990   1000
>> 9  1200   1991   1100
>> 10 1200   1992   1200
>> 11 1200   1993   1300
>> 12 1200   1994   1400
>> 13 1200   1995   1500
>> 14 1200   1996   1600
>> 15 1300   1990   1000
>> 16 1300   1991   1100
>> 17 1300   1992   1200
>> 18 1300   1993   1300
>> 19 1300   1994   1400
>> 20 1300   1995   1500
>> 21 1300   1996   1600
>>
>> # I am now removing a couple of rows
>> df1<-df1[-c(5, 8), ]
>> # the result is
>>   co_code1 fyear1 sales1
>> 1  1100   1990   1000
>> 2  1100   1991   1100
>> 3  1100   1992   1200
>> 4  1100   1993   1300
>> 6  1100   1995   1500
>> 7  1100   1996   1600
>> 9  1200   1991   1100
>> 10 1200   1992   1200
>> 11 1200   1993   1300
>> 12 1200   1994   1400
>> 13 1200   1995   1500
>> 14 1200   1996   1600
>> 15 1300   1990   1000
>> 16 1300   1991   1100
>> 17 1300   1992   1200
>> 18 1300   1993   1300
>> 19 1300   1994   1400
>> 20 1300   1995   1500
>> 21 1300   1996   1600
>> # so 1994 for co_code1 1100 and 1990 for co_code1 1200 have been
>> removed. If I try,
>> d<-ddply(df1,"co_code1",transform, growth=c(NA,exp(diff(log(sales1)))-1)*100)
>>
>> # this apparently gives wrong results for the year 1995 (as shown
>> below) as growth rates are computed considering yearly increment.
>>
>>   co_code1 fyear1 sales1growth
>> 1  1100   1990   1000NA
>> 2  1100   1991   1100 10.00
>> 3  1100   1992   1200  9.090909
>> 4  1100   1993   1300  8.33
>> 5  1100   1995   1500 15.384615
>> 6  1100   1996   1600  6.67
>> 7  1200   1991   1100NA
>> 8  1200   1992   1200  9.090909
>> 9  1200   1993   1300  8.33
>> 10 1200   1994   1400  7.692308
>> 11 1200   1995   1500  7.142857
>> 12 1200   1996   1600  6.67
>> 13 1300   1990   1000NA
>> 14 1300   1991   1100 10.00
>> 15 1300   1992   1200  9.090909
>> 16 1300   1993   1300  8.33
>> 17 1300   1994   1400  7.692308
>> 18 1300   1995   1500  7.142857
>> 19 1300   1996   1600  6.67
>> # I thought of using the formula only when the increment of fyear1 is
>> only 1 while in a co_code1, by using this formula
>>
>> d<-ddply(df1,
>> "co_code1",
>> transform,
>> if(diff(fyear1)==1){
>>   growth=(exp(diff(log(df1$sales1)))-1)*100
>> } else{
>>   growth=NA
>> })
>>
>> But, this doesn't work. I am getting the following error.
>>
>> In if (diff(fyear1) == 1) { :
>>  the condition has length > 1 and only the first element will be used
>> (repeated a few times).
>>
>> # I have searched for a solution, but somehow couldn't get one. Hope
>> that some kind soul will guide me here.
>>
>
> In your case use ifelse() as explained by Rui.
> But it can be done more easily since the fyear1 and co_code1 are synchronized.
> Add a new column to df1 like this
>
> df1$growth <- c(NA,
>  ifelse(diff(df1$fyear1)==1,
> (exp(diff(log(df1$sales1)))-1)*100,
> NA
> )
> )
>
> and display df1. From your request I cannot determine if this is what you 
> want.
>
> regards,
>
> Berend Hasselman
>

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Computing growth rate

2016-12-15 Thread Brijesh Mishra
This was ensured while using ddply()...

On Thu, Dec 15, 2016 at 6:04 PM, Brijesh Mishra
 wrote:
> Dear Mr Hasselman,
>
> I missed you mail, while I was typing my own mail as a reply to Mr.
> Barradas suggestion. In fact, I implemented your suggestion even
> before reading it. But, I have a concern that I have noted (though its
> only hypothetical- such a scenario is very unlikely to occur). Is
> there a way to restrict such calculations co_code1 wise?
>
> Many thanks,
>
> Brijesh
>
> On Thu, Dec 15, 2016 at 5:48 PM, Berend Hasselman  wrote:
>>
>>> On 15 Dec 2016, at 04:40, Brijesh Mishra  wrote:
>>>
>>> Hi,
>>>
>>> I am trying to calculate growth rate (say, sales, though it is to be
>>> computed for many variables) in a panel data set. Problem is that I
>>> have missing data for many firms for many years. To put it simply, I
>>> have created this short dataframe (original df id much bigger)
>>>
>>> df1<-data.frame(co_code1=rep(c(1100, 1200, 1300), each=7),
>>> fyear1=rep(1990:1996, 3), sales1=rep(seq(1000,1600, by=100),3))
>>>
>>> # this gives me
>>> co_code1 fyear1 sales1
>>> 1  1100   1990   1000
>>> 2  1100   1991   1100
>>> 3  1100   1992   1200
>>> 4  1100   1993   1300
>>> 5  1100   1994   1400
>>> 6  1100   1995   1500
>>> 7  1100   1996   1600
>>> 8  1200   1990   1000
>>> 9  1200   1991   1100
>>> 10 1200   1992   1200
>>> 11 1200   1993   1300
>>> 12 1200   1994   1400
>>> 13 1200   1995   1500
>>> 14 1200   1996   1600
>>> 15 1300   1990   1000
>>> 16 1300   1991   1100
>>> 17 1300   1992   1200
>>> 18 1300   1993   1300
>>> 19 1300   1994   1400
>>> 20 1300   1995   1500
>>> 21 1300   1996   1600
>>>
>>> # I am now removing a couple of rows
>>> df1<-df1[-c(5, 8), ]
>>> # the result is
>>>   co_code1 fyear1 sales1
>>> 1  1100   1990   1000
>>> 2  1100   1991   1100
>>> 3  1100   1992   1200
>>> 4  1100   1993   1300
>>> 6  1100   1995   1500
>>> 7  1100   1996   1600
>>> 9  1200   1991   1100
>>> 10 1200   1992   1200
>>> 11 1200   1993   1300
>>> 12 1200   1994   1400
>>> 13 1200   1995   1500
>>> 14 1200   1996   1600
>>> 15 1300   1990   1000
>>> 16 1300   1991   1100
>>> 17 1300   1992   1200
>>> 18 1300   1993   1300
>>> 19 1300   1994   1400
>>> 20 1300   1995   1500
>>> 21 1300   1996   1600
>>> # so 1994 for co_code1 1100 and 1990 for co_code1 1200 have been
>>> removed. If I try,
>>> d<-ddply(df1,"co_code1",transform, 
>>> growth=c(NA,exp(diff(log(sales1)))-1)*100)
>>>
>>> # this apparently gives wrong results for the year 1995 (as shown
>>> below) as growth rates are computed considering yearly increment.
>>>
>>>   co_code1 fyear1 sales1growth
>>> 1  1100   1990   1000NA
>>> 2  1100   1991   1100 10.00
>>> 3  1100   1992   1200  9.090909
>>> 4  1100   1993   1300  8.33
>>> 5  1100   1995   1500 15.384615
>>> 6  1100   1996   1600  6.67
>>> 7  1200   1991   1100NA
>>> 8  1200   1992   1200  9.090909
>>> 9  1200   1993   1300  8.33
>>> 10 1200   1994   1400  7.692308
>>> 11 1200   1995   1500  7.142857
>>> 12 1200   1996   1600  6.67
>>> 13 1300   1990   1000NA
>>> 14 1300   1991   1100 10.00
>>> 15 1300   1992   1200  9.090909
>>> 16 1300   1993   1300  8.33
>>> 17 1300   1994   1400  7.692308
>>> 18 1300   1995   1500  7.142857
>>> 19 1300   1996   1600  6.67
>>> # I thought of using the formula only when the increment of fyear1 is
>>> only 1 while in a co_code1, by using this formula
>>>
>>> d<-ddply(df1,
>>> "co_code1",
>>> transform,
>>> if(diff(fyear1)==1){
>>>   growth=(exp(diff(log(df1$sales1)))-1)*100
>>> } else{
>>>   growth=NA
>>> })
>>>
>>> But, this doesn't work. I am getting the following error.
>>>
>>> In if (diff(fyear1) == 1) { :
>>>  the condition has length > 1 and only the first element will be used
>>> (repeated a few times).
>>>
>>> # I have searched for a solution, but somehow couldn't get one. Hope
>>> that some kind soul will guide me here.
>>>
>>
>> In your case use ifelse() as explained by Rui.
>> But it can be done more easily since the fyear1 and co_code1 are 
>> synchronized.
>> Add a new column to df1 like this
>>
>> df1$growth <- c(NA,
>>  ifelse(diff(df1$fyear1)==1,
>> (exp(diff(log(df1$sales1)))-1)*100,
>> NA
>> )
>> )
>>
>> and display df1. From your request I cannot determine if this is what you 
>> want.
>>
>> regards,
>>
>> Berend Hasselman
>>

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide 

Re: [R] Computing growth rate

2016-12-15 Thread David Stevens
Berend - Unless you need the change in sales year by year, you might 
consider looking at each company's sales over the years and use 
regression or other type of trend analysis to get an overall trend... 
Or, if not, simply divide diff(sales) by diff(fyear1) for each company 
so at least you get the average over the missing years.


David


On 12/15/2016 7:18 AM, Berend Hasselman wrote:

On 15 Dec 2016, at 04:40, Brijesh Mishra  wrote:

Hi,

I am trying to calculate growth rate (say, sales, though it is to be
computed for many variables) in a panel data set. Problem is that I
have missing data for many firms for many years. To put it simply, I
have created this short dataframe (original df id much bigger)

df1<-data.frame(co_code1=rep(c(1100, 1200, 1300), each=7),
fyear1=rep(1990:1996, 3), sales1=rep(seq(1000,1600, by=100),3))

# this gives me
co_code1 fyear1 sales1
1  1100   1990   1000
2  1100   1991   1100
3  1100   1992   1200
4  1100   1993   1300
5  1100   1994   1400
6  1100   1995   1500
7  1100   1996   1600
8  1200   1990   1000
9  1200   1991   1100
10 1200   1992   1200
11 1200   1993   1300
12 1200   1994   1400
13 1200   1995   1500
14 1200   1996   1600
15 1300   1990   1000
16 1300   1991   1100
17 1300   1992   1200
18 1300   1993   1300
19 1300   1994   1400
20 1300   1995   1500
21 1300   1996   1600

# I am now removing a couple of rows
df1<-df1[-c(5, 8), ]
# the result is
   co_code1 fyear1 sales1
1  1100   1990   1000
2  1100   1991   1100
3  1100   1992   1200
4  1100   1993   1300
6  1100   1995   1500
7  1100   1996   1600
9  1200   1991   1100
10 1200   1992   1200
11 1200   1993   1300
12 1200   1994   1400
13 1200   1995   1500
14 1200   1996   1600
15 1300   1990   1000
16 1300   1991   1100
17 1300   1992   1200
18 1300   1993   1300
19 1300   1994   1400
20 1300   1995   1500
21 1300   1996   1600
# so 1994 for co_code1 1100 and 1990 for co_code1 1200 have been
removed. If I try,
d<-ddply(df1,"co_code1",transform, growth=c(NA,exp(diff(log(sales1)))-1)*100)

# this apparently gives wrong results for the year 1995 (as shown
below) as growth rates are computed considering yearly increment.

   co_code1 fyear1 sales1growth
1  1100   1990   1000NA
2  1100   1991   1100 10.00
3  1100   1992   1200  9.090909
4  1100   1993   1300  8.33
5  1100   1995   1500 15.384615
6  1100   1996   1600  6.67
7  1200   1991   1100NA
8  1200   1992   1200  9.090909
9  1200   1993   1300  8.33
10 1200   1994   1400  7.692308
11 1200   1995   1500  7.142857
12 1200   1996   1600  6.67
13 1300   1990   1000NA
14 1300   1991   1100 10.00
15 1300   1992   1200  9.090909
16 1300   1993   1300  8.33
17 1300   1994   1400  7.692308
18 1300   1995   1500  7.142857
19 1300   1996   1600  6.67
# I thought of using the formula only when the increment of fyear1 is
only 1 while in a co_code1, by using this formula

d<-ddply(df1,
 "co_code1",
 transform,
 if(diff(fyear1)==1){
   growth=(exp(diff(log(df1$sales1)))-1)*100
 } else{
   growth=NA
 })

But, this doesn't work. I am getting the following error.

In if (diff(fyear1) == 1) { :
  the condition has length > 1 and only the first element will be used
(repeated a few times).

# I have searched for a solution, but somehow couldn't get one. Hope
that some kind soul will guide me here.


In your case use ifelse() as explained by Rui.
But it can be done more easily since the fyear1 and co_code1 are synchronized.
Add a new column to df1 like this

df1$growth <- c(NA,
  ifelse(diff(df1$fyear1)==1,
 (exp(diff(log(df1$sales1)))-1)*100,
 NA
 )
 )

and display df1. From your request I cannot determine if this is what you want.

regards,

Berend Hasselman

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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 K Stevens, P.E., Ph.D.
Professor and Head, Environmental Engineering
Civil and Environmental Engineering
Utah Water Research Laboratory
8200 Old Main Hill
Logan, UT  84322-8200
435 797 3229 - voice
435 797 1363 - fax
david.stev...@usu.edu

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Computing growth rate

2016-12-15 Thread Berend Hasselman

> On 15 Dec 2016, at 13:34, Brijesh Mishra  wrote:
> 
> Dear Mr Hasselman,
> 
> I missed you mail, while I was typing my own mail as a reply to Mr.
> Barradas suggestion. In fact, I implemented your suggestion even
> before reading it. But, I have a concern that I have noted (though its
> only hypothetical- such a scenario is very unlikely to occur). Is
> there a way to restrict such calculations co_code1 wise?

Like this?

df2 <- ddply(df1,"co_code1", transform,
growth=c(NA, ifelse(diff(fyear1)==1, (exp(diff(log(sales1)))-1)*100,NA))
)


But do also look at Petr Pikal's solution. Which of the two solutions you 
prefer depends on what you want in your special case.

Berend
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Computing growth rate

2016-12-15 Thread PIKAL Petr
Hi

Maybe you does not need if or ifelse but just divide by years difference.

d2<-ddply(df1,"co_code1",transform, 
growth=c(NA,exp(diff(log(sales1))/diff(fyear1))- 1)*100)

Cheers
Petr

> -Original Message-
> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Berend
> Hasselman
> Sent: Thursday, December 15, 2016 1:18 PM
> To: Brijesh Mishra 
> Cc: r-help mailing list 
> Subject: Re: [R] Computing growth rate
>
>
> > On 15 Dec 2016, at 04:40, Brijesh Mishra 
> wrote:
> >
> > Hi,
> >
> > I am trying to calculate growth rate (say, sales, though it is to be
> > computed for many variables) in a panel data set. Problem is that I
> > have missing data for many firms for many years. To put it simply, I
> > have created this short dataframe (original df id much bigger)
> >
> > df1<-data.frame(co_code1=rep(c(1100, 1200, 1300), each=7),
> > fyear1=rep(1990:1996, 3), sales1=rep(seq(1000,1600, by=100),3))
> >
> > # this gives me
> > co_code1 fyear1 sales1
> > 1  1100   1990   1000
> > 2  1100   1991   1100
> > 3  1100   1992   1200
> > 4  1100   1993   1300
> > 5  1100   1994   1400
> > 6  1100   1995   1500
> > 7  1100   1996   1600
> > 8  1200   1990   1000
> > 9  1200   1991   1100
> > 10 1200   1992   1200
> > 11 1200   1993   1300
> > 12 1200   1994   1400
> > 13 1200   1995   1500
> > 14 1200   1996   1600
> > 15 1300   1990   1000
> > 16 1300   1991   1100
> > 17 1300   1992   1200
> > 18 1300   1993   1300
> > 19 1300   1994   1400
> > 20 1300   1995   1500
> > 21 1300   1996   1600
> >
> > # I am now removing a couple of rows
> > df1<-df1[-c(5, 8), ]
> > # the result is
> >   co_code1 fyear1 sales1
> > 1  1100   1990   1000
> > 2  1100   1991   1100
> > 3  1100   1992   1200
> > 4  1100   1993   1300
> > 6  1100   1995   1500
> > 7  1100   1996   1600
> > 9  1200   1991   1100
> > 10 1200   1992   1200
> > 11 1200   1993   1300
> > 12 1200   1994   1400
> > 13 1200   1995   1500
> > 14 1200   1996   1600
> > 15 1300   1990   1000
> > 16 1300   1991   1100
> > 17 1300   1992   1200
> > 18 1300   1993   1300
> > 19 1300   1994   1400
> > 20 1300   1995   1500
> > 21 1300   1996   1600
> > # so 1994 for co_code1 1100 and 1990 for co_code1 1200 have been
> > removed. If I try,
> > d<-ddply(df1,"co_code1",transform, growth=c(NA,exp(diff(log(sales1)))-
> 1)*100)
> >
> > # this apparently gives wrong results for the year 1995 (as shown
> > below) as growth rates are computed considering yearly increment.
> >
> >   co_code1 fyear1 sales1growth
> > 1  1100   1990   1000NA
> > 2  1100   1991   1100 10.00
> > 3  1100   1992   1200  9.090909
> > 4  1100   1993   1300  8.33
> > 5  1100   1995   1500 15.384615
> > 6  1100   1996   1600  6.67
> > 7  1200   1991   1100NA
> > 8  1200   1992   1200  9.090909
> > 9  1200   1993   1300  8.33
> > 10 1200   1994   1400  7.692308
> > 11 1200   1995   1500  7.142857
> > 12 1200   1996   1600  6.67
> > 13 1300   1990   1000NA
> > 14 1300   1991   1100 10.00
> > 15 1300   1992   1200  9.090909
> > 16 1300   1993   1300  8.33
> > 17 1300   1994   1400  7.692308
> > 18 1300   1995   1500  7.142857
> > 19 1300   1996   1600  6.67
> > # I thought of using the formula only when the increment of fyear1 is
> > only 1 while in a co_code1, by using this formula
> >
> > d<-ddply(df1,
> > "co_code1",
> > transform,
> > if(diff(fyear1)==1){
> >   growth=(exp(diff(log(df1$sales1)))-1)*100
> > } else{
> >   growth=NA
> > })
> >
> > But, this doesn't work. I am getting the following error.
> >
> > In if (diff(fyear1) == 1) { :
> >  the condition has length > 1 and only the first element will be used
> > (repeated a few times).
> >
> > # I have searched for a solution, but somehow couldn't get one. Hope
> > that some kind soul will guide me here.
> >
>
> In your case use ifelse() as explained by Rui.
> But it can be done more easily since the fyear1 and co_code1 are
> synchronized.
> Add a new column to df1 like this
>
> df1$growth <- c(NA,
>  ifelse(diff(df1$fyear1)==1,
> (exp(diff(log(df1$sales1)))-1)*100,
> NA
> )
> )
>
> and display df1. From your request I cannot determine if this is what you
> want.
>
> regards,
>
> Berend Hasselman
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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] Computing growth rate

2016-12-15 Thread Berend Hasselman

> On 15 Dec 2016, at 04:40, Brijesh Mishra  wrote:
> 
> Hi,
> 
> I am trying to calculate growth rate (say, sales, though it is to be
> computed for many variables) in a panel data set. Problem is that I
> have missing data for many firms for many years. To put it simply, I
> have created this short dataframe (original df id much bigger)
> 
> df1<-data.frame(co_code1=rep(c(1100, 1200, 1300), each=7),
> fyear1=rep(1990:1996, 3), sales1=rep(seq(1000,1600, by=100),3))
> 
> # this gives me
> co_code1 fyear1 sales1
> 1  1100   1990   1000
> 2  1100   1991   1100
> 3  1100   1992   1200
> 4  1100   1993   1300
> 5  1100   1994   1400
> 6  1100   1995   1500
> 7  1100   1996   1600
> 8  1200   1990   1000
> 9  1200   1991   1100
> 10 1200   1992   1200
> 11 1200   1993   1300
> 12 1200   1994   1400
> 13 1200   1995   1500
> 14 1200   1996   1600
> 15 1300   1990   1000
> 16 1300   1991   1100
> 17 1300   1992   1200
> 18 1300   1993   1300
> 19 1300   1994   1400
> 20 1300   1995   1500
> 21 1300   1996   1600
> 
> # I am now removing a couple of rows
> df1<-df1[-c(5, 8), ]
> # the result is
>   co_code1 fyear1 sales1
> 1  1100   1990   1000
> 2  1100   1991   1100
> 3  1100   1992   1200
> 4  1100   1993   1300
> 6  1100   1995   1500
> 7  1100   1996   1600
> 9  1200   1991   1100
> 10 1200   1992   1200
> 11 1200   1993   1300
> 12 1200   1994   1400
> 13 1200   1995   1500
> 14 1200   1996   1600
> 15 1300   1990   1000
> 16 1300   1991   1100
> 17 1300   1992   1200
> 18 1300   1993   1300
> 19 1300   1994   1400
> 20 1300   1995   1500
> 21 1300   1996   1600
> # so 1994 for co_code1 1100 and 1990 for co_code1 1200 have been
> removed. If I try,
> d<-ddply(df1,"co_code1",transform, growth=c(NA,exp(diff(log(sales1)))-1)*100)
> 
> # this apparently gives wrong results for the year 1995 (as shown
> below) as growth rates are computed considering yearly increment.
> 
>   co_code1 fyear1 sales1growth
> 1  1100   1990   1000NA
> 2  1100   1991   1100 10.00
> 3  1100   1992   1200  9.090909
> 4  1100   1993   1300  8.33
> 5  1100   1995   1500 15.384615
> 6  1100   1996   1600  6.67
> 7  1200   1991   1100NA
> 8  1200   1992   1200  9.090909
> 9  1200   1993   1300  8.33
> 10 1200   1994   1400  7.692308
> 11 1200   1995   1500  7.142857
> 12 1200   1996   1600  6.67
> 13 1300   1990   1000NA
> 14 1300   1991   1100 10.00
> 15 1300   1992   1200  9.090909
> 16 1300   1993   1300  8.33
> 17 1300   1994   1400  7.692308
> 18 1300   1995   1500  7.142857
> 19 1300   1996   1600  6.67
> # I thought of using the formula only when the increment of fyear1 is
> only 1 while in a co_code1, by using this formula
> 
> d<-ddply(df1,
> "co_code1",
> transform,
> if(diff(fyear1)==1){
>   growth=(exp(diff(log(df1$sales1)))-1)*100
> } else{
>   growth=NA
> })
> 
> But, this doesn't work. I am getting the following error.
> 
> In if (diff(fyear1) == 1) { :
>  the condition has length > 1 and only the first element will be used
> (repeated a few times).
> 
> # I have searched for a solution, but somehow couldn't get one. Hope
> that some kind soul will guide me here.
> 

In your case use ifelse() as explained by Rui. 
But it can be done more easily since the fyear1 and co_code1 are synchronized.
Add a new column to df1 like this

df1$growth <- c(NA,
 ifelse(diff(df1$fyear1)==1,
(exp(diff(log(df1$sales1)))-1)*100,
NA
)
)

and display df1. From your request I cannot determine if this is what you want.

regards,

Berend Hasselman

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] R studio Problem

2016-12-15 Thread Amelia Marsh via R-help
Dear Mr Martin,

Thanks a lot for this much needed insight. Unfortunately even though my system 
admin has uninstalled McAfee from my laptop, however, the same problem still 
exists. After uninstalling MCafee, I have reinstalled Rstudio but of no use. As 
Mr Gunter has suggested, trying to take this issue with RStudio people too.

I have started using R again.

Regards and thanks again

Amelia



On Thursday, 15 December 2016 2:43 PM, Martin Maechler 
 wrote:
> Amelia Marsh via R-help 
> on Thu, 15 Dec 2016 08:05:44 + writes:

> Sorry Mr Gunter. I didn't realize it.
> Regards

> Amelia

In this case, however, it was only the 'Subject' of Amelia's
posting and her own "feeling about" the problem which were
wrong:

As K. Elo's helpful reply suggests, it most probably 
is indeed an *R* problem, not an RStudio one:

Excursion (HW, do listen!):  A very efficient and easy way to _search_
all the R mailing lists @R-project.org, i.e., including
R-help (and R-devel, R-packages, R-package-devel, R-SIG-Mac, ...) is
by knowing/noticing that

  a) the website of all these lists are
at  https://stat.ethz.ch/mailman/listinfo/
and (consequently) all the list __archives__ are at
  https://stat.ethz.ch/pipermail/

  b) the (somewhat) advanced, but not known well enough,
 Google search feature  'site:' 

In this case (because it has been on R-help in the past),
consequently a very efficient search to solve this problem is to
enter this into Google
site:stat.ethz.ch normalizePath McAfee
~
(or click here to "learn it":
https://lmgtfy.com/?q=site%3Astat.ethz.ch+normalizePath+McAfee)

which finds this as a first hit  
https://stat.ethz.ch/pipermail/r-help/2010-September/252217.html
which used to be the solution of the problem (and K.Elo's URL was to the
infamous Nabble version of R-help).

---

It is very said to notice that more and more users of R (and
Rtudio) and it seems even *instructors* are thinking they use
RStudio when they are primarily using R via RStudio... and their
credits are going to RStudio only instead of to R, the R
foundation and its not-unimportant subset, the R core team,
plus the 1000s of package authors and bug report / patches
contributing volunteers around the world.

--> Please spread the word: It is __R__ (and RStudio),  not the
other way around.





> On Thursday, 15 December 2016 12:39 PM, Bert Gunter 
 wrote:
> You may get a reply here, but this is the wrong place for you to post.
> RStudio is a separate commercial entity and product from the
> noncommercial R foundation and R software that runs this list. This
> list is about R programming; for questions about RStudio, you should
> consult the RStudio website and post to their support lists.

> Cheers,
> Bert


> Bert Gunter

> "The trouble with having an open mind is that people keep coming along
> and sticking things into it."
> -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )



> On Wed, Dec 14, 2016 at 10:18 PM, Amelia Marsh via R-help
>  wrote:
>> Hi
>> 
>> I had installed R studio Desktop 1.0.44. However whenever I wanted to 
write any command, before I could complete, I was getting following error
>> 
>> Error in normalizePath(dir, winslash = "/", mustWork = TRUE) :
>> unused argument(s) (winslash = "/", mustWork = TRUE)
>> 
>> 
>> I had uninstalled RStudio and again downloaded it and reinstalled. But 
still I am getting error like as mentioned below -
>> 
>> 
>>> a = 40
>> 
>>> b = 45
>> Error in normalizePath(dir, winslash = "/", mustWork = TRUE) :
>> unused argument(s) (winslash = "/", mustWork = TRUE)
>>> c = 120
>> Error in normalizePath(dir, winslash = "/", mustWork = TRUE) :
>> unused argument(s) (winslash = "/", mustWork = TRUE)
>> Error in normalizePath(dir, winslash = "/", mustWork = TRUE) :
>> unused argument(s) (winslash = "/", mustWork = TRUE)
>> Error in normalizePath(dir, winslash = "/", mustWork = TRUE) :
>> unused argument(s) (winslash = "/", mustWork = TRUE)
>> Error in normalizePath(dir, winslash = "/", mustWork = TRUE) :
>> unused argument(s) (winslash = "/", mustWork = TRUE)
>> Error in normalizePath(dir, winslash = "/", mustWork = TRUE) :
>> unused argument(s) (winslash = "/", mustWork = TRUE)
>> 
>> 
>> I had assigned value 40 to a, value 45 to b, but when I tried to assign 
value 120 to c, before I could complete, it started throwing above messages. I 
tried rnorm etc, however the error keeps on reappearing.
>> 
>> 
>> Can someone guide me.
>> 
>> Regards
>> 
>> Amelais
>> 
>> __
>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> 

Re: [R] Computing growth rate

2016-12-15 Thread Rui Barradas

Hello,

That is a very common mistake. if() accepts only one TRUE/FALSE, for a 
vectorized version you need ?ifelse. Something like the following 
(untested).


growth <- ifelse(diff(fyear1)==1, (exp(diff(log(df1$sales1)))-1)*100, NA)

Hope this helps,

Rui Barradas

Em 15-12-2016 03:40, Brijesh Mishra escreveu:

Hi,

I am trying to calculate growth rate (say, sales, though it is to be
computed for many variables) in a panel data set. Problem is that I
have missing data for many firms for many years. To put it simply, I
have created this short dataframe (original df id much bigger)

df1<-data.frame(co_code1=rep(c(1100, 1200, 1300), each=7),
fyear1=rep(1990:1996, 3), sales1=rep(seq(1000,1600, by=100),3))

# this gives me
co_code1 fyear1 sales1
1  1100   1990   1000
2  1100   1991   1100
3  1100   1992   1200
4  1100   1993   1300
5  1100   1994   1400
6  1100   1995   1500
7  1100   1996   1600
8  1200   1990   1000
9  1200   1991   1100
10 1200   1992   1200
11 1200   1993   1300
12 1200   1994   1400
13 1200   1995   1500
14 1200   1996   1600
15 1300   1990   1000
16 1300   1991   1100
17 1300   1992   1200
18 1300   1993   1300
19 1300   1994   1400
20 1300   1995   1500
21 1300   1996   1600

# I am now removing a couple of rows
df1<-df1[-c(5, 8), ]
# the result is
co_code1 fyear1 sales1
1  1100   1990   1000
2  1100   1991   1100
3  1100   1992   1200
4  1100   1993   1300
6  1100   1995   1500
7  1100   1996   1600
9  1200   1991   1100
10 1200   1992   1200
11 1200   1993   1300
12 1200   1994   1400
13 1200   1995   1500
14 1200   1996   1600
15 1300   1990   1000
16 1300   1991   1100
17 1300   1992   1200
18 1300   1993   1300
19 1300   1994   1400
20 1300   1995   1500
21 1300   1996   1600
# so 1994 for co_code1 1100 and 1990 for co_code1 1200 have been
removed. If I try,
d<-ddply(df1,"co_code1",transform, growth=c(NA,exp(diff(log(sales1)))-1)*100)

# this apparently gives wrong results for the year 1995 (as shown
below) as growth rates are computed considering yearly increment.

co_code1 fyear1 sales1growth
1  1100   1990   1000NA
2  1100   1991   1100 10.00
3  1100   1992   1200  9.090909
4  1100   1993   1300  8.33
5  1100   1995   1500 15.384615
6  1100   1996   1600  6.67
7  1200   1991   1100NA
8  1200   1992   1200  9.090909
9  1200   1993   1300  8.33
10 1200   1994   1400  7.692308
11 1200   1995   1500  7.142857
12 1200   1996   1600  6.67
13 1300   1990   1000NA
14 1300   1991   1100 10.00
15 1300   1992   1200  9.090909
16 1300   1993   1300  8.33
17 1300   1994   1400  7.692308
18 1300   1995   1500  7.142857
19 1300   1996   1600  6.67
# I thought of using the formula only when the increment of fyear1 is
only 1 while in a co_code1, by using this formula

d<-ddply(df1,
  "co_code1",
  transform,
  if(diff(fyear1)==1){
growth=(exp(diff(log(df1$sales1)))-1)*100
  } else{
growth=NA
  })

But, this doesn't work. I am getting the following error.

In if (diff(fyear1) == 1) { :
   the condition has length > 1 and only the first element will be used
(repeated a few times).

# I have searched for a solution, but somehow couldn't get one. Hope
that some kind soul will guide me here.

Regards,

Brijesh K Mishra
Indian Institute of Management, Indore
India

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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 -- To UNSUBSCRIBE and more, see
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] ggplot aestetics: beginner question - I am lost in endless possibilites

2016-12-15 Thread Thierry Onkelinx
Here is a solution

ggplot(exdatframe2) +
  geom_tile(aes(x = exdatframeT, y = Name, fill = knownstate), colour =
"black", height = 0.5) +
  scale_fill_discrete(na.value = "white")

Best regards,

ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature and
Forest
team Biometrie & Kwaliteitszorg / team Biometrics & Quality Assurance
Kliniekstraat 25
1070 Anderlecht
Belgium

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to say
what the experiment died of. ~ Sir Ronald Aylmer Fisher
The plural of anecdote is not data. ~ Roger Brinner
The combination of some data and an aching desire for an answer does not
ensure that a reasonable answer can be extracted from a given body of data.
~ John Tukey

2016-12-15 10:22 GMT+01:00 Dagmar :

> # Dear all,
> # I hope someone can help me with this. I am so lost and can't find a
> solution even though I spent hours on searching for a solution of that tiny
> problem.
> # Maybe someone of you could give me hint?
> #This is my string:
> exdatframe <- data.frame(Name=c("Ernie","Ernie","Ernie",
> "Leon","Leon","Leon"),
>   recordedTime=c("03.01.2011","04.01.2011","05.01.2011",
> "04.01.2011","05.01.2011","06.01.2011"),
>knownstate =c("breeding","moulting","moulting",
>  "breeding","breeding",NA))
> exdatframe
>
> exdatframeT <- as.POSIXct (strptime(as.character(exdatfr
> ame$recordedTime),"%d.%m.%Y"))
> exdatframeT
> exdatframe2 <- cbind(exdatframe, exdatframeT)
> exdatframe2$recordedTime <-NULL
> exdatframe2
> str(datframe)
>
> library(ggplot2)
> ggplot(exdatframe2)+geom_tile(aes(x=exdatframeT,y=Name,fill=knownstate),
> height=0.5)
>
> # Now all I want is:
> # 1) a black outline around the bars. Adding colour="black" like I have
> found elsewere on the internet doesn't work
> # 2) change the colours: E.g. I want white for NAs. I can't find a command
> to describe my wishes.
>
> #?
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posti
> ng-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] problem installing Rmpi

2016-12-15 Thread Erin Hodgess
At the risk of sounding simplistic, do you have MPI installed, please?

On Thu, Dec 15, 2016 at 2:08 AM, Jim Maas  wrote:

> Can anyone tell me to start looking to fix this, when attempting to install
> Rmpi on Ubuntu 16.04, just updated R version to 3.3.2
>
>
> ** building package indices
> ** testing if installed package can be loaded
> Error in system2(file.path(R.home("bin"), "R"), c(if (nzchar(arch))
> paste0("--arch=",  :
>   error in running command
> * removing ‘/usr/local/lib/R/site-library/Rmpi’
>
> ​Thanks, J​
>
> --
> Jim Maas
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.




-- 
Erin Hodgess
Associate Professor
Department of Mathematical and Statistics
University of Houston - Downtown
mailto: erinm.hodg...@gmail.com

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] ggplot aestetics: beginner question - I am lost in endless possibilites

2016-12-15 Thread Dagmar

# Dear all,
# I hope someone can help me with this. I am so lost and can't find a 
solution even though I spent hours on searching for a solution of that 
tiny problem.

# Maybe someone of you could give me hint?
#This is my string:
exdatframe <- data.frame(Name=c("Ernie","Ernie","Ernie", 
"Leon","Leon","Leon"),

  recordedTime=c("03.01.2011","04.01.2011","05.01.2011",
"04.01.2011","05.01.2011","06.01.2011"),
   knownstate =c("breeding","moulting","moulting",
 "breeding","breeding",NA))
exdatframe

exdatframeT <- as.POSIXct 
(strptime(as.character(exdatframe$recordedTime),"%d.%m.%Y"))

exdatframeT
exdatframe2 <- cbind(exdatframe, exdatframeT)
exdatframe2$recordedTime <-NULL
exdatframe2
str(datframe)

library(ggplot2)
ggplot(exdatframe2)+geom_tile(aes(x=exdatframeT,y=Name,fill=knownstate), 
height=0.5)


# Now all I want is:
# 1) a black outline around the bars. Adding colour="black" like I have 
found elsewere on the internet doesn't work
# 2) change the colours: E.g. I want white for NAs. I can't find a 
command to describe my wishes.


#?

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] R studio Problem

2016-12-15 Thread Martin Maechler
> Amelia Marsh via R-help 
> on Thu, 15 Dec 2016 08:05:44 + writes:

> Sorry Mr Gunter. I didn't realize it.
> Regards

> Amelia

In this case, however, it was only the 'Subject' of Amelia's
posting and her own "feeling about" the problem which were
wrong:

As K. Elo's helpful reply suggests, it most probably 
is indeed an *R* problem, not an RStudio one:

Excursion (HW, do listen!):  A very efficient and easy way to _search_
 all the R mailing lists @R-project.org, i.e., including
 R-help (and R-devel, R-packages, R-package-devel, R-SIG-Mac, ...) is
by knowing/noticing that

  a) the website of all these lists are
at  https://stat.ethz.ch/mailman/listinfo/
and (consequently) all the list __archives__ are at
  https://stat.ethz.ch/pipermail/

  b) the (somewhat) advanced, but not known well enough,
 Google search feature  'site:' 

In this case (because it has been on R-help in the past),
consequently a very efficient search to solve this problem is to
enter this into Google
 site:stat.ethz.ch normalizePath McAfee
 ~
(or click here to "learn it":
 https://lmgtfy.com/?q=site%3Astat.ethz.ch+normalizePath+McAfee)

which finds this as a first hit  
https://stat.ethz.ch/pipermail/r-help/2010-September/252217.html
which used to be the solution of the problem (and K.Elo's URL was to the
infamous Nabble version of R-help).

---

It is very said to notice that more and more users of R (and
Rtudio) and it seems even *instructors* are thinking they use
RStudio when they are primarily using R via RStudio... and their
credits are going to RStudio only instead of to R, the R
foundation and its not-unimportant subset, the R core team,
plus the 1000s of package authors and bug report / patches
contributing volunteers around the world.

--> Please spread the word: It is __R__ (and RStudio),  not the
other way around.




> On Thursday, 15 December 2016 12:39 PM, Bert Gunter 
 wrote:
> You may get a reply here, but this is the wrong place for you to post.
> RStudio is a separate commercial entity and product from the
> noncommercial R foundation and R software that runs this list. This
> list is about R programming; for questions about RStudio, you should
> consult the RStudio website and post to their support lists.

> Cheers,
> Bert


> Bert Gunter

> "The trouble with having an open mind is that people keep coming along
> and sticking things into it."
> -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )



> On Wed, Dec 14, 2016 at 10:18 PM, Amelia Marsh via R-help
>  wrote:
>> Hi
>> 
>> I had installed R studio Desktop 1.0.44. However whenever I wanted to 
write any command, before I could complete, I was getting following error
>> 
>> Error in normalizePath(dir, winslash = "/", mustWork = TRUE) :
>> unused argument(s) (winslash = "/", mustWork = TRUE)
>> 
>> 
>> I had uninstalled RStudio and again downloaded it and reinstalled. But 
still I am getting error like as mentioned below -
>> 
>> 
>>> a = 40
>> 
>>> b = 45
>> Error in normalizePath(dir, winslash = "/", mustWork = TRUE) :
>> unused argument(s) (winslash = "/", mustWork = TRUE)
>>> c = 120
>> Error in normalizePath(dir, winslash = "/", mustWork = TRUE) :
>> unused argument(s) (winslash = "/", mustWork = TRUE)
>> Error in normalizePath(dir, winslash = "/", mustWork = TRUE) :
>> unused argument(s) (winslash = "/", mustWork = TRUE)
>> Error in normalizePath(dir, winslash = "/", mustWork = TRUE) :
>> unused argument(s) (winslash = "/", mustWork = TRUE)
>> Error in normalizePath(dir, winslash = "/", mustWork = TRUE) :
>> unused argument(s) (winslash = "/", mustWork = TRUE)
>> Error in normalizePath(dir, winslash = "/", mustWork = TRUE) :
>> unused argument(s) (winslash = "/", mustWork = TRUE)
>> 
>> 
>> I had assigned value 40 to a, value 45 to b, but when I tried to assign 
value 120 to c, before I could complete, it started throwing above messages. I 
tried rnorm etc, however the error keeps on reappearing.
>> 
>> 
>> Can someone guide me.
>> 
>> Regards
>> 
>> Amelais
>> 
>> __
>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> 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 -- To UNSUBSCRIBE and more, see
> 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, 

[R] problem installing Rmpi

2016-12-15 Thread Jim Maas
Can anyone tell me to start looking to fix this, when attempting to install
Rmpi on Ubuntu 16.04, just updated R version to 3.3.2


** building package indices
** testing if installed package can be loaded
Error in system2(file.path(R.home("bin"), "R"), c(if (nzchar(arch))
paste0("--arch=",  :
  error in running command
* removing ‘/usr/local/lib/R/site-library/Rmpi’

​Thanks, J​

-- 
Jim Maas

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] R studio Problem

2016-12-15 Thread Amelia Marsh via R-help
Sorry Mr Gunter. I didn't realize it.

Regards

Amelia



On Thursday, 15 December 2016 12:39 PM, Bert Gunter  
wrote:
You may get a reply here, but this is the wrong place for you to post.
RStudio is a separate commercial entity and product from the
noncommercial R foundation and R software that runs this list. This
list is about R programming; for questions about RStudio, you should
consult the RStudio website and post to their support lists.

Cheers,
Bert


Bert Gunter

"The trouble with having an open mind is that people keep coming along
and sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )



On Wed, Dec 14, 2016 at 10:18 PM, Amelia Marsh via R-help
 wrote:
> Hi
>
> I had installed R studio Desktop 1.0.44. However whenever I wanted to write 
> any command, before I could complete, I was getting following error
>
> Error in normalizePath(dir, winslash = "/", mustWork = TRUE) :
> unused argument(s) (winslash = "/", mustWork = TRUE)
>
>
> I had uninstalled RStudio and again downloaded it and reinstalled. But still 
> I am getting error like as mentioned below -
>
>
>> a = 40
>
>> b = 45
> Error in normalizePath(dir, winslash = "/", mustWork = TRUE) :
> unused argument(s) (winslash = "/", mustWork = TRUE)
>> c = 120
> Error in normalizePath(dir, winslash = "/", mustWork = TRUE) :
> unused argument(s) (winslash = "/", mustWork = TRUE)
> Error in normalizePath(dir, winslash = "/", mustWork = TRUE) :
> unused argument(s) (winslash = "/", mustWork = TRUE)
> Error in normalizePath(dir, winslash = "/", mustWork = TRUE) :
> unused argument(s) (winslash = "/", mustWork = TRUE)
> Error in normalizePath(dir, winslash = "/", mustWork = TRUE) :
> unused argument(s) (winslash = "/", mustWork = TRUE)
> Error in normalizePath(dir, winslash = "/", mustWork = TRUE) :
> unused argument(s) (winslash = "/", mustWork = TRUE)
>
>
> I had assigned value 40 to a, value 45 to b, but when I tried to assign value 
> 120 to c, before I could complete, it started throwing above messages. I 
> tried rnorm etc, however the error keeps on reappearing.
>
>
> Can someone guide me.
>
> Regards
>
> Amelais
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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 -- To UNSUBSCRIBE and more, see
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] R studio Problem

2016-12-15 Thread Amelia Marsh via R-help
Thanks a lot Kimmo for your valuable guidance. Hope it works.

Regards

Amelia



On Thursday, 15 December 2016 12:06 PM, K. Elo  wrote:
Hi!

Maybe this helps:

http://r.789695.n4.nabble.com/Error-in-normalizePath-path-with-McAfee-td2532324.html

Best,
Kimmo

15.12.2016, 08:18, Amelia Marsh via R-help wrote:
> Hi
>
> I had installed R studio Desktop 1.0.44. However whenever I wanted to write 
> any command, before I could complete, I was getting following error
>
> Error in normalizePath(dir, winslash = "/", mustWork = TRUE) :
> unused argument(s) (winslash = "/", mustWork = TRUE)
>
>
> I had uninstalled RStudio and again downloaded it and reinstalled. But still 
> I am getting error like as mentioned below -
>
>
>> a = 40
>
>> b = 45
> Error in normalizePath(dir, winslash = "/", mustWork = TRUE) :
> unused argument(s) (winslash = "/", mustWork = TRUE)
>> c = 120
> Error in normalizePath(dir, winslash = "/", mustWork = TRUE) :
> unused argument(s) (winslash = "/", mustWork = TRUE)
> Error in normalizePath(dir, winslash = "/", mustWork = TRUE) :
> unused argument(s) (winslash = "/", mustWork = TRUE)
> Error in normalizePath(dir, winslash = "/", mustWork = TRUE) :
> unused argument(s) (winslash = "/", mustWork = TRUE)
> Error in normalizePath(dir, winslash = "/", mustWork = TRUE) :
> unused argument(s) (winslash = "/", mustWork = TRUE)
> Error in normalizePath(dir, winslash = "/", mustWork = TRUE) :
> unused argument(s) (winslash = "/", mustWork = TRUE)
>
>
> I had assigned value 40 to a, value 45 to b, but when I tried to assign value 
> 120 to c, before I could complete, it started throwing above messages. I 
> tried rnorm etc, however the error keeps on reappearing.
>
>
> Can someone guide me.
>
> Regards
>
> Amelais
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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 -- To UNSUBSCRIBE and more, see
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 -- To UNSUBSCRIBE and more, see
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.