r

How to change R versions on Mac

∥☆過路亽.° 提交于 2021-02-10 20:42:58
问题 I'm trying to use the legacy version of R to run a package on Mac. On Windows there is a switch in the General tab. However, it is not found on Mac RStudio. I referred to this post: https://support.rstudio.com/hc/en-us/articles/200486138-Using-Different-Versions-of-R And I do not quite understand the 3 options: Run the installer from CRAN for the R version you want to be current List item Use the RSwitch utility available at: http://r.research.att.com/ Update the R.framework/Versions/Current

Count events before a specific time for a series of items in R

丶灬走出姿态 提交于 2021-02-10 20:40:07
问题 I have a dataframe of items with a certain number of different events which occur at different times. e.g. say I had a times of events (goal, corner, red card etc...) in various games of football. I want to count the number of each events which occurred before a certain time for each team in each game (where the time is different for each game). So I could have a dataframe of events (where C is corner, G is goal and R is red card) as follows: events <- data.frame( game_id = c(1, 1, 1, 1, 1, 1

Count events before a specific time for a series of items in R

二次信任 提交于 2021-02-10 20:38:39
问题 I have a dataframe of items with a certain number of different events which occur at different times. e.g. say I had a times of events (goal, corner, red card etc...) in various games of football. I want to count the number of each events which occurred before a certain time for each team in each game (where the time is different for each game). So I could have a dataframe of events (where C is corner, G is goal and R is red card) as follows: events <- data.frame( game_id = c(1, 1, 1, 1, 1, 1

Is there syntactic sugar to define a data frame in R

偶尔善良 提交于 2021-02-10 20:36:35
问题 I want to regroup US states by regions and thus I need to define a "US state" -> "US Region" mapping function, which is done by setting up an appropriate data frame. The basis is this exercise (apparently this is a map of the "Commonwealth of the Fallout"): One starts off with an original list in raw form: Alabama = "Gulf" Arizona = "Four States" Arkansas = "Texas" California = "South West" Colorado = "Four States" Connecticut = "New England" Delaware = "Columbia" which eventually leads to

Knitr: Turning the R chunk figure caption 90 degrees inline Latex

大憨熊 提交于 2021-02-10 20:25:14
问题 Here is my a code to demo what I cannot do. I use an R chunk to make a figure and use out.extra='angle=90' to make the figure post sideways on the page. Now how do I get my caption to go sideways too? \documentclass{article} \usepackage{subcaption} \begin{document} <<test-plot,echo=FALSE,fig.cap="I would like to be posted sideways under figure, NOT HERE",out.extra='angle=90'>>= plot(1) abline(0, 1) plot(rnorm(10)) for(i in 1:10) { abline(v = i, lty = 2) } @ \end{document} 来源: https:/

fviz_cluster() not accepting for k-medoid (PAM) results

核能气质少年 提交于 2021-02-10 20:24:59
问题 Trying to visualize k-medoid (PAM) cluster results with fviz_cluster() , however function isn't accepting them. It states within ?fviz_clust "object argument = an object of class "partition" created by the functions pam() , clara() or fanny() in cluster package" I've tried accessing the clustering vector through other means; pam_gower_2$clustering pam_gower_2[[3]] but then I get a separate error: Error: $ operator is invalid for atomic vectors" The class of pam_gower_2 is partition? As the

Find outlier using z score

不想你离开。 提交于 2021-02-10 20:23:23
问题 I am trying to create a function in R. The function should find outliers from a matrix using z score. The function should have two arguments as input (x which is a matrix and zs which is an integer). For each raw of the matrix, the function should calculate the zscore for each element and if zscore is bigger than zs or smaller than -zs , then the function should print that element. I know that I can use: z<- (x-mean(x))/sd(x) or z<- scale(x) for the calculations of z score but as I am a

Knitr: Turning the R chunk figure caption 90 degrees inline Latex

孤人 提交于 2021-02-10 20:22:08
问题 Here is my a code to demo what I cannot do. I use an R chunk to make a figure and use out.extra='angle=90' to make the figure post sideways on the page. Now how do I get my caption to go sideways too? \documentclass{article} \usepackage{subcaption} \begin{document} <<test-plot,echo=FALSE,fig.cap="I would like to be posted sideways under figure, NOT HERE",out.extra='angle=90'>>= plot(1) abline(0, 1) plot(rnorm(10)) for(i in 1:10) { abline(v = i, lty = 2) } @ \end{document} 来源: https:/

Find outlier using z score

穿精又带淫゛_ 提交于 2021-02-10 20:20:16
问题 I am trying to create a function in R. The function should find outliers from a matrix using z score. The function should have two arguments as input (x which is a matrix and zs which is an integer). For each raw of the matrix, the function should calculate the zscore for each element and if zscore is bigger than zs or smaller than -zs , then the function should print that element. I know that I can use: z<- (x-mean(x))/sd(x) or z<- scale(x) for the calculations of z score but as I am a

Error in dyn.load(file, DLLpath = DLLpath, …) : unable to load shared object '/software/R…', installing dplyr on LSF GNU/Linux server

余生颓废 提交于 2021-02-10 20:18:33
问题 I tried installing 'dplyr' on a Linux server using the following code in a script: install.packages('dplyr', dependencies = TRUE, lib = 'output/software/r/package/installation/', repos = 'http://cran.rstudio.com') but after running it with 'Rscript code.R' I got a long message followed by: ** package ‘dplyr’ successfully unpacked and MD5 sums checked ** libs ... g++ -I/software/R-3.4.0/lib/R/include -DNDEBUG -I../inst/include -DCOMPILING_DPLYR -DBOOST_NO_INT64_T -DBOOST_NO_INTEGRAL_INT64_T