[R] Computing means of multiple variables based on a condition

2016-05-25 Thread KMNanus
I have a large dataset, a sample of which is: a<- c(“A”, “B”,“A”, “B”,“A”, “B”,“A”, “B”,“A”, “B”) b <-c(15, 35, 20, 99, 75, 64, 33, 78, 45, 20) c<- c( 111, 234, 456, 876, 246, 662, 345, 480, 512, 179) d<- c(1.1, 3.2, 14.2, 8.7, 12.5, 5.9, 8.3, 6.0, 2.9, 9.3) df <- data.frame(a,b,c,d) I’m tryin

Re: [R] Computing means of multiple variables based on a condition

2016-05-25 Thread KMNanus
tware > wdunlap tibco.com <http://tibco.com/> > On Wed, May 25, 2016 at 3:37 PM, KMNanus <mailto:kmna...@gmail.com>> wrote: > I have a large dataset, a sample of which is: > > a<- c(“A”, “B”,“A”, “B”,“A”, “B”,“A”, “B”,“A”, “B”) > b <-c(15, 35, 20, 99, 75,

[R] Need help getting plotly to run on R

2016-06-02 Thread KMNanus
I signed up with plotly on their own site - https://plot.ly/ - and got a username and password. When I installed the package in R, I got the following error msg - "Storing 'username' as the environment variable 'plotly_username' Error in Sys.setenv(plotly_username = username)

[R] Turning a variable name into a function argument

2016-06-27 Thread KMNanus
I’m inexperience but am trying to get my head around using functions to make a number of ggplots easier to do. I have a function that creates a ggplot taking one input variable as an argument. The variable name is shorthand for the actual variable (variable name = tue, Actual name = Tuesday).

Re: [R] Turning a variable name into a function argument

2016-06-28 Thread KMNanus
gt; On Jun 28, 2016, at 12:20 PM, David Winsemius wrote: > >> >> On Jun 27, 2016, at 6:12 PM, KMNanus wrote: >> >> I’m inexperience but am trying to get my head around using functions to make >> a number of ggplots easier to do. >> >> I hav

Re: [R] Turning a variable name into a function argument

2016-06-28 Thread KMNanus
o accomplish what you want > even simpler by using the `paste`, `paste0`, or `sprintf` functions. > > On Tue, Jun 28, 2016 at 12:10 PM, KMNanus wrote: >> Thanks for getting back to me, I’m sorry if I was unclear. >> >> What I’m trying to figure out is the equivalent of

Re: [R] Turning a variable name into a function argument

2016-06-28 Thread KMNanus
ng to modify an > existing function without working on the source? > > On Tue, Jun 28, 2016 at 2:46 PM, KMNanus <mailto:kmna...@gmail.com>> wrote: > Thanks for getting back to me. None of them work, because I’m trying to use > the string in the function call - myfun(z, “st

Re: [R] Turning a variable name into a function argument

2016-06-28 Thread KMNanus
line below) >> 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 Tue, Jun 28

[R] Is there a way to coerce ggplot into using min & max values for x & y axes?

2016-07-11 Thread KMNanus
I’m plotting few dozen variables, doing so because I need to examine them one at a time. The range of these variables varies widely. One can range from -.5 to .03, another from -600 to +750. I want both axes to automatically plot from both min and max values for both continuous variables.

[R] Please help me, I'm trying to update my version of R

2016-08-22 Thread KMNanus
I’m a newbie running 3.2.4 on a mac equipped with Yosemite (10.10.5). I want to update to 3.3.1 and have downloaded the package, but have not been able to install it. I’ve tried install.packages("R-3.3.1.tar.gz”) and install.packages("R-3.3.1.pkg”) after downloading both files. I get an error

Re: [R] Please help me, I'm trying to update my version of R

2016-08-23 Thread KMNanus
won't be available in the > 3.3 installation, but *those* packages you can install using install.packages. > > Cheers > > -- > Thomas Mailund > On 22 August 2016 at 22:17:50, KMNanus (kmna...@gmail.com > <mailto:kmna...@gmail.com>) wrote: > >> I’m a newbie runn

[R] receiving Error: unexpected '='

2016-02-29 Thread KMNanus
I’m a newbie and trying to execute this simple function in order to change wk 5 NA’s to wk 4 values for the dataset (ken) below. Can someone pls tell me what I’m doing wrong? The error msg is “"rror: unexpected input in "new_week <- function(x,y) { “ Even the “E” is missing in the word “Error.

[R] Extracting part of a factor

2016-03-03 Thread KMNanus
I have a factor variable that is 6 digits and hyphenated. For example, 001-014. I need to extract the first 3 digits to a new variable using mutate in dplyr - in this case 001 - but can’t find a function to do it. substr will do this for character strings, but I need the variable to remain as

Re: [R] Extracting part of a factor

2016-03-03 Thread KMNanus
> Hi, > > On 03/03/2016 12:18 PM, KMNanus wrote: >> I have a factor variable that is 6 digits and hyphenated. For example, >> 001-014. >> >> I need to extract the first 3 digits to a new variable using mutate in dplyr >> - in this case 001 - but can’t fin

Re: [R] Extracting part of a factor

2016-03-03 Thread KMNanus
gt; > Like this? > > x <- factor("001-014") > y <- substr(as.character(x), 1, 3) > > Best, > Ista > > > > > On Thu, Mar 3, 2016 at 3:18 PM, KMNanus wrote: >> I have a factor variable that is 6 digits and hyphenated. For example, >

Re: [R] Extracting part of a factor

2016-03-04 Thread KMNanus
4-450-0816 (tel) 347-730-4813 (fax) > On Mar 3, 2016, at 8:33 PM, Hervé Pagès wrote: > > On 03/03/2016 02:13 PM, KMNanus wrote: >> When I do that, > > When you do what exactly? > > It's impossible for anyone here to know what you're doing if you &g

Re: [R] Extracting part of a factor

2016-03-04 Thread KMNanus
as has already been suggested. You'll need to > provide a reproducible example to show us what's going wrong. Using fake data > is fine, we just need to see some data that look like yours and the code > you're using. > > Sarah > > On Fri, Mar 4, 2016 at 1

Re: [R] Extracting part of a factor

2016-03-04 Thread KMNanus
4 > str(testdata) > 'data.frame': 6 obs. of 6 variables: > $ subject: Factor w/ 6 levels "001","002","003",..: 1 2 3 4 5 6 > $ group : Factor w/ 2 levels "boys","girls": 1 1 1 2 2 2 > $ wk1: int 2 7 9 5 2 1 > $ wk2

Re: [R] Extracting part of a factor

2016-03-05 Thread KMNanus
s a functional language - a properly written R functio does > not change anything, it only returns its result. > > :-) > > > On Mar 4, 2016, at 4:13 PM, KMNanus wrote: > >> If I call mutate this way - mutate(test, place = >> factor(substr(test$subject,1

[R] extracting months from a data

2016-03-09 Thread KMNanus
I have a series of dates in format 3-Oct, 10-Oct, 20-Oct, etc. I want to create a variable of just the month. If I convert the date to a character string, substr is ineffective because some of the dates have 5 characters (3-Oct) and some have 6 (10-Oct). Is there a date function that accompli

[R] Error in make.names(col.names, unique = TRUE) : invalid multibyte string at '14 <4a>ULY 2012'

2016-03-10 Thread KMNanus
I’m trying to read in the data below from an Excel file (as a .csv file) in order to create an age (in years.%years) but am getting the error message in the subject line. I’ve tried saving the dates as dates in Excel and tried saving the dates as text, both give me the same error message. Can

Re: [R] extracting months from a data

2016-03-10 Thread KMNanus
functions for this. Read ?regex and ?sub. > > x <- c( "3-Oct", "10-Nov" ) > m <- sub( "^\\d+-([A-Za-z]{3})$", "\\1", x ) > > -- > Sent from my phone. Please excuse my brevity. > > On March 9, 2016 10:14:25 AM PST, KMNanus <ma

[R] Everything in ggplot2 is blue

2016-03-12 Thread KMNanus
I’m working with a data frame called “Koufax” (his lifetime pitching stats) in order to improve my ggplot2 skills. I’ve worked with a variety of iterations of ken <- ggplot(koufax, aes(x = W, y = IPouts, color = SO)) + geom_bar(stat = "identity”) but all the bars come up blue, even if I call..

Re: [R] How To Start R Studio After Installation

2016-03-19 Thread KMNanus
If you’re on a mac, just go into finder, then applications. highlight R studio and drag it to the dock. Then double-click it and r studio should start. If you’re on Windows, I don’t have a clue. Ken kmna...@gmail.com 914-450-0816 (tel) 347-730-4813 (fax) > On Mar 19, 2016, at 10:09 AM, Prasa

Re: [R] Help! Mann whitney

2016-03-21 Thread KMNanus
Here’s how I did it - Save the xlsx file as a .csv. Then call read.csv(“your file.csv”) and you should be in. Ken kmna...@gmail.com 914-450-0816 (tel) 347-730-4813 (fax) > On Mar 20, 2016, at 1:37 PM, > wrote: > > This may be really basic, but could you help me with this issue? > I have

Re: [R] installing packages

2016-03-21 Thread KMNanus
Have you set your working directory to the “3.2” folder? Ken kmna...@gmail.com 914-450-0816 (tel) 347-730-4813 (fax) > On Mar 21, 2016, at 5:07 PM, James Henson wrote: > > Dear R community, > > When I install or update a package, R prints the waring below. I go to the > ‘downloaded_packages’

[R] Manually inserting an extra tick on the y axis in ggplot2

2016-03-25 Thread KMNanus
I have called geom_hline to insert a horizontal line on the y axis of a plot at a given point. How can I insert the corresponding tick and its value on the y axis itself? Ken kmna...@gmail.com 914-450-0816 (tel) 347-730-4813 (fax) __ R-help@r-projec

Re: [R] Manually inserting an extra tick on the y axis in ggplot2

2016-03-25 Thread KMNanus
Thanks. Actually, found a good answer online - I wanted a horizontal line with a y intercept of 12.6. I set m <- 12.6 I drew the line with geom_hline then added geom_text(aes(0,m,label = m, vjust = -1)) which worked just fine. Ken kmna...@gmail.com 914-450-0816 (tel) 347-730-4813 (fax)