Re: [R] [FORGED] Re: bar plot add space to group data

2018-08-18 Thread Rolf Turner
On 19/08/18 16:12, Jim Lemon wrote: Hi Rolf, That's what comes of being in a hurry. legend(4.1,30,c("A+","A","B","C","D","E","U"), fill=c("white","lightblue","blue","orange","green","red","pink")) and I thank you for alerting me to the fact that the legend arguments in barp don't position the

Re: [R] [FORGED] Re: bar plot add space to group data

2018-08-18 Thread Rolf Turner
On 19/08/18 16:58, Peter Langfelder wrote: My guess is that space has no effect because (1) the first element is zero and (2) the code in OP's message has barplot(gceac[,3], ... i.e. barplot does not see a matrix, only a vector. To the OP, try formatting the data to be plotted as a matrix, n

Re: [R] Converting chr to num

2018-08-18 Thread Rui Barradas
Hello, It also works with class "factor": df <- data.frame(variable = c("12.6%", "30.9%", "61.4%")) class(df$variable) #[1] "factor" as.numeric(gsub(pattern = "%", "", df$variable)) #[1] 12.6 30.9 61.4 This is because sub() and gsub() return a character vector and the instruction becomes an

Re: [R] [FORGED] Re: bar plot add space to group data

2018-08-18 Thread Peter Langfelder
My guess is that space has no effect because (1) the first element is zero and (2) the code in OP's message has barplot(gceac[,3], ... i.e. barplot does not see a matrix, only a vector. To the OP, try formatting the data to be plotted as a matrix, not as a vector, then the space argument should b

Re: [R] [FORGED] Re: bar plot add space to group data

2018-08-18 Thread Jim Lemon
Hi Rolf, That's what comes of being in a hurry. legend(4.1,30,c("A+","A","B","C","D","E","U"), fill=c("white","lightblue","blue","orange","green","red","pink")) and I thank you for alerting me to the fact that the legend arguments in barp don't position the legend properly. I'll fix it. Jim O

Re: [R] [FORGED] Re: bar plot add space to group data

2018-08-18 Thread Rolf Turner
Jim: (a) There's no legend. (b) I am still curious as to why the OP's code didn't work, in that the "space=c(0,2)" argument seemed to have no effect. cheers, Rolf On 18/08/18 20:45, Jim Lemon wrote: Hi citc, Try this: geac<-matrix(c(9,9,8,8,8,23,23,23,23,22,27,27,27,25,24, 19,19,19,20,2

Re: [R] Converting chr to num

2018-08-18 Thread GALIB KHAN
So running the code in my headas long as that column's data type is a vector of characters then it should work. Did you try it out? On Sat, Aug 18, 2018, 5:02 PM Jeff Reichman wrote: > Given it’s a variable would I just change the 12.6 in > as.numeric(gsub(pattern = "%","","12.6%")) > > To

Re: [R] Converting chr to num

2018-08-18 Thread GALIB KHAN
Hey there, as.numeric(gsub(pattern = "%","","12.6%")) On Sat, Aug 18, 2018 at 4:20 PM, Jeff Reichman wrote: > R-Help Forum > > > > How do I convert a chr variable that contains percentages to an integer > > > > Example 12.6% (chr) to 12.6 (int) > > > > Jeff > > > [[alternative HTML vers

Re: [R] Converting chr to num

2018-08-18 Thread Bert Gunter
u 12.6 is not an integer. 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 Sat, Aug 18, 2018 at 2:20 PM Jeff Reichman wrote: > R-Help Forum > > > > How

Re: [R] Converting chr to num

2018-08-18 Thread Jeff Reichman
Given it’s a variable would I just change the 12.6 in as.numeric(gsub(pattern = "%","","12.6%")) To the variable name say … as.numeric(gsub(pattern = "%","",df$variable)) From: GALIB KHAN Sent: Saturday, August 18, 2018 4:23 PM To: reichm...@sbcglobal.net Cc: r-help@r-project.org Subject

Re: [R] Converting chr to num

2018-08-18 Thread Rui Barradas
Hello, You have to get rid of the percent sign first. This can be done with ?sub x <- "12.6%" y <- sub("%$", "", x) z <- as.numeric(y) 1) The dollar sign means "end of string". See ?regexpr. 2) You can all of that in one code line, no need to create y. z <- as.numeric(sub("%$", "", x)) Hope

[R] Converting chr to num

2018-08-18 Thread Jeff Reichman
R-Help Forum How do I convert a chr variable that contains percentages to an integer Example 12.6% (chr) to 12.6 (int) Jeff [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see ht

Re: [R] Understanding read.csv error message [FIXED]

2018-08-18 Thread Rich Shepard
On Sat, 18 Aug 2018, MacQueen, Don wrote: It's not obvious what would be causing that error from read.csv. But here's what I would probably try: I'd try switching to the more general read.table. Don/Peter, I found the problem: it was in the following line in the script which referenced '

Re: [R] Understanding read.csv error message

2018-08-18 Thread Ben Tupper
Hi, I would be tempted, as a start, to read the entire file in as rows of text, split each line by the expected delimiter, and then count the number of elements each split line yields. Once you know each row splits into the expected number of txt <- "name,easting,northing,elev,sampdate,prcp

Re: [R] Understanding read.csv error message

2018-08-18 Thread peter dalgaard
What Don said, and also notice that the error is not about anything having value 0, it is about replacing something with something of _length_ 0. It is not obvious where that happens, sometimes a traceback() can give a clue, but probably Don is right that the issue is that there is something not

Re: [R] How to rotate label in tcltk R

2018-08-18 Thread peter dalgaard
I don't think labels as such can be rotated. Newer versions of Tk allows rotation in canvases but this was implemented some years after the tcltk package was developed, so some assembly may be required. If you can extrapolate from Python, there may be some relevant ideas in this post: https://s

Re: [R] bar plot add space to group data

2018-08-18 Thread Jim Lemon
Hi citc, Try this: geac<-matrix(c(9,9,8,8,8,23,23,23,23,22,27,27,27,25,24, 19,19,19,20,20,17,17,17,18,19,8,8,8,9,9,2,2,3,3,3),ncol=5,byrow=TRUE) library(plotrix) barp(geac,names.arg=2014:2018,main="A level grades chemistry", xlab="Year",ylab="Percentage of each grade",ylim=c(0,30), col=c("white

Re: [R] source script file that contains Unicode non-English characters

2018-08-18 Thread Faridedin Cheraghi
Dear Duncan, thanks again for your response. > I'm talking about the R Core developers. Now it make sense. Those [R Core] are the key words that were omitted in your original email. > If you think this is a new bug, you should report it to the bug tracking system (which requires you to be regi