Re: [R] Calculating frequencies of multiple values in 200 colomns

2017-11-09 Thread Bert Gunter
Always reply to the list. I am not a free, private consultant! "For example, if I have the values : 1 , 2 , 3 in each column, applying Tabulate () would calculate the frequency of 1 and 2 without 3" Huh?? > x <- sample(1:3,10,TRUE) > x [1] 1 3 1 1 1 3 2 3 2 1 > tabulate(x) [1] 5 2 3 Cheers, Be

Re: [R] Calculating frequencies of multiple values in 200 colomns

2017-11-09 Thread Bert Gunter
This is not a good way to do things! R has many powerful built in functions to do this sort of thing for you. Searching -- e.g. at rseek.org or even a plain old google search -- can help you find them. Also, it looks like you need to go through a tutorial or two to learn more about R's basic funct

Re: [R] R basic

2017-11-09 Thread jean-philippe
Hi, Since you didn't provide us any detail of what you tried to do so far, I can point you out to the dplyr library. It will make your life easier while dealing with dataframes (well at least it makes mine easier). Cheers Jean-Philippe On 09/11/2017 16:05, Hye Joon Yoon wrote: Can anyone

Re: [R] R basic

2017-11-09 Thread Boris Steipe
Hi - This list has a "no homework" policy, but we can certainly help once you show what effort you have put into this yourself. Read the posting guide, especially regarding the instructions re. reproducible examples, and follow them exactly. Cheers, B. > On Nov 9, 2017, at 10:05 AM, Hye Joo

[R] R basic

2017-11-09 Thread Hye Joon Yoon
Can anyone help with scripting the commands below? 1. Add/create a new column to df and name it as ShortPause . 2. Convert ShortPause as a factor variable. 3. ShortPause will have two levels (short and long). Assign short if pause is smaller than 0.1, and assign long otherwise. 4. How many ‘syntax

Re: [R] weighted average grouped by variables

2017-11-09 Thread Thierry Onkelinx
Dear Massimo, It seems straightforward to use weighted.mean() in a dplyr context library(dplyr) mydf %>% group_by(date_time, type) %>% summarise(vel = weighted.mean(speed, n_vehicles)) Best regards, ir. Thierry Onkelinx Statisticus / Statistician Vlaamse Overheid / Government of Flanders

[R] R 3.4.3 scheduled for November 30

2017-11-09 Thread Peter Dalgaard
Full schedule available on developer.r-project.org (pending auto-update from SVN) -- Peter Dalgaard, Professor, Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Office: A 4.23 Email: pd@cbs.dk Priv: pda...@gmail.com __

Re: [R] R-help

2017-11-09 Thread MacQueen, Don
A trip to the Spatial Task View on CRAN might be in order. The RandomFields package comes to mind. -Don -- Don MacQueen Lawrence Livermore National Laboratory 7000 East Ave., L-627 Livermore, CA 94550 925-423-1062 Lab cell 925-724-7509 On 11/9/17, 12:37 AM, "R-help on behalf of PIKAL Petr"

Re: [R] [R-pkgs] Release of ess 0.0.1

2017-11-09 Thread Sam Steingold
> * Jorge Cimentada [2017-11-09 00:02:53 +0100]: > > I'm happy to announce the release of ess 0.0.1 a package designed to > download data from the European Social Survey Given the existence of ESS (Emacs Speaks Statistics - https://ess.r-project.org/) the package name "ess" seems unfortunate. --

Re: [R] weighted average grouped by variables

2017-11-09 Thread Massimo Bressan
hi thierry thanks for your reply yes, you are right, your solution is more straightforward best Da: "Thierry Onkelinx" A: "Massimo Bressan" Cc: "r-help" Inviato: Giovedì, 9 novembre 2017 15:17:31 Oggetto: Re: [R] weighted average grouped by variables Dear Massimo, It seems strai

[R] ggplot2 error

2017-11-09 Thread Thomas Subia via R-help
Hello all, Zeki(?) reported: > ggplot(data = mtcars, aes(x= wt, y= mpg)) + geom_line() > Error: Found object is not a stat. Using R v3.4.62 and R studio, I'm unable to reproduce this error. All the best, Thomas Subia [[alternative HTML version deleted]]

Re: [R] weighted average grouped by variables

2017-11-09 Thread PIKAL Petr
Hi Thanks for working example. you could use split/ lapply approach, however it is probably not much better than dplyr method. sapply(split(mydf, mydf$type), function(speed, n_vehicles) sum(mydf$speed*mydf$n_vehicles)/sum(mydf$n_vehicles)) gives you averages aggregate(mydf$n_vehicles, list(my

Re: [R] weighted average grouped by variables

2017-11-09 Thread Rui Barradas
Sorry, I messed up. Only checked the final result after sending the previous mail. The solution is wrong. Rui Barradas Em 09-11-2017 13:27, Rui Barradas escreveu: Hello, Using base R only, the following seems to do what you want. with(mydf, ave(speed, date_time, type, FUN = weighted.mean, w

Re: [R] weighted average grouped by variables

2017-11-09 Thread Rui Barradas
Hello, Using base R only, the following seems to do what you want. with(mydf, ave(speed, date_time, type, FUN = weighted.mean, w = n_vehicles)) Hope this helps, Rui Barradas Em 09-11-2017 13:16, Massimo Bressan escreveu: Hello an update about my question: I worked out the following solutio

Re: [R] weighted average grouped by variables

2017-11-09 Thread Massimo Bressan
Hello an update about my question: I worked out the following solution (with the package "dplyr") library(dplyr) mydf%>% mutate(speed_vehicles=n_vehicles*mydf$speed) %>% group_by(date_time,type) %>% summarise( sum_n_times_speed=sum(speed_vehicles), n_vehicles=sum(n_vehicles), vel=sum(s

Re: [R] Sharing an R installation via NFS on ubuntu cluster

2017-11-09 Thread Ista Zahn
On Nov 9, 2017 5:07 AM, "Florian Oswald" wrote: I can install R with sudo apt-get update sudo apt-get install r-base this is not my problem, and indeed, not my question. my question was how could I share the resulting R installation over NFS? Do I have to export every location where apt-get i

[R] weighted average grouped by variables

2017-11-09 Thread Massimo Bressan
hi all I have this dataframe (created as a reproducible example) mydf<-structure(list(date_time = structure(c(1508238000, 1508238000, 1508238000, 1508238000, 1508238000, 1508238000, 1508238000), class = c("POSIXct", "POSIXt"), tzone = ""), direction = structure(c(1L, 1L, 1L, 1L, 2L, 2L, 2L),

[R] [R-pkgs] Release of ess 0.0.1

2017-11-09 Thread Jorge Cimentada
Dear CRANers! I'm happy to announce the release of ess 0.0.1 a package designed to download data from the European Social Survey directly into R as easily as possible. It has a few helper functions to download rounds/waves, rounds for a selected country and t

Re: [R] Sharing an R installation via NFS on ubuntu cluster

2017-11-09 Thread Florian Oswald
I can install R with sudo apt-get update sudo apt-get install r-base this is not my problem, and indeed, not my question. my question was how could I share the resulting R installation over NFS? Do I have to export every location where apt-get installs a component or can I force apt-get to place

Re: [R] R-help

2017-11-09 Thread PIKAL Petr
Hi it smells like a homework, this list has no homework policy. Anyway, maybe the sample approach could be used. Generate x,y coordinates - ?expand.grid sample n centers - ?sample select all points within defined area - ?point.in.polygon, package sp select desired number of points - ?sample Che