[R] Help with if else branching print out

2018-12-18 Thread Andrew
Hi all Playing around with some branching using if, if else, and else, I wrote the following very basic script: [code block] ## Take single value input from user: # Note 'as.integer' to convert character vector to numeric for testing nums <- (as.numeric(readline("Please enter a number

Re: [R] Help with if else branching print out

2018-12-18 Thread Eric Berger
I often use sprintf() to control formatting of text strings. e.g. sprintf("%s is not between 1 or 15\n",nums) See ?sprintf for details HTH, Eric On Tue, Dec 18, 2018 at 10:56 AM Andrew wrote: > Hi all > > Playing around with some branching using if, if else, and else, I wrote > the

Re: [R] Help with if else branching print out

2018-12-18 Thread Ivan Krylov
On Tue, 18 Dec 2018 08:56:23 + Andrew wrote: > How do I: > > (a) reduce the gap between the reported number (i.e., 17, 9, 13) in > each of the lines? and > > (b) ensure that in the case of the second run using 9 as the input, > the print is not over two lines? Build a single string from

Re: [R] Help with if else branching print out

2018-12-18 Thread Rui Barradas
Hello, Yet another option is ?cat. msg <- c("is not between 1 or 15", "is *not* 6 - 9 inclusive, nor is it 12", "falls within 6 - 9 inclusively, or is 12", "is *not* 6 - 9 inclusive, nor is it 12", "is not between 1 or 15") nums <-

[R] Webshot failed to take snapshot in Ubuntu machine

2018-12-18 Thread Christofer Bogaso
Hi, I was using webshot package to take snapshot of a webpage as below: library(webshot) webshot(' https://www.bseindia.com/stock-share-price/asian-paints-ltd/asianpaint/500820/', 'bb.pdf') However what I see is a Blank PDF file is saved. However if I use the same code in my windows machine it

Re: [R] Webshot failed to take snapshot in Ubuntu machine

2018-12-18 Thread Marc Girondot via R-help
Hi Christofer, I just try on MacOSX and ubuntu and it works on both: For ubuntu: > Sys.info()   sysname   "Linux"   release   "4.15.0-42-generic"    

Re: [R] [R studio] Plotting of line chart for each columns at 1 page

2018-12-18 Thread Jim Lemon
Hi Subhamitra, My apologies, I caught a mistake. To have the first tick in the middle of the first year, you want half of the _observations_ in a year, not half of the days. As I now have your data at my fingertips: 3567/15.58385 [1] 228.8908 Almost exactly what was calculated for the first

Re: [R] [R studio] Plotting of line chart for each columns at 1 page

2018-12-18 Thread Subhamitra Patra
Hello Sir, It is really great learning for me while discussing with you. As per your suggestion, I also read the axis function in the graphics package, and now completely understand your logic. I will apply the same logic for my rest variable and would like to discuss after the successful

Re: [R] Webshot failed to take snapshot in Ubuntu machine

2018-12-18 Thread Christofer Bogaso
Also the Session information. > sessionInfo() R version 3.4.4 (2018-03-15) Platform: x86_64-pc-linux-gnu (64-bit) Running under: Ubuntu 16.04.4 LTS Matrix products: default BLAS: /usr/lib/libblas/libblas.so.3.6.0 LAPACK: /usr/lib/lapack/liblapack.so.3.6.0 locale: [1] LC_CTYPE=en_US.UTF-8

Re: [R] Problem with Plotting in R

2018-12-18 Thread Michael Dewey
Dear Bob We do not have your data so it is hard to be sure but plot() takes two parameters for the data x and y so when you give it three you are confusing it into thinking one of them is something else. What exactly were you trying to do with the failed command? On 18/12/2018 14:17,

Re: [R] Problem with Plotting in R

2018-12-18 Thread Rui Barradas
Hello, You are calling plot.default with 4 arguments. The first 2 are x and y. The 3rd is type. So MyData$NWorthSm becomes the 4th, xlim. When you pass xlim a value, MyData$NWorthSm becomes the next one, ylim. Etc, etc, etc. It will throw the errors in the order of the arguments you can see in

[R] Problem with Plotting in R

2018-12-18 Thread rsherry8
Please consider the following R statements: > x = seq(1:1632) > length( MyData$NWorth ) [1] 1632 > length( MyData$NWorthSm ) [1] 1632 > plot( x, MyData$NWorth, type="l" ) > plot( x, MyData$NWorthSm, type="l" ) > plot( x, MyData$NWorth, MyData$NWorthSm, type="l"

[R] [Solved] Re: Help with if else branching print out

2018-12-18 Thread Andrew
Dear Eric, Ivan & Rui Thanks all for your suggestions. FWIW, I've opted to use paste0 and after a bit of playing around found it formatted the output nicely. Eric, I wasn't aware of sprintf - seems a handy function to format text with, so will try to remember that. Ivan, I'll dig into

Re: [R] Webshot failed to take snapshot in Ubuntu machine

2018-12-18 Thread Christofer Bogaso
Is there any alternative to webshot? On Tue, Dec 18, 2018 at 6:23 PM Marc Girondot wrote: > Hi Christofer, > I just try on MacOSX and ubuntu and it works on both: > > For ubuntu: > > Sys.info() >sysname >"Linux" >

[R] Plotting rgb proportions in R

2018-12-18 Thread Tasha O'Hara
Hello, I am trying to plot specific rgb color proportions of a marine specimen in a stacked plot using R and I was looking for some help. I have several rgb proportions per specimen (an example of one is below). I've run into different examples of people using vegan or grDevices. Can anyone help

Re: [R] Plotting rgb proportions in R

2018-12-18 Thread Jeff Newmiller
I can't figure out what message you are hoping to convey in your plot from your posting... what are you comparing to what? Comments like "I've run into different examples of people using vegan (an analysis package with some diagnostic display functionality) or grDevices (a package supporting

Re: [R] Problem with LM

2018-12-18 Thread Richard M. Heiberger
## This example, with your variable names, works correctly. z2 <- data.frame(y=1:5, x=c(1,5,2,3,5), x2=c(1,5,2,3,5)^2) z2 class(z2) length(z2) dim(z2) lm(y ~ x + x2, data=z2) ## note that that variable names y, x, x2 are column names of the ## data.frame z2 ## please review the definitions and

Re: [R] Problem with LM

2018-12-18 Thread Bert Gunter
... Perhaps worth adding is the use of poly() rather than separately created terms for (non/orthogonal) polynomials: lm(y ~ poly(x, degree =2) #orthogonal polyomial of degree 2 see ?poly for details. -- Bert Bert Gunter "The trouble with having an open mind is that people keep coming along

Re: [R] Problem with LM

2018-12-18 Thread rsherry8
Richard, It is now working. Thank you very much. Bob On 12/18/2018 7:10 PM, Richard M. Heiberger wrote: ## This example, with your variable names, works correctly. z2 <- data.frame(y=1:5, x=c(1,5,2,3,5), x2=c(1,5,2,3,5)^2) z2 class(z2) length(z2) dim(z2) lm(y ~ x + x2, data=z2) ## note

Re: [R] Plotting rgb proportions in R

2018-12-18 Thread Jim Lemon
I was probably a bit obscure and should have written "convert your 0-255 values to 0-1". As Bert notes, you can't get a sensible ternary plot if your values do not sum to 1. scatterplot3d does a pretty good job, if you run the example. Jim On Wed, Dec 19, 2018 at 3:26 PM Bert Gunter wrote: > >

[R] Problem with LM

2018-12-18 Thread rsherry8
The values read into z2 came from a CSV file. Please consider this R session: > length(x2) [1] 1632 > length(x) [1] 1632 > length(z2) [1] 1632 > head(z2) [1] 28914.0 28960.5 28994.5 29083.0 29083.0 29083.0 > tail(z2) [1] 32729.65 32751.85 32386.05 32379.75 32379.15 31977.15 > lm ( y ~ x2 + x,

Re: [R] Plotting rgb proportions in R

2018-12-18 Thread Bert Gunter
3-d Proportions must sum to 1and are thus actually 2-d and should preferaby be plotted as a ternary plot. Several r packages will do this for you, e.g. package Ternary. Search "ternary plots" on rseek.org for others. -- Bert Bert Gunter "The trouble with having an open mind is that people keep

Re: [R] Plotting rgb proportions in R

2018-12-18 Thread Jim Lemon
Hi Tasha, I may be right off the track, but you could plot RGB proportions on a 3D plot. The easiest way I can think if would be to convert your 0-255 values to proportions: rgb_prop<-read.table(text="Red Green Blue pct 249 158 37 56.311 249 158 68 4.319 249 158 98 0.058 249 128 7 13.965 249 128

[R] geom_ribbon function in ggplot2 package

2018-12-18 Thread John
Hi, When using the geom_ribbon function in gglot2 package, I got the text "fill" above the legend "A" and "B". How can I get rid of the text "fill" above the legend? Thanks! The code is as follows: df<-data.frame(x=c(1,2), y=c(1,2), z=c(3,5)) > ggplot(df,