dplyr

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

How to create a new column in data frame which each row of new column is multiplication of all previous rows

南笙酒味 提交于 2021-02-10 17:56:45
问题 I have a data frame like the one shown below: ref_inf <- c(2,3,1,2.2,1.3,1.5,1.9,1.8,1.9,1.9) ref_year<- seq(2001,2010) inf_data <- data.frame(ref_year,ref_inf) ref_year ref_inf 1 2001 2.0 2 2002 3.0 3 2003 1.0 4 2004 2.2 5 2005 1.3 6 2006 1.5 7 2007 1.9 8 2008 1.8 9 2009 1.9 10 2010 1.9 What I want to do is to create a new column "Final Inflation" and each number in the new column should be calculated by multiplying all previous numbers in ref_inf column, so for example, if I want to

Error running weathercan package - fatal SSL/TLS alert (e.g. handshake failed))

萝らか妹 提交于 2021-02-10 17:49:25
问题 I am running the "weathercan" data package (https://cran.r-project.org/web/packages/weathercan/index.html; https://github.com/ropensci/weathercan) and keep getting an error when trying to retrieved data from the Environment and Climate Change historic weather data website. I've re-installed the package, I even reinstalled R and RStudio after deleting everything R from my system, but the error persists. The package works fine when I look up stations up, e.g., stations_search(coords = c(44

R: Creating a new row based on previous rows

雨燕双飞 提交于 2021-02-10 15:55:59
问题 I'm new to R and trying to create a new row based on values on previous rows. Sample data: df <- data.table(Item = c("a", "b", "c", "d"), "2010FY" = c(3, 5, 2, 2), "2011FY" = c(5, 6, 2, 1), "2012FY" = c(-1, 2, 2, 0.5)) I would like to create a new row that divides the 3rd row by the 4th row. Let's call this Item "e" and ideally should like this: Item 2010FY 2011FY 2012FY 1 a 3 5 -1 2 b 5 6 2 3 c 2 2 2 4 d 2 1 0.5 5 e 1 2 4 Using dplyr, my first attempt is: df <- bind_rows(df, e = df[Item %in%

R: Creating a new row based on previous rows

こ雲淡風輕ζ 提交于 2021-02-10 15:55:02
问题 I'm new to R and trying to create a new row based on values on previous rows. Sample data: df <- data.table(Item = c("a", "b", "c", "d"), "2010FY" = c(3, 5, 2, 2), "2011FY" = c(5, 6, 2, 1), "2012FY" = c(-1, 2, 2, 0.5)) I would like to create a new row that divides the 3rd row by the 4th row. Let's call this Item "e" and ideally should like this: Item 2010FY 2011FY 2012FY 1 a 3 5 -1 2 b 5 6 2 3 c 2 2 2 4 d 2 1 0.5 5 e 1 2 4 Using dplyr, my first attempt is: df <- bind_rows(df, e = df[Item %in%

How to get mean for all participants after selecting only a certain number of trials

♀尐吖头ヾ 提交于 2021-02-10 15:13:52
问题 I have a dataset of 500 trials per participant that I want to sample from in various quantities (i.e. I want to sample the same number of trials from each participant) and then compute the mean for each participant. Instead of doing so, it is creating a file with a one mean for each participant separately for each "num", e.g. if the mean for participant 1 with 125 trials is 426 that will be the whole file, then another file for participant 1 with 150 trials with a single value, and that is

Expand nested dataframe into parent

时光总嘲笑我的痴心妄想 提交于 2021-02-10 15:10:22
问题 I have a dataframe nested within a dataframe that I'm getting from Mongo. The number of rows match in each so that when viewed it looks like a typical dataframe. My question, how do I expand the nested dataframe into the parent so that I can run dplyr selects? See the layout below 'data.frame': 10 obs. of 2 variables: $ _id : int 1551 1033 1061 1262 1032 1896 1080 1099 1679 1690 $ personalInfo:'data.frame': 10 obs. of 2 variables: ..$ FirstName :List of 10 .. ..$ : chr "Jack" .. ..$ : chr

Use dplyr to take first and last row in a sequence by group [duplicate]

好久不见. 提交于 2021-02-10 14:51:54
问题 This question already has answers here : Subset panel data by group [duplicate] (3 answers) Closed 1 year ago . I'm trying to use dplyr to take the first and last rows of repeated values by group. I'm doing this for efficiency reasons, particularly so that graphing is faster. This is not a duplicate of Select first and last row from grouped data because I'm not asking for the strict first and last row in a group; I'm asking for the first and last row in a group by level (in my case 1's and 0

How to use dplyr `rowwise()` column numbers instead of column names

北慕城南 提交于 2021-02-10 14:39:41
问题 library(tidyverse) df <- tibble(col1 = c(5, 2), col2 = c(6, 4), col3 = c(9, 9)) df %>% rowwise() %>% mutate(col4 = sd(c(col1, col3))) # # A tibble: 2 x 4 # col1 col2 col3 col4 # <dbl> <dbl> <dbl> <dbl> # 1 5 6 9 2.83 # 2 2 4 9 4.95 After asking a series of questions I can finally calculate standard deviation across rows. See my code above. But I can't use column names in my production code, because the database I pull from likes to change the column names periodically. Lucky for me the

Finding the differences of paired-columns using dplyr

一曲冷凌霜 提交于 2021-02-10 14:38:09
问题 set.seed(3) library(dplyr) dat <- tibble(Measure = c("Height","Weight","Width","Length"), AD1_1= rpois(4,10), AD1_2= rpois(4,9), AD2_1= rpois(4,10), AD2_2= rpois(4,9), AD3_1= rpois(4,10), AD3_2= rpois(4,9), AD4_1= rpois(4,10), AD4_2= rpois(4,9), AD5_1= rpois(4,10), AD5_2= rpois(4,9), AD6_1= rpois(4,10), AD6_2= rpois(4,9)) Suppose I have data that looks like this. I wish to calculate the difference for each AD, paired with underscored number, i.e., AD1diff, AD2diff,AD3diff. Instead of writing