r

Unable to launch runtime for 'R' script

巧了我就是萌 提交于 2021-02-16 18:53:27
问题 After installing the Advanced Analytics Extensions in SQL Server 2016 (CTP3) the following error appears in SSMS while executing an R-script: Unable to launch runtime for 'R' script. Please check the configuration of the 'R' runtime. What is the remedy? 回答1: Tried different approaches, but only this worked for me: "C:\Program Files\Microsoft SQL Server\130\R_SERVER\library\RevoScaleR\rxLibs\x64\RegisterRExt" /uninstall Then "C:\Program Files\Microsoft SQL Server\130\R_SERVER\library

How do I change column names in list of data frames inside a function?

|▌冷眼眸甩不掉的悲伤 提交于 2021-02-16 18:51:48
问题 I know that the answer to "how to change names in a list of data frames" has been answered multiple times. However, I'm stuck trying to generate a function that can take any list as an argument and change all of the column names of all of the data frames in the list. I am working with a large number of .csv files, all of which will have the same 3 column names. I'm importing the files in groups as follows: # Get a group of drying data data files, remove 1st column files <- list.files('Mang

How do I change column names in list of data frames inside a function?

我怕爱的太早我们不能终老 提交于 2021-02-16 18:51:25
问题 I know that the answer to "how to change names in a list of data frames" has been answered multiple times. However, I'm stuck trying to generate a function that can take any list as an argument and change all of the column names of all of the data frames in the list. I am working with a large number of .csv files, all of which will have the same 3 column names. I'm importing the files in groups as follows: # Get a group of drying data data files, remove 1st column files <- list.files('Mang

Extending rank() “Olympic Style”

一曲冷凌霜 提交于 2021-02-16 18:44:15
问题 In the olympics, if two people are tied for silver - they don't give out a bronze medal. Here's a sample of the kind of data I'm working with: x <- c(0.64, 0.64, 0.63, 0.62, 0.62, 0.62, 0.61, 0.6, 0.6, 0.58) I'd like to create a ranking function that outputs like so: rank.fun(x) 1 1 3 4 4 4 7 8 8 10 I've tried messing around with findInterval , rank , floor , ceiling but none of them seem to provide the result I'm looking for. 回答1: How about this: rank(-x, ties.method="min") 回答2: It looks

Extending rank() “Olympic Style”

醉酒当歌 提交于 2021-02-16 18:43:16
问题 In the olympics, if two people are tied for silver - they don't give out a bronze medal. Here's a sample of the kind of data I'm working with: x <- c(0.64, 0.64, 0.63, 0.62, 0.62, 0.62, 0.61, 0.6, 0.6, 0.58) I'd like to create a ranking function that outputs like so: rank.fun(x) 1 1 3 4 4 4 7 8 8 10 I've tried messing around with findInterval , rank , floor , ceiling but none of them seem to provide the result I'm looking for. 回答1: How about this: rank(-x, ties.method="min") 回答2: It looks

Group dates by week in R

此生再无相见时 提交于 2021-02-16 18:30:08
问题 I wish to label my data based on their week. This is my data: df2 <- structure(list(Order_Date = structure(c(16735, 16805, 16753, 16830, 17075, 17009, 17085, 16740, 16891, 16750, 16820, 16849, 16906, 16929, 16746, 16731, 16786, 16873, 16895, 16931), class = "Date")), .Names = "Order_Date", row.names = c(NA, -20L), class = "data.frame") and I tried to label them based on the week (0th week, 1th week and ....) and I wish to group my data by the week later And I tried this: # order by data

Trimming data in R, getting rid of “*”

不羁的心 提交于 2021-02-16 18:25:06
问题 I have a data set wich looks like: > data<-c( "IGHV1-2*02 F, or IGHV1-2*03 F","IGHV3-23*01 F, or > IGHV3-23*04 F","IGHV2-70*01 F","IGHV7-4-1*01") I would like to keep the first appearance of "V1-2" for example and delete anything which follows (including the "*"). So I tried the following: > data.substr<-substr(data,4,9) > data.substr1<-gsub("*","",data.substr) but I still cant get rid of the "*", probably because it serves as a placeholder... Does anyone have an idea? 回答1: gsub("[*].*$",""

Is there a way to build a pairwise data frame based on shared values in another data frame in R?

感情迁移 提交于 2021-02-16 18:24:27
问题 For example DF1 is: Id1 Id2 1 10 2 10 3 7 4 7 5 10 And want DF2: Id1 Id2 1 2 1 5 2 5 3 4 The data frame DF2 is a pairwise set of values from Id1 column in DF1 that shared a common value in Id2 of DF1. My attempt: temp <- do.call("cbind", split(DF1, rep(c(1,2), length.out = nrow(DF1)))) (DF2 <- temp %>% select("1.Id1", "2.Id2")) But this does not generate a pairwise data frame: Id1 Id2 1 2 3 4 回答1: Here is another tidyverse method using full_join . library(dplyr) library(purrr) dat2 <- dat %>%

Separate string into many columns

元气小坏坏 提交于 2021-02-16 18:23:06
问题 I'd like to separate each letter or symbol in a string for composing a new data.frame with dimension equals the number of letters. I tried to use the function separate from tidyr package, but the result is not desired. df <- data.frame(x = c('house', 'mouse'), y = c('count', 'apple'), stringsAsFactors = F) unexpected result df[1, ] %>% separate(x, c('A1', 'A2', 'A3', 'A4', 'A5'), sep ='') A1 A2 A3 A4 A5 y 1 <NA> <NA> <NA> <NA> <NA> count Expected output A1 A2 A3 A4 A5 h o u s e m o u s e

Extract elements by name from a nested list

感情迁移 提交于 2021-02-16 18:14:49
问题 For a named, nested list, what is the best way to extract a specific element? If I have a list with known fields (eg, from a yaml file), I want to extract an element (list or otherwise) without having to search through the names and indices or trying to keep track of the levels in the str output. For example, I know that lm returns a nested list which contains qr info. fit <- lm(mpg ~ wt, mtcars) fit$qr$qraux # [1] 1.176777 1.046354 But if I don't know the order, I just want to specify the