r

How convert Persian date to Gregorian in R? [closed]

妖精的绣舞 提交于 2021-02-10 15:13:07
问题 Closed . This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 8 months ago . Improve this question I want to convert a Persian calendar date (e.g. 1399/03/27) to a Gregorian calendar date in R. Is there any function to do so in R? 回答1: As @RuiBarradas pointed out in comments, we may use ConvCalendar::OtherDate . Since the package is no longer on CRAN we first need to

How to compare values with a reference table in R?

吃可爱长大的小学妹 提交于 2021-02-10 15:12:34
问题 I have following 2 dataframes. The 'ddf' has age and wt values of group while 'refdf' is reference table for lower and upper limit of wt for different ages. ddf = read.csv(text=" age, wt 10,26 9,21 8,28 6,16 7,20 11,24",header=T) refdf = read.csv(text=" age,lower,upper 5, 10, 14 6, 11, 13 7, 13, 15 8, 14, 18 9, 16, 21 10, 17, 22 11, 19, 25 12, 22, 29",header=T) I need to have another column called 'result' in ddf which should have a value of -1,1 or 0 depending on the wt being <= lower, >

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

Indenting disturbed when adding superscript to rowname of a grouped row using kable in latex

ぃ、小莉子 提交于 2021-02-10 15:07:28
问题 How do I add superscript to name of a particular row of a table created using kable in latex environment (this link gives solution for markdown). I tried following: at2=cbind(1:5,6:10,11:15) rownames(at2)=c("one", "two", "three", "four$^1$", "five") kable(at2,format = "latex",booktabs=T) But this isn't working. For image of result click this EDIT: The first problem is solved with escape = FALSE but now a new problem related to indentation has come up. I am using group_rows which automatically

How to compare values with a reference table in R?

◇◆丶佛笑我妖孽 提交于 2021-02-10 15:05:23
问题 I have following 2 dataframes. The 'ddf' has age and wt values of group while 'refdf' is reference table for lower and upper limit of wt for different ages. ddf = read.csv(text=" age, wt 10,26 9,21 8,28 6,16 7,20 11,24",header=T) refdf = read.csv(text=" age,lower,upper 5, 10, 14 6, 11, 13 7, 13, 15 8, 14, 18 9, 16, 21 10, 17, 22 11, 19, 25 12, 22, 29",header=T) I need to have another column called 'result' in ddf which should have a value of -1,1 or 0 depending on the wt being <= lower, >

Indenting disturbed when adding superscript to rowname of a grouped row using kable in latex

房东的猫 提交于 2021-02-10 15:05:11
问题 How do I add superscript to name of a particular row of a table created using kable in latex environment (this link gives solution for markdown). I tried following: at2=cbind(1:5,6:10,11:15) rownames(at2)=c("one", "two", "three", "four$^1$", "five") kable(at2,format = "latex",booktabs=T) But this isn't working. For image of result click this EDIT: The first problem is solved with escape = FALSE but now a new problem related to indentation has come up. I am using group_rows which automatically

Computing points for a football team

别说谁变了你拦得住时间么 提交于 2021-02-10 14:59:47
问题 everyone. I am trying to calculate football team points. I have my dataframe "df.work" with rownames = teamnames: rownames(df.work) <- c(as.vector(teams$HomeTeam)) I have imported all played matches from another dataframe. And for every team I try to execute if loop based on subset of team matches. First I filter all home matches. So my code is for (Team1 in row.names.data.frame(df.work)){ a1 <- filter(df.clean, HomeTeam == Team1) if (a1$home.goals > a1$away.goals) { df.work[Team1,"Points"] <

Computing points for a football team

亡梦爱人 提交于 2021-02-10 14:59:30
问题 everyone. I am trying to calculate football team points. I have my dataframe "df.work" with rownames = teamnames: rownames(df.work) <- c(as.vector(teams$HomeTeam)) I have imported all played matches from another dataframe. And for every team I try to execute if loop based on subset of team matches. First I filter all home matches. So my code is for (Team1 in row.names.data.frame(df.work)){ a1 <- filter(df.clean, HomeTeam == Team1) if (a1$home.goals > a1$away.goals) { df.work[Team1,"Points"] <

Using geom_rect in plotly

时间秒杀一切 提交于 2021-02-10 14:56:54
问题 I have the following plot using ggplot2 and plotly . However, the plotly image does not display the shaded areas I've inserted using geom_rect . I'm guessing that this is because plotly doesn't support geom_rect , does anyone have a workaround to solve this? Here is my code library(rmsfuns) packages <- c('ggplot2','ggthemes','lubridate', 'readxl','plotly', 'dplyr','tidyr', 'scales') load_pkg(packages) min <- as.Date('2015-01-01') max <- as.Date('2020-07-01') p1 <- ggplot(pmi_data, aes(Date

Using geom_rect in plotly

∥☆過路亽.° 提交于 2021-02-10 14:55:17
问题 I have the following plot using ggplot2 and plotly . However, the plotly image does not display the shaded areas I've inserted using geom_rect . I'm guessing that this is because plotly doesn't support geom_rect , does anyone have a workaround to solve this? Here is my code library(rmsfuns) packages <- c('ggplot2','ggthemes','lubridate', 'readxl','plotly', 'dplyr','tidyr', 'scales') load_pkg(packages) min <- as.Date('2015-01-01') max <- as.Date('2020-07-01') p1 <- ggplot(pmi_data, aes(Date